Example #1
0
    def create_entry(self, item):

        entry = Element("li")
        value = self.get_item_value(item)
        eligible = value is not uneligible

        # Control (checkbox or radio button)
        if eligible:
            entry.control = Element("input",
                name = self.name,
                value = value,
                checked = self.is_selected(item)
            )

            if self.selection_mode == SINGLE_SELECTION:
                entry.control["type"] = "radio"

            elif self.selection_mode == MULTIPLE_SELECTION:
                entry.control["type"] = "checkbox"

            entry.append(entry.control)

        # Label
        if eligible:
            entry.label = Element("label")
            entry.label["for"] = entry.control.require_id()
        else:
            entry.label = Element("span")
            entry.add_class("uneligible")

        entry.label.append(self.get_item_label(item))
        entry.append(entry.label)

        return entry
    def create_entry(self, item):

        value = self.get_item_value(item)
        selected = self.is_selected(item)

        entry = Element()
        entry.add_class("entry")

        if self.selection_mode == SINGLE_SELECTION:
            entry.control = Element("input", type = "radio", checked = selected)
        elif self.selection_mode == MULTIPLE_SELECTION:
            entry.control = CheckBox()
            entry.control.value = selected
        else:
            raise ValueError("Invalid selection mode")

        entry.control["name"] = self.name
        entry.control["value"] = value
        entry.append(entry.control)

        entry.label = Element("label")
        entry.label["for"] = entry.control.require_id()
        entry.label.append(self.get_item_label(item))
        entry.append(entry.label)

        if value:
            entry.label.set_style("font-size", str(self._font_sizes[value]) + "%")

        return entry
Example #3
0
    def create_class_entry(self, cls):

        entry = Element()
        entry.add_class("content_type")

        entry.label = self.create_class_label(cls)
        entry.append(entry.label)

        entry.members_container = Element()
        entry.members_container.add_class("members")

        has_visible_members = False

        for member in cls.members(False).itervalues():
            if self.member_is_eligible(member):
                has_visible_members = True
                entry.members_container.append(
                    self.create_member_entry(member))

        if has_visible_members:
            entry.append(entry.members_container)

        entry.derived_classes_container = Element()
        entry.derived_classes_container.add_class("derived_classes")
        entry.append(entry.derived_classes_container)

        for derived_schema in cls.derived_schemas(recursive=False):
            if derived_schema.visible:
                entry.derived_classes_container.append(
                    self.create_class_entry(derived_schema))

        return entry
Example #4
0
    def create_entry(self, item):

        entry = Element("li")

        if (self.highlighted_selection
                and not (self.root_visibility == self.MERGED_ROOT and
                         item is self.root and self.selection is not self.root)
                and item in self._expanded):
            entry.add_class("selected")
            if item is self.selection:
                entry.add_class("active")

        entry.label = self.create_label(item)
        entry.append(entry.label)

        children = self.get_expanded_children(item)

        if self.create_empty_containers or children:

            for child in children:
                if self._is_accessible(child) != NOT_ACCESSIBLE:
                    entry.add_class("branch")
                    break

            entry.container = self.create_children_container(item, children)
            entry.append(entry.container)
        else:
            entry.add_class("leaf")

        return entry
Example #5
0
    def create_group(self, grouping):

        container = Element()
        container.add_class("group")

        container.label = self.create_group_label(grouping)
        container.append(container.label)

        self._create_entries(grouping.items, container)
        self._create_nested_groups(grouping, container)

        return container
Example #6
0
    def create_entry(self, item):

        entry = Element()
        entry.add_class("entry")

        entry.check = CheckBox()
        entry.check.name = self.name
        entry.check.value = self.is_selected(item)
        entry.check["value"] = self.get_item_value(item)
        entry.append(entry.check)

        entry.label = Element("label")
        entry.label["for"] = entry.check.require_id()
        entry.label.append(self.get_item_label(item))
        entry.append(entry.label)

        return entry
Example #7
0
    def create_member_entry(self, member):

        value = member.schema.full_name + "." + member.name

        entry = Element()

        entry.check = CheckBox()
        entry.check["name"] = self.name
        entry.check.require_id()
        entry.check.value = value in self.value
        entry.check["value"] = value
        entry.append(entry.check)

        entry.label = Element("label")
        entry.label["for"] = entry.check["id"]
        entry.label.append(translations(member.schema.name + "." +
                                        member.name))
        entry.append(entry.label)

        return entry
Example #8
0
    def create_empty_option(self):

        entry = Element("li")

        entry.control = Element("input",
                                type=self._control_type,
                                name=self.name,
                                value="",
                                checked=self.value is None)
        bind_member(self, entry.control)
        entry.append(entry.control)

        entry.label = Element("label")
        entry.label.add_class("entry_label")
        entry.label.add_class("empty_option")
        entry.label.append(
            translations("woost.views.ContentTypePicker.empty_label"))
        entry.append(entry.label)

        entry.label["for"] = entry.control.require_id()

        return entry
Example #9
0
    def create_field_instance(self, member, language=None):

        field_instance = Element("td" if self.table_layout else "div")
        field_instance.add_class("field_instance")

        # Label
        if not self.get_member_hidden(member):

            if member.translated and not self.redundant_translation_labels:
                label = self.create_language_label(member, language)
            else:
                label = self.create_label(member, language)

            field_instance.label = label
            field_instance.append(label)

        # Control
        with language_context(language):
            field_instance.control = self.create_control(self.data, member)

        if field_instance.control.class_css:
            for class_name in field_instance.control.class_css.split(" "):
                field_instance.add_class("field_instance-" + class_name)

        insert = getattr(field_instance.control, "insert_into_form", None)

        if insert:
            insert(self, field_instance)
        else:
            field_instance.append(field_instance.control)

        if field_instance.control.tag \
        in ("input", "button", "select", "textarea"):
            field_instance.label["for"] = field_instance.control.require_id()

        return field_instance