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 pyams_content.component.paragraph.zmi import get_json_paragraph_markers_refresh_event |
12 |
13 |
13 __docformat__ = 'restructuredtext' |
14 __docformat__ = 'restructuredtext' |
14 |
15 |
15 |
16 |
16 # import standard library |
17 # import standard library |
53 weight = 10 |
54 weight = 10 |
54 action_class = 'action internal-links nowrap width-40' |
55 action_class = 'action internal-links nowrap width-40' |
55 icon_class = 'fa fa-fw fa-external-link-square fa-rotate-90' |
56 icon_class = 'fa fa-fw fa-external-link-square fa-rotate-90' |
56 icon_hint = _("Internal links") |
57 icon_hint = _("Internal links") |
57 |
58 |
|
59 marker_type = 'internal-links' |
|
60 |
58 @property |
61 @property |
59 def count(self): |
62 def count(self): |
60 return len([file for file in IAssociationContainer(self.context).values() |
63 return len([file for file in IAssociationContainer(self.context).values() |
61 if IInternalLink.providedBy(file)]) |
64 if IInternalLink.providedBy(file)]) |
62 |
65 |
103 """Internal link add form, JSON renderer""" |
106 """Internal link add form, JSON renderer""" |
104 |
107 |
105 def get_ajax_output(self, changes): |
108 def get_ajax_output(self, changes): |
106 output = super(InternalLinkAJAXAddForm, self).get_ajax_output(changes) |
109 output = super(InternalLinkAJAXAddForm, self).get_ajax_output(changes) |
107 if output: |
110 if output: |
108 counter = InternalLinksCounter(self.context, self.request, self, None) |
111 output.setdefault('events', []).append(get_json_paragraph_markers_refresh_event(self.context, self.request, |
109 counter.update() |
112 self, InternalLinksCounter)) |
110 output.setdefault('events', []).append({ |
|
111 'event': 'myams.refresh', |
|
112 'options': { |
|
113 'handler': 'PyAMS_content.paragraphs.updateMarkers', |
|
114 'object_name': self.context.__name__, |
|
115 'marker_type': 'internal-links', |
|
116 'marker_tag': counter.render() |
|
117 } |
|
118 }) |
|
119 return output |
113 return output |
120 |
114 |
121 |
115 |
122 @pagelet_config(name='properties.html', context=IInternalLink, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
116 @pagelet_config(name='properties.html', context=IInternalLink, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
123 class InternalLinkPropertiesEditForm(AdminDialogEditForm): |
117 class InternalLinkPropertiesEditForm(AdminDialogEditForm): |
124 """Internal link properties edit form""" |
118 """Internal link properties edit form""" |
|
119 |
|
120 prefix = 'internallink_properties.' |
125 |
121 |
126 legend = _("Edit internal link properties") |
122 legend = _("Edit internal link properties") |
127 icon_css_class = 'fa fa-fw fa-external-link-square fa-rotate-90' |
123 icon_css_class = 'fa fa-fw fa-external-link-square fa-rotate-90' |
128 |
124 |
129 fields = field.Fields(IInternalLink).select('reference', 'title', 'description') |
125 fields = field.Fields(IInternalLink).select('reference', 'title', 'description') |
161 weight = 11 |
157 weight = 11 |
162 action_class = 'action external-links nowrap width-40' |
158 action_class = 'action external-links nowrap width-40' |
163 icon_class = 'fa fa-fw fa-external-link' |
159 icon_class = 'fa fa-fw fa-external-link' |
164 icon_hint = _("External links") |
160 icon_hint = _("External links") |
165 |
161 |
|
162 marker_type = 'external-links' |
|
163 |
166 @property |
164 @property |
167 def count(self): |
165 def count(self): |
168 return len([file for file in IAssociationContainer(self.context).values() |
166 return len([file for file in IAssociationContainer(self.context).values() |
169 if IExternalLink.providedBy(file)]) |
167 if IExternalLink.providedBy(file)]) |
170 |
168 |
211 """External link add form, JSON renderer""" |
209 """External link add form, JSON renderer""" |
212 |
210 |
213 def get_ajax_output(self, changes): |
211 def get_ajax_output(self, changes): |
214 output = super(ExternalLinkAJAXAddForm, self).get_ajax_output(changes) |
212 output = super(ExternalLinkAJAXAddForm, self).get_ajax_output(changes) |
215 if output: |
213 if output: |
216 counter = ExternalLinksCounter(self.context, self.request, self, None) |
214 output.setdefault('events', []).append(get_json_paragraph_markers_refresh_event(self.context, self.request, |
217 counter.update() |
215 self, ExternalLinksCounter)) |
218 output.setdefault('events', []).append({ |
|
219 'event': 'myams.refresh', |
|
220 'options': { |
|
221 'handler': 'PyAMS_content.paragraphs.updateMarkers', |
|
222 'object_name': self.context.__name__, |
|
223 'marker_type': 'external-links', |
|
224 'marker_tag': counter.render() |
|
225 } |
|
226 }) |
|
227 return output |
216 return output |
228 |
217 |
229 |
218 |
230 @pagelet_config(name='properties.html', context=IExternalLink, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
219 @pagelet_config(name='properties.html', context=IExternalLink, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
231 class ExternalLinkPropertiesEditForm(AdminDialogEditForm): |
220 class ExternalLinkPropertiesEditForm(AdminDialogEditForm): |
232 """External link properties edit form""" |
221 """External link properties edit form""" |
|
222 |
|
223 prefix = 'externallink_properties.' |
233 |
224 |
234 legend = _("Edit external link properties") |
225 legend = _("Edit external link properties") |
235 icon_css_class = 'fa fa-fw fa-external-link' |
226 icon_css_class = 'fa fa-fw fa-external-link' |
236 |
227 |
237 fields = field.Fields(IExternalLink).select('url', 'title', 'description', 'language') |
228 fields = field.Fields(IExternalLink).select('url', 'title', 'description', 'language') |
269 weight = 12 |
260 weight = 12 |
270 action_class = 'action mailto-links nowrap width-40' |
261 action_class = 'action mailto-links nowrap width-40' |
271 icon_class = 'fa fa-fw fa-envelope-o' |
262 icon_class = 'fa fa-fw fa-envelope-o' |
272 icon_hint = _("Mailto links") |
263 icon_hint = _("Mailto links") |
273 |
264 |
|
265 marker_type = 'mailto-links' |
|
266 |
274 @property |
267 @property |
275 def count(self): |
268 def count(self): |
276 return len([file for file in IAssociationContainer(self.context).values() |
269 return len([file for file in IAssociationContainer(self.context).values() |
277 if IMailtoLink.providedBy(file)]) |
270 if IMailtoLink.providedBy(file)]) |
278 |
271 |
319 """Mailto link add form, JSON renderer""" |
312 """Mailto link add form, JSON renderer""" |
320 |
313 |
321 def get_ajax_output(self, changes): |
314 def get_ajax_output(self, changes): |
322 output = super(MailtoLinkAJAXAddForm, self).get_ajax_output(changes) |
315 output = super(MailtoLinkAJAXAddForm, self).get_ajax_output(changes) |
323 if output: |
316 if output: |
324 counter = MailtoLinksCounter(self.context, self.request, self, None) |
317 output.setdefault('events', []).append(get_json_paragraph_markers_refresh_event(self.context, self.request, |
325 counter.update() |
318 self, MailtoLinksCounter)) |
326 output.setdefault('events', []).append({ |
|
327 'event': 'myams.refresh', |
|
328 'options': { |
|
329 'handler': 'PyAMS_content.paragraphs.updateMarkers', |
|
330 'object_name': self.context.__name__, |
|
331 'marker_type': 'mailto-links', |
|
332 'marker_tag': counter.render() |
|
333 } |
|
334 }) |
|
335 return output |
319 return output |
336 |
320 |
337 |
321 |
338 @pagelet_config(name='properties.html', context=IMailtoLink, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
322 @pagelet_config(name='properties.html', context=IMailtoLink, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
339 class MailtoLinkPropertiesEditForm(AdminDialogEditForm): |
323 class MailtoLinkPropertiesEditForm(AdminDialogEditForm): |
340 """Mailto link properties edit form""" |
324 """Mailto link properties edit form""" |
341 |
325 |
|
326 prefix = 'mailtolink_properties.' |
|
327 |
342 legend = _("Edit mailto link properties") |
328 legend = _("Edit mailto link properties") |
343 icon_css_class = 'fa fa-fw fa-envelope-o' |
329 icon_css_class = 'fa fa-fw fa-envelope-o' |
344 |
330 |
345 fields = field.Fields(IMailtoLink).select('address', 'address_name', 'title', 'description') |
331 fields = field.Fields(IMailtoLink).select('address', 'address_name', 'title', 'description') |
346 ajax_handler = 'properties.json' |
332 ajax_handler = 'properties.json' |
356 permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True) |
342 permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True) |
357 class MailtoLinkPropertiesAJAXEditForm(AssociationItemAJAXEditForm, MailtoLinkPropertiesEditForm): |
343 class MailtoLinkPropertiesAJAXEditForm(AssociationItemAJAXEditForm, MailtoLinkPropertiesEditForm): |
358 """Mailto link properties edit form, JSON renderer""" |
344 """Mailto link properties edit form, JSON renderer""" |
359 |
345 |
360 def get_ajax_output(self, changes): |
346 def get_ajax_output(self, changes): |
361 if ('title' in changes.get(IBaseLink, ())) or \ |
347 if ('title' in changes.get(IBaseLink, ())) or changes.get(IMailtoLink, ()): |
362 ('reference' in changes.get(IMailtoLink, ())): |
|
363 return self.get_associations_table() |
348 return self.get_associations_table() |
364 else: |
349 else: |
365 return super(MailtoLinkPropertiesAJAXEditForm, self).get_ajax_output(changes) |
350 return super(MailtoLinkPropertiesAJAXEditForm, self).get_ajax_output(changes) |