7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
10 # FOR A PARTICULAR PURPOSE. |
10 # FOR A PARTICULAR PURPOSE. |
11 # |
11 # |
|
12 from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget |
|
13 |
|
14 from pyams_form.group import NamedWidgetsGroup |
|
15 |
12 |
16 |
13 __docformat__ = 'restructuredtext' |
17 __docformat__ = 'restructuredtext' |
14 |
18 |
15 from uuid import uuid4 |
19 from uuid import uuid4 |
16 |
20 |
81 class ContentLinkAddForm(AdminDialogAddForm): |
85 class ContentLinkAddForm(AdminDialogAddForm): |
82 """Content link add form""" |
86 """Content link add form""" |
83 |
87 |
84 legend = _("Rent existing content") |
88 legend = _("Rent existing content") |
85 |
89 |
86 fields = field.Fields(IContentLinkAddFormFields).select('reference', 'navigation_title', |
90 fields = field.Fields(IContentLinkAddFormFields).select('reference', 'navigation_title', 'show_header', |
87 'navigation_header', 'parent') |
91 'navigation_header', 'parent') |
|
92 fields['show_header'].widgetFactory = SingleCheckBoxFieldWidget |
88 fields['parent'].widgetFactory = SiteManagerFoldersSelectorFieldWidget |
93 fields['parent'].widgetFactory = SiteManagerFoldersSelectorFieldWidget |
89 |
94 |
90 edit_permission = CREATE_CONTENT_PERMISSION |
95 edit_permission = CREATE_CONTENT_PERMISSION |
91 |
96 |
92 __target = None |
97 __target = None |
95 super(ContentLinkAddForm, self).updateWidgets(prefix) |
100 super(ContentLinkAddForm, self).updateWidgets(prefix) |
96 if 'parent' in self.widgets: |
101 if 'parent' in self.widgets: |
97 self.widgets['parent'].permission = CREATE_CONTENT_PERMISSION |
102 self.widgets['parent'].permission = CREATE_CONTENT_PERMISSION |
98 if 'navigation_header' in self.widgets: |
103 if 'navigation_header' in self.widgets: |
99 self.widgets['navigation_header'].widget_css_class = 'input height-100' |
104 self.widgets['navigation_header'].widget_css_class = 'input height-100' |
|
105 |
|
106 def updateGroups(self): |
|
107 self.add_group(NamedWidgetsGroup(self, 'reference', self.widgets, |
|
108 ('reference', 'navigation_title'))) |
|
109 self.add_group(NamedWidgetsGroup(self, 'header', self.widgets, |
|
110 ('show_header', 'navigation_header'), |
|
111 fieldset_class='inner bordered', |
|
112 legend=_("Show navigation header"), |
|
113 css_class='inner', |
|
114 switch=True, |
|
115 checkbox_switch=True, |
|
116 checkbox_field=IContentLinkAddFormFields['show_header'])) |
|
117 self.add_group(NamedWidgetsGroup(self, 'reference', self.widgets, |
|
118 ('parent',))) |
|
119 super(ContentLinkAddForm, self).updateGroups() |
100 |
120 |
101 def create(self, data): |
121 def create(self, data): |
102 return ContentLink() |
122 return ContentLink() |
103 |
123 |
104 def update_content(self, content, data): |
124 def update_content(self, content, data): |
146 |
166 |
147 prefix = 'link_properties.' |
167 prefix = 'link_properties.' |
148 |
168 |
149 legend = _("Edit content link properties") |
169 legend = _("Edit content link properties") |
150 |
170 |
151 fields = field.Fields(IContentLink).select('reference', 'navigation_title', 'navigation_header') |
171 fields = field.Fields(IContentLink).select('reference', 'navigation_title', 'show_header', 'navigation_header') |
|
172 fields['show_header'].widgetFactory = SingleCheckBoxFieldWidget |
152 edit_permission = MANAGE_CONTENT_PERMISSION |
173 edit_permission = MANAGE_CONTENT_PERMISSION |
153 |
174 |
154 def updateWidgets(self, prefix=None): |
175 def updateWidgets(self, prefix=None): |
155 super(ContentLinkPropertiesEditForm, self).updateWidgets(prefix) |
176 super(ContentLinkPropertiesEditForm, self).updateWidgets(prefix) |
156 if 'navigation_header' in self.widgets: |
177 if 'navigation_header' in self.widgets: |
157 self.widgets['navigation_header'].widget_css_class = 'input height-100' |
178 self.widgets['navigation_header'].widget_css_class = 'input height-100' |
|
179 |
|
180 def updateGroups(self): |
|
181 self.add_group(NamedWidgetsGroup(self, 'reference', self.widgets, |
|
182 ('reference', 'navigation_title'))) |
|
183 self.add_group(NamedWidgetsGroup(self, 'header', self.widgets, |
|
184 ('show_header', 'navigation_header'), |
|
185 fieldset_class='inner bordered', |
|
186 legend=_("Show navigation header"), |
|
187 css_class='inner', |
|
188 switch=True, |
|
189 checkbox_switch=True, |
|
190 checkbox_field=IContentLink['show_header'])) |
|
191 super(ContentLinkPropertiesEditForm, self).updateGroups() |
158 |
192 |
159 def get_ajax_output(self, changes): |
193 def get_ajax_output(self, changes): |
160 output = super(self.__class__, self).get_ajax_output(changes) |
194 output = super(self.__class__, self).get_ajax_output(changes) |
161 intids = get_utility(IIntIds) |
195 intids = get_utility(IIntIds) |
162 if changes: |
196 if changes: |
203 class ExternalContentLinkAddForm(AdminDialogAddForm): |
237 class ExternalContentLinkAddForm(AdminDialogAddForm): |
204 """External content link add form""" |
238 """External content link add form""" |
205 |
239 |
206 legend = _("Link external content") |
240 legend = _("Link external content") |
207 |
241 |
208 fields = field.Fields(IExternalContentLinkAddFormFields).select('url', 'navigation_title', |
242 fields = field.Fields(IExternalContentLinkAddFormFields).select('url', 'navigation_title', 'show_header', |
209 'navigation_header', 'parent') |
243 'navigation_header', 'parent') |
210 fields['parent'].widgetFactory = SiteManagerFoldersSelectorFieldWidget |
244 fields['parent'].widgetFactory = SiteManagerFoldersSelectorFieldWidget |
211 |
245 |
212 edit_permission = CREATE_CONTENT_PERMISSION |
246 edit_permission = CREATE_CONTENT_PERMISSION |
213 |
247 |