30 # import packages |
30 # import packages |
31 from pyams_content.component.paragraph.zmi import IParagraphContainerView, BaseParagraphAddMenu, \ |
31 from pyams_content.component.paragraph.zmi import IParagraphContainerView, BaseParagraphAddMenu, \ |
32 BaseParagraphAJAXAddForm, BaseParagraphPropertiesEditForm, BaseParagraphAJAXEditForm, IParagraphEditFormButtons |
32 BaseParagraphAJAXAddForm, BaseParagraphPropertiesEditForm, BaseParagraphAJAXEditForm, IParagraphEditFormButtons |
33 from pyams_content.features.renderer.zmi.widget import RendererFieldWidget |
33 from pyams_content.features.renderer.zmi.widget import RendererFieldWidget |
34 from pyams_content.shared.logo.paragraph import LogosParagraph |
34 from pyams_content.shared.logo.paragraph import LogosParagraph |
|
35 from pyams_form.form import ajax_config |
35 from pyams_pagelet.pagelet import pagelet_config |
36 from pyams_pagelet.pagelet import pagelet_config |
36 from pyams_skin.event import get_json_widget_refresh_event |
37 from pyams_skin.event import get_json_widget_refresh_event |
37 from pyams_utils.adapter import adapter_config |
38 from pyams_utils.adapter import adapter_config |
38 from pyams_utils.traversing import get_parent |
39 from pyams_utils.traversing import get_parent |
39 from pyams_viewlet.viewlet import viewlet_config |
40 from pyams_viewlet.viewlet import viewlet_config |
56 paragraph_type = LOGOS_PARAGRAPH_TYPE |
57 paragraph_type = LOGOS_PARAGRAPH_TYPE |
57 |
58 |
58 |
59 |
59 @pagelet_config(name='add-logos-paragraph.html', context=IParagraphContainerTarget, layer=IPyAMSLayer, |
60 @pagelet_config(name='add-logos-paragraph.html', context=IParagraphContainerTarget, layer=IPyAMSLayer, |
60 permission=MANAGE_CONTENT_PERMISSION) |
61 permission=MANAGE_CONTENT_PERMISSION) |
|
62 @ajax_config(name='add-logos-paragraph.json', context=IParagraphContainerTarget, layer=IPyAMSLayer, |
|
63 base=BaseParagraphAJAXAddForm) |
61 class LogosParagraphAddForm(AdminDialogAddForm): |
64 class LogosParagraphAddForm(AdminDialogAddForm): |
62 """Logos paragraph add form""" |
65 """Logos paragraph add form""" |
63 |
66 |
64 legend = _("Add new logos paragraph") |
67 legend = _("Add new logos paragraph") |
65 icon_css_class = 'fa fa-fw fa-th-large' |
68 icon_css_class = 'fa fa-fw fa-th-large' |
66 |
69 |
67 fields = field.Fields(ILogosParagraph).omit('__parent__', '__name__', 'visible') |
70 fields = field.Fields(ILogosParagraph).omit('__parent__', '__name__', 'visible') |
68 ajax_handler = 'add-logos-paragraph.json' |
|
69 edit_permission = MANAGE_CONTENT_PERMISSION |
71 edit_permission = MANAGE_CONTENT_PERMISSION |
70 |
72 |
71 def create(self, data): |
73 def create(self, data): |
72 return LogosParagraph() |
74 return LogosParagraph() |
73 |
75 |
74 def add(self, object): |
76 def add(self, object): |
75 IParagraphContainer(self.context).append(object) |
77 IParagraphContainer(self.context).append(object) |
76 |
78 |
77 |
79 |
78 @view_config(name='add-logos-paragraph.json', context=IParagraphContainerTarget, request_type=IPyAMSLayer, |
|
79 permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True) |
|
80 class LogosParagraphAJAXAddForm(BaseParagraphAJAXAddForm, LogosParagraphAddForm): |
|
81 """Logos paragraph add form, JSON renderer""" |
|
82 |
|
83 |
|
84 @pagelet_config(name='properties.html', context=ILogosParagraph, layer=IPyAMSLayer, |
80 @pagelet_config(name='properties.html', context=ILogosParagraph, layer=IPyAMSLayer, |
85 permission=MANAGE_CONTENT_PERMISSION) |
81 permission=MANAGE_CONTENT_PERMISSION) |
|
82 @ajax_config(name='properties.json', context=ILogosParagraph, layer=IPyAMSLayer) |
86 class LogosParagraphPropertiesEditForm(BaseParagraphPropertiesEditForm): |
83 class LogosParagraphPropertiesEditForm(BaseParagraphPropertiesEditForm): |
87 """Logos paragraph properties edit form""" |
84 """Logos paragraph properties edit form""" |
88 |
85 |
89 prefix = 'logos_properties.' |
86 prefix = 'logos_properties.' |
90 |
87 |
97 icon_css_class = 'fa fa-fw fa-th-large' |
94 icon_css_class = 'fa fa-fw fa-th-large' |
98 |
95 |
99 fields = field.Fields(ILogosParagraph).omit('__parent__', '__name__', 'visible') |
96 fields = field.Fields(ILogosParagraph).omit('__parent__', '__name__', 'visible') |
100 fields['renderer'].widgetFactory = RendererFieldWidget |
97 fields['renderer'].widgetFactory = RendererFieldWidget |
101 |
98 |
102 ajax_handler = 'properties.json' |
|
103 edit_permission = MANAGE_CONTENT_PERMISSION |
99 edit_permission = MANAGE_CONTENT_PERMISSION |
104 |
100 |
105 |
101 |
106 @view_config(name='properties.json', context=ILogosParagraph, request_type=IPyAMSLayer, |
|
107 permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True) |
|
108 class LogosParagraphPropertiesAJAXEditForm(BaseParagraphAJAXEditForm, LogosParagraphPropertiesEditForm): |
|
109 """Logos paragraph properteis edit form, JSOn renderer""" |
|
110 |
|
111 |
|
112 @adapter_config(context=(ILogosParagraph, IPyAMSLayer), provides=IParagraphInnerEditor) |
102 @adapter_config(context=(ILogosParagraph, IPyAMSLayer), provides=IParagraphInnerEditor) |
|
103 @ajax_config(name='inner-properties.json', context=ILogosParagraph, layer=IPyAMSLayer, |
|
104 base=BaseParagraphAJAXEditForm) |
113 @implementer(IInnerForm) |
105 @implementer(IInnerForm) |
114 class LogosParagraphInnerEditForm(LogosParagraphPropertiesEditForm): |
106 class LogosParagraphInnerEditForm(LogosParagraphPropertiesEditForm): |
115 """Logos paragraph properties inner edit form""" |
107 """Logos paragraph properties inner edit form""" |
116 |
108 |
117 legend = None |
109 legend = None |
118 ajax_handler = 'inner-properties.json' |
|
119 |
110 |
120 @property |
111 @property |
121 def buttons(self): |
112 def buttons(self): |
122 if self.mode == INPUT_MODE: |
113 if self.mode == INPUT_MODE: |
123 return button.Buttons(IParagraphEditFormButtons) |
114 return button.Buttons(IParagraphEditFormButtons) |