<?xml version="1.0" encoding="utf-8"?>
<?py
from cocktail.html.uigeneration import default_search_control
?>

<py:cocktail.html.Form
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:py="http://www.whads.com/ns/cocktail/templates"
    py:name_prefix="filter_"
    py:required_marks="${False}"
    py:generate_groups="${False}">

    <?py-class
    base_ui_generators = [default_search_control]

    def create_language_display(self, obj, member, value, **context):

        display = loader.new("cocktail.html.DropdownSelector")
        display.empty_option_displayed = not member.required
        display.empty_label = translations("cocktail.html.UserFilterEntry any language")

        @extend(display)
        def get_item_label(display, language):
            if language:
                return translations("translated into", lang = language)
            else:
                return call_base(language)

        return display

    def create_operator_display(self, obj, member, value, **context):

        display = loader.new("cocktail.html.DropdownSelector")
        display.empty_option_displayed = False

        @refine(display)
        def get_item_label(self, item):
            return translations("cocktail.html.UserFilterEntry operator " + item)

        return display
    ?>

    <?py
    self.set_member_label("language", "")
    self.set_member_label("operator", "")
    self.set_member_label("value", "")
    ?>

</py:cocktail.html.Form>
