Use base AJAX pagraph add form
authorThierry Florac <thierry.florac@onf.fr>
Tue, 12 Sep 2017 16:45:45 +0200
changeset 151 890d3c1e0c71
parent 150 90a1cb45caf8
child 152 363efe154011
Use base AJAX pagraph add form
src/pyams_content/component/association/zmi/paragraph.py
src/pyams_content/component/gallery/zmi/paragraph.py
src/pyams_content/component/paragraph/zmi/header.py
src/pyams_content/component/paragraph/zmi/html.py
--- a/src/pyams_content/component/association/zmi/paragraph.py	Tue Sep 12 16:42:36 2017 +0200
+++ b/src/pyams_content/component/association/zmi/paragraph.py	Tue Sep 12 16:45:45 2017 +0200
@@ -32,9 +32,8 @@
 
 # import packages
 from pyams_content.component.association.paragraph import AssociationParagraph
-from pyams_content.component.paragraph.zmi import BaseParagraphAJAXEditForm
+from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm
 from pyams_content.component.paragraph.zmi.container import ParagraphContainerView
-from pyams_form.form import AJAXAddForm
 from pyams_form.security import ProtectedFormObjectMixin
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.viewlet.toolbar import ToolbarMenuItem
@@ -82,13 +81,9 @@
 
 @view_config(name='add-association-paragraph.json', context=IParagraphContainerTarget, request_type=IPyAMSLayer,
              permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
-class AssociationParagraphAJAXAddForm(AJAXAddForm, AssociationParagraphAddForm):
+class AssociationParagraphAJAXAddForm(BaseParagraphAJAXAddForm, AssociationParagraphAddForm):
     """Association paragraph add form, JSON renderer"""
 
-    def get_ajax_output(self, changes):
-        return {'status': 'reload',
-                'location': '#paragraphs.html'}
-
 
 @pagelet_config(name='properties.html', context=IAssociationParagraph, layer=IPyAMSLayer,
                 permission=MANAGE_CONTENT_PERMISSION)
--- a/src/pyams_content/component/gallery/zmi/paragraph.py	Tue Sep 12 16:42:36 2017 +0200
+++ b/src/pyams_content/component/gallery/zmi/paragraph.py	Tue Sep 12 16:45:45 2017 +0200
@@ -30,10 +30,9 @@
 
 # import packages
 from pyams_content.component.gallery.paragraph import Gallery
-from pyams_content.component.paragraph.zmi import BaseParagraphAJAXEditForm
+from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm
 from pyams_content.component.paragraph.zmi.container import ParagraphContainerView
 from pyams_content.shared.common.zmi import WfSharedContentPermissionMixin
-from pyams_form.form import AJAXAddForm
 from pyams_form.security import ProtectedFormObjectMixin
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.viewlet.toolbar import ToolbarMenuItem, ToolbarAction
@@ -86,13 +85,9 @@
 
 @view_config(name='add-gallery.json', context=IParagraphContainerTarget, request_type=IPyAMSLayer,
              permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
-class GalleryAJAXAddForm(AJAXAddForm, GalleryAddForm):
+class GalleryAJAXAddForm(BaseParagraphAJAXAddForm, GalleryAddForm):
     """Gallery paragraph add form, JSON renderer"""
 
-    def get_ajax_output(self, changes):
-        return {'status': 'reload',
-                'location': '#paragraphs.html'}
-
 
 @pagelet_config(name='properties.html', context=IGalleryParagraph, layer=IPyAMSLayer,
                 permission=MANAGE_CONTENT_PERMISSION)
--- a/src/pyams_content/component/paragraph/zmi/header.py	Tue Sep 12 16:42:36 2017 +0200
+++ b/src/pyams_content/component/paragraph/zmi/header.py	Tue Sep 12 16:45:45 2017 +0200
@@ -30,9 +30,8 @@
 
 # import packages
 from pyams_content.component.paragraph.header import HeaderParagraph
-from pyams_content.component.paragraph.zmi import BaseParagraphAJAXEditForm
+from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm
 from pyams_content.component.paragraph.zmi.container import ParagraphContainerView
-from pyams_form.form import AJAXAddForm
 from pyams_form.security import ProtectedFormObjectMixin
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.viewlet.toolbar import ToolbarMenuItem
@@ -85,13 +84,9 @@
 
 @view_config(name='add-header-paragraph.json', context=IParagraphContainerTarget, request_type=IPyAMSLayer,
              permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
-class HeaderParagraphAJAXAddForm(AJAXAddForm, HeaderParagraphAddForm):
+class HeaderParagraphAJAXAddForm(BaseParagraphAJAXAddForm, HeaderParagraphAddForm):
     """Header paragraph add form, JSON renderer"""
 
-    def get_ajax_output(self, changes):
-        return {'status': 'reload',
-                'location': '#paragraphs.html'}
-
 
 @pagelet_config(name='properties.html', context=IHeaderParagraph, layer=IPyAMSLayer,
                 permission=MANAGE_CONTENT_PERMISSION)
--- a/src/pyams_content/component/paragraph/zmi/html.py	Tue Sep 12 16:42:36 2017 +0200
+++ b/src/pyams_content/component/paragraph/zmi/html.py	Tue Sep 12 16:45:45 2017 +0200
@@ -34,9 +34,8 @@
 # import packages
 from pyams_content.component.association.zmi import AssociationsTable
 from pyams_content.component.paragraph.html import HTMLParagraph
-from pyams_content.component.paragraph.zmi import BaseParagraphAJAXEditForm
+from pyams_content.component.paragraph.zmi import BaseParagraphAJAXAddForm, BaseParagraphAJAXEditForm
 from pyams_content.component.paragraph.zmi.container import ParagraphContainerView
-from pyams_form.form import AJAXAddForm
 from pyams_form.security import ProtectedFormObjectMixin
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_skin.viewlet.toolbar import ToolbarMenuItem
@@ -97,13 +96,9 @@
 
 @view_config(name='add-html-paragraph.json', context=IParagraphContainerTarget, request_type=IPyAMSLayer,
              permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
-class HTMLParagraphAJAXAddForm(AJAXAddForm, HTMLParagraphAddForm):
+class HTMLParagraphAJAXAddForm(BaseParagraphAJAXAddForm, HTMLParagraphAddForm):
     """HTML paragraph add form, JSON renderer"""
 
-    def get_ajax_output(self, changes):
-        return {'status': 'reload',
-                'location': '#paragraphs.html'}
-
 
 @pagelet_config(name='properties.html', context=IHTMLParagraph, layer=IPyAMSLayer,
                 permission=MANAGE_CONTENT_PERMISSION)