Ejemplo n.º 1
0
class IsotopeViewConfigurationForm(form.Form):
    fields = field.Fields(ICollectiveIsotopeViewSettings)
    label = _(u"Isotope View Configuration")
    description = _(
        u"Configuration of layout, filters, and sorting for this view")

    def getContent(self):
        annotations = IAnnotations(self.context)
        current_config = annotations.get(ISOTOPE_CONFIGURATION_KEY, {})
        return current_config

    @button.buttonAndHandler(_(u'Save Configuration'))
    def handleApply(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        assert IAttributeAnnotatable.providedBy(self.context)
        annotations = IAnnotations(self.context)
        annotations[ISOTOPE_CONFIGURATION_KEY] = data

        self.request.response.redirect(self.context.absolute_url())
        messages = IStatusMessage(self.request)
        messages.add(_(u"Your configuration has been saved"), type=u"info")
Ejemplo n.º 2
0
class IsotopeSettingsControlpanelForm(controlpanel.RegistryEditForm):

    schema = ICollectiveIsotopeSettings
    label = _(u'Isotope View Settings')
    description = _(u'Site-wide settings to control the Isotope View for '
                    u'collections and folders')

    def updateFields(self):
        super(IsotopeSettingsControlpanelForm, self).updateFields()
        for field in ['available_filters', 'available_sorts']:
            self.fields[field].widgetFactory = DataGridFieldFactory
            self.fields[field].allow_insert = True
Ejemplo n.º 3
0
class IFilterSchema(Interface):
    column_name = field.Choice(
        title=_(u'Column Name'),
        description=_(u'Enter the name of a catalog metadata column'),
        vocabulary='collective.isotope.vocabularies.friendly_columns',
        required=False,
        missing_value=u'')
    label = field.TextLine(
        title=_(u'Label'),
        description=_(
            u'If desired, enter the human-readable label for this column'),
        required=False,
        missing_value=u'')
Ejemplo n.º 4
0
class ICollectiveIsotopeLayoutSettings(Interface):
    """Settings for the options that control the javascript Isotope library
    """
    layoutMode = schema.Choice(
        title=_(u'Layout Mode'),
        description=_(u'Select the default layout mode to be used on all '
                      u'isotope views throughout your website'),
        values=[u'masonry', u'fitRows', u'vertical'],
        default=u'masonry')

    percentPosition = schema.Bool(
        title=_(u'Use percentPosition'),
        description=_(u'Set the horizontal position of items by percent '
                      u'rather than pixel size. This works best with items '
                      u'that are sized by percentage. On by default'),
        default=True)
Ejemplo n.º 5
0
class ICollectiveIsotopeViewSettings(Interface):
    """Settings for configuration of individual views"""
    filter = schema.List(
        title=_(u'Filtering'),
        description=_(u'Select the ttributes on which users will be able to '
                      u'filter the items listed in this view. If no values '
                      u'are selected, user filtering will be disabled'),
        required=False,
        value_type=schema.Choice(
            vocabulary='collective.isotope.vocabularies.available_filters', ))

    sort = schema.List(
        title=_(u'Sorting'),
        description=_(u'Select the attributes on which users will be able to '
                      u'sort the items listed in this view. If no value is '
                      u'selected, user sorting will be disabled.'),
        required=False,
        value_type=schema.Choice(
            vocabulary='collective.isotope.vocabularies.available_sorts'))
Ejemplo n.º 6
0
    def handleApply(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        assert IAttributeAnnotatable.providedBy(self.context)
        annotations = IAnnotations(self.context)
        annotations[ISOTOPE_CONFIGURATION_KEY] = data

        self.request.response.redirect(self.context.absolute_url())
        messages = IStatusMessage(self.request)
        messages.add(_(u"Your configuration has been saved"), type=u"info")
Ejemplo n.º 7
0
class ICollectiveIsotopeFilterSettings(Interface):
    """Settings to control filtering options"""
    available_filters = schema.List(
        title=_(u'Available Filters'),
        description=_(u'List the filters that will be available for Istotope '
                      u'views throughout your site.'),
        value_type=ImportableTextDictRow(title=_(u'Filter'),
                                         schema=IFilterSchema))

    available_sorts = schema.List(
        title=_(u'Available Sorts'),
        description=_(u'List the sortable attributes that will be available '
                      u'for Istotope views throughout your site.'),
        value_type=ImportableTextDictRow(title=_(u'Sort'),
                                         schema=IFilterSchema))