# HG changeset patch # User Thierry Florac # Date 1539270975 -7200 # Node ID 6cdae82405f717498ed6021ca9651ab7ea3db2b8 # Parent f82a78ce9963e714163477bb287bd3666c9e9962# Parent d69762f1ca4d09f830e8b0f235071d2ec0c3e601 Sort pictograms in manager settings form diff -r d69762f1ca4d -r 6cdae82405f7 src/pyams_content/component/paragraph/zmi/frame.py --- a/src/pyams_content/component/paragraph/zmi/frame.py Thu Oct 11 16:25:04 2018 +0200 +++ b/src/pyams_content/component/paragraph/zmi/frame.py Thu Oct 11 17:16:15 2018 +0200 @@ -9,8 +9,6 @@ # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # -from pyams_content.component.paragraph import IBaseParagraph - __docformat__ = 'restructuredtext' @@ -22,8 +20,8 @@ from pyams_content.component.association.zmi import AssociationsTable from pyams_content.component.association.zmi.interfaces import IAssociationsParentForm from pyams_content.component.paragraph.frame import FrameParagraph -from pyams_content.component.paragraph.interfaces import IParagraphContainer, IParagraphContainerTarget, \ - PARAGRAPH_HIDDEN_FIELDS +from pyams_content.component.paragraph.interfaces import IBaseParagraph, IParagraphContainer, \ + IParagraphContainerTarget, PARAGRAPH_HIDDEN_FIELDS from pyams_content.component.paragraph.interfaces.frame import FRAME_PARAGRAPH_TYPE, IFrameParagraph from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm, \ BaseParagraphAddMenu, BaseParagraphPropertiesEditForm, IParagraphInnerEditFormButtons, IParagraphTitleValue, \ @@ -37,7 +35,7 @@ from pyams_form.interfaces.form import IInnerForm from pyams_i18n.interfaces import II18n from pyams_pagelet.pagelet import pagelet_config -from pyams_skin.event import get_json_switched_table_refresh_event, get_json_widget_refresh_event +from pyams_skin.event import get_json_switched_table_refresh_event from pyams_skin.interfaces.tinymce import ITinyMCEConfiguration from pyams_skin.interfaces.viewlet import IToolbarAddingMenu from pyams_skin.layer import IPyAMSLayer @@ -66,8 +64,8 @@ configuration = { 'ams-tinymce-menubar': False, - 'ams-tinymce-plugins': ['lists', ], - 'ams-tinymce-toolbar': 'undo redo | bold italic | bullist numlist', + 'ams-tinymce-plugins': ['paste', 'lists'], + 'ams-tinymce-toolbar': 'undo redo | pastetext | bold italic | bullist numlist', 'ams-tinymce-toolbar1': False, 'ams-tinymce-toolbar2': False, 'ams-tinymce-height': 150 diff -r d69762f1ca4d -r 6cdae82405f7 src/pyams_content/reference/pictograms/zmi/manager.py --- a/src/pyams_content/reference/pictograms/zmi/manager.py Thu Oct 11 16:25:04 2018 +0200 +++ b/src/pyams_content/reference/pictograms/zmi/manager.py Thu Oct 11 17:16:15 2018 +0200 @@ -12,35 +12,31 @@ __docformat__ = 'restructuredtext' - -# import standard library import json import locale -# import interfaces +from z3c.form import button, field +from z3c.form.util import changedField +from zope.interface import Interface, implementer + from pyams_content.interfaces import MANAGE_TOOL_PERMISSION -from pyams_content.reference.pictograms.interfaces import IPictogramManagerTarget, IPictogramManager, IPictogramTable -from pyams_form.interfaces.form import IWidgetForm, IWidgetsSuffixViewletsManager, IUncheckedEditFormButtons +from pyams_content.reference.pictograms.interfaces import IPictogramManager, IPictogramManagerTarget, IPictogramTable +from pyams_form.form import ajax_config +from pyams_form.interfaces.form import IUncheckedEditFormButtons, IWidgetForm, IWidgetsSuffixViewletsManager from pyams_i18n.interfaces import II18n +from pyams_pagelet.pagelet import pagelet_config from pyams_skin.interfaces import IInnerPage from pyams_skin.layer import IPyAMSLayer +from pyams_skin.viewlet.menu import MenuItem +from pyams_template.template import template_config from pyams_utils.interfaces.data import IObjectData +from pyams_utils.registry import query_utility +from pyams_utils.traversing import get_parent +from pyams_viewlet.viewlet import Viewlet, viewlet_config +from pyams_zmi.form import AdminEditForm from pyams_zmi.interfaces.menu import IPropertiesMenu from pyams_zmi.layer import IAdminLayer -# import packages -from pyams_form.form import ajax_config -from pyams_pagelet.pagelet import pagelet_config -from pyams_skin.viewlet.menu import MenuItem -from pyams_template.template import template_config -from pyams_utils.registry import query_utility -from pyams_utils.traversing import get_parent -from pyams_viewlet.viewlet import viewlet_config, Viewlet -from pyams_zmi.form import AdminEditForm -from z3c.form import field, button -from z3c.form.util import changedField -from zope.interface import implementer, Interface - from pyams_content import _ @@ -87,30 +83,35 @@ class PictogramManagerSelectionView(Viewlet): """Pictogram manager selection viewlet""" + pictogram_table = None + pictogram_manager = None - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.table = query_utility(IPictogramTable) - self.target = get_parent(self.context, IPictogramManagerTarget) - if self.target is not None: - self.picto_manager = IPictogramManager(self.target) + def update(self): + super(PictogramManagerSelectionView, self).update() + self.pictogram_table = query_utility(IPictogramTable) + target = get_parent(self.context, IPictogramManagerTarget) + if target is not None: + self.pictogram_manager = IPictogramManager(target) - def sort_pictogram(self, pictograms): - return sorted(pictograms, - key=lambda x: locale.strxfrm(II18n(x).query_attribute('title', - request=self.request) or '').lower()) + @property + def sorted_pictograms(self): + yield from sorted(self.pictogram_table.values(), + key=lambda x: locale.strxfrm(II18n(x).query_attribute('title', + request=self.request) or '').lower()) @property def available_pictograms(self): - if self.picto_manager: - for pictogram in self.sort_pictogram(self.table.values()): - if pictogram.__name__ not in self.picto_manager.selected_pictograms: + manager = self.pictogram_manager + if manager is not None: + for pictogram in self.sorted_pictograms: + if pictogram.__name__ not in manager.selected_pictograms: yield pictogram @property def selected_pictograms(self): - if self.picto_manager.selected_pictograms: - for name in self.picto_manager.selected_pictograms: - pictogram = self.table.get(name) + manager = self.pictogram_manager + if manager is not None: + for name in (manager.selected_pictograms or ()): + pictogram = self.pictogram_table.get(name) if pictogram is not None: yield pictogram