From fe0520ee38f89a5ef390f4ff480fa70a09cc73a6 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Tue, 30 May 2017 11:46:32 +0200 Subject: [PATCH 01/20] Fix Plone 4.3 with p.a.widgets 1.x edit modals see issue #719 --- .../cover/browser/templates/tile.pt | 2 +- src/collective/cover/configure.zcml | 5 ++ src/collective/cover/static/js/compose.js | 25 ++-------- src/collective/cover/widgets/richtext.py | 50 +++++++++++++++++++ 4 files changed, 60 insertions(+), 22 deletions(-) create mode 100644 src/collective/cover/widgets/richtext.py diff --git a/src/collective/cover/browser/templates/tile.pt b/src/collective/cover/browser/templates/tile.pt index 19815d567..41683f2ad 100644 --- a/src/collective/cover/browser/templates/tile.pt +++ b/src/collective/cover/browser/templates/tile.pt @@ -58,7 +58,7 @@ Edit diff --git a/src/collective/cover/configure.zcml b/src/collective/cover/configure.zcml index 453687a16..f9a983a8f 100644 --- a/src/collective/cover/configure.zcml +++ b/src/collective/cover/configure.zcml @@ -5,6 +5,7 @@ xmlns:genericsetup="http://namespaces.zope.org/genericsetup" xmlns:i18n="http://namespaces.zope.org/i18n" xmlns:plone="http://namespaces.plone.org/plone" + xmlns:zcml="http://namespaces.zope.org/zcml" i18n_domain="collective.cover"> @@ -43,6 +44,10 @@ /> + + + + diff --git a/src/collective/cover/static/js/compose.js b/src/collective/cover/static/js/compose.js index b89340845..50ca41285 100644 --- a/src/collective/cover/static/js/compose.js +++ b/src/collective/cover/static/js/compose.js @@ -96,7 +96,9 @@ $(document).ready(function() { TitleMarkupSetup(); - if ($.fn.prepOverlay !== undefined) { + // if mockup is installed let pat-plone-modal do its job + // XXX: the check for require === 'undefined' should probably be more explicit + if ($.fn.prepOverlay !== undefined && typeof require === 'undefined') { $('a.edit-tile-link').prepOverlay({ subtype: 'ajax', filter: '.tile-content', @@ -140,26 +142,7 @@ $(document).ready(function() { }, config: { onLoad: function() { - // With plone.app.widgets and Plone 4.3 - if (typeof require !== 'undefined' && require.defined('pat-registry')) { - // Remove old editors references to work with ajax - if (typeof tinyMCE !== 'undefined' && tinyMCE !== null) { - if (tinyMCE.EditorManager != null) { - tinyMCE.EditorManager.editors = []; - } - } - // Add tinymce - $('.overlay textarea.mce_editable').addClass('pat-tinymce'); - require('pat-registry').scan($('.overlay'), ['tinymce']); - // Wire save buttom to save tinymce - $( '.overlay input#buttons-save').on('click', function() { - tinyMCE.triggerSave(); - }); - // Hack to make overlay work over overlay - $('.overlay').on('mouseover', function() { - $('div.plone-modal-wrapper').css('z-index', '10050'); - }); - } else if (typeof initTinyMCE !== 'undefined') { // Plone 4.3 + if (typeof initTinyMCE !== 'undefined') { // Plone 4.3 // Remove old editors references to work with ajax if (typeof tinyMCE !== 'undefined' && tinyMCE !== null) { if (tinyMCE.EditorManager != null) { diff --git a/src/collective/cover/widgets/richtext.py b/src/collective/cover/widgets/richtext.py new file mode 100644 index 000000000..b64a1387e --- /dev/null +++ b/src/collective/cover/widgets/richtext.py @@ -0,0 +1,50 @@ +import pkg_resources + +try: + pkg_resources.get_distribution('plone.app.widgets') +except pkg_resources.DistributionNotFound: + pass +else: + from Acquisition import aq_parent + from Products.CMFCore.utils import getToolByName + from collective.cover.tiles.richtext import IRichTextTile + from plone.app.widgets.base import dict_merge + from plone.app.widgets.dx import RichTextWidget + from plone.app.widgets.utils import get_tinymce_options + from z3c.form.interfaces import IFieldWidget, IFormLayer + from z3c.form.util import getSpecification + from z3c.form.widget import FieldWidget + from zope.component import adapter + from zope.interface import implementer + + + class TileRichTextWidget(RichTextWidget): + """ """ + + def _base_args(self): + args = { + 'pattern': self.pattern, + 'pattern_options': self.pattern_options.copy(), + } + context = aq_parent(self.wrapped_context()) + args['name'] = self.name + properties = getToolByName(context, 'portal_properties') + charset = properties.site_properties.getProperty( + 'default_charset', 'utf-8') + value = self.value and self.value.raw_encoded or '' + args['value'] = (self.request.get( + self.field.getName(), value)).decode(charset) + + args.setdefault('pattern_options', {}) + merged = dict_merge( + get_tinymce_options(context, self.field, self.request), + args['pattern_options']) + args['pattern_options'] = merged + + return args + + + @adapter(getSpecification(IRichTextTile['text']), IFormLayer) + @implementer(IFieldWidget) + def TileRichTextFieldWidget(field, request): + return FieldWidget(field, TileRichTextWidget(request)) From 22010e5a4bc927621c926e890f8bc827b3a79c4c Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Tue, 30 May 2017 11:55:48 +0200 Subject: [PATCH 02/20] update CHANGES.rst --- CHANGES.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 05469f5a1..0c28fb47c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,6 +11,10 @@ There's a frood who really knows where his towel is. You should explicitly add plone.app.drafts to the `eggs` part of your buildout configuration to avoid issues. You can safely unistall plone.app.drafts after that, if you are not using it. +- Fix Plone 4.3 width plone.app.widgets 1.x installed. The tile-edit forms are now opened + with .pat-plone-modal (fixes `#719`_) + [petschki] + - Update recommended versions of Blocks dependencies to keep in sync with curren Mosaic development. [hvelarde] @@ -191,3 +195,4 @@ Previous entries can be found in the HISTORY.rst file. .. _`#651`: https://github.com/collective/collective.cover/issues/651 .. _`#686`: https://github.com/collective/collective.cover/issues/686 .. _`#710`: https://github.com/collective/collective.cover/issues/710 +.. _`#719`: https://github.com/collective/collective.cover/issues/719 From fced3291f56a2d5a847dd1caa8a12f5d826bc210 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Tue, 30 May 2017 11:46:32 +0200 Subject: [PATCH 03/20] Fix Plone 4.3 with p.a.widgets 1.x edit modals see issue #719 --- CHANGES.rst | 5 ++ .../cover/browser/templates/tile.pt | 2 +- src/collective/cover/configure.zcml | 5 ++ src/collective/cover/static/js/compose.js | 25 ++-------- src/collective/cover/widgets/richtext.py | 50 +++++++++++++++++++ 5 files changed, 65 insertions(+), 22 deletions(-) create mode 100644 src/collective/cover/widgets/richtext.py diff --git a/CHANGES.rst b/CHANGES.rst index 05469f5a1..bfa76d0f4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,6 +11,10 @@ There's a frood who really knows where his towel is. You should explicitly add plone.app.drafts to the `eggs` part of your buildout configuration to avoid issues. You can safely unistall plone.app.drafts after that, if you are not using it. +- Fix Plone 4.3 with plone.app.widgets 1.x installed. The tile-edit forms are now opened + with .pat-plone-modal (fixes `#719`_) + [petschki] + - Update recommended versions of Blocks dependencies to keep in sync with curren Mosaic development. [hvelarde] @@ -191,3 +195,4 @@ Previous entries can be found in the HISTORY.rst file. .. _`#651`: https://github.com/collective/collective.cover/issues/651 .. _`#686`: https://github.com/collective/collective.cover/issues/686 .. _`#710`: https://github.com/collective/collective.cover/issues/710 +.. _`#719`: https://github.com/collective/collective.cover/issues/719 diff --git a/src/collective/cover/browser/templates/tile.pt b/src/collective/cover/browser/templates/tile.pt index 19815d567..41683f2ad 100644 --- a/src/collective/cover/browser/templates/tile.pt +++ b/src/collective/cover/browser/templates/tile.pt @@ -58,7 +58,7 @@ Edit diff --git a/src/collective/cover/configure.zcml b/src/collective/cover/configure.zcml index 453687a16..f9a983a8f 100644 --- a/src/collective/cover/configure.zcml +++ b/src/collective/cover/configure.zcml @@ -5,6 +5,7 @@ xmlns:genericsetup="http://namespaces.zope.org/genericsetup" xmlns:i18n="http://namespaces.zope.org/i18n" xmlns:plone="http://namespaces.plone.org/plone" + xmlns:zcml="http://namespaces.zope.org/zcml" i18n_domain="collective.cover"> @@ -43,6 +44,10 @@ /> + + + + diff --git a/src/collective/cover/static/js/compose.js b/src/collective/cover/static/js/compose.js index b89340845..50ca41285 100644 --- a/src/collective/cover/static/js/compose.js +++ b/src/collective/cover/static/js/compose.js @@ -96,7 +96,9 @@ $(document).ready(function() { TitleMarkupSetup(); - if ($.fn.prepOverlay !== undefined) { + // if mockup is installed let pat-plone-modal do its job + // XXX: the check for require === 'undefined' should probably be more explicit + if ($.fn.prepOverlay !== undefined && typeof require === 'undefined') { $('a.edit-tile-link').prepOverlay({ subtype: 'ajax', filter: '.tile-content', @@ -140,26 +142,7 @@ $(document).ready(function() { }, config: { onLoad: function() { - // With plone.app.widgets and Plone 4.3 - if (typeof require !== 'undefined' && require.defined('pat-registry')) { - // Remove old editors references to work with ajax - if (typeof tinyMCE !== 'undefined' && tinyMCE !== null) { - if (tinyMCE.EditorManager != null) { - tinyMCE.EditorManager.editors = []; - } - } - // Add tinymce - $('.overlay textarea.mce_editable').addClass('pat-tinymce'); - require('pat-registry').scan($('.overlay'), ['tinymce']); - // Wire save buttom to save tinymce - $( '.overlay input#buttons-save').on('click', function() { - tinyMCE.triggerSave(); - }); - // Hack to make overlay work over overlay - $('.overlay').on('mouseover', function() { - $('div.plone-modal-wrapper').css('z-index', '10050'); - }); - } else if (typeof initTinyMCE !== 'undefined') { // Plone 4.3 + if (typeof initTinyMCE !== 'undefined') { // Plone 4.3 // Remove old editors references to work with ajax if (typeof tinyMCE !== 'undefined' && tinyMCE !== null) { if (tinyMCE.EditorManager != null) { diff --git a/src/collective/cover/widgets/richtext.py b/src/collective/cover/widgets/richtext.py new file mode 100644 index 000000000..b64a1387e --- /dev/null +++ b/src/collective/cover/widgets/richtext.py @@ -0,0 +1,50 @@ +import pkg_resources + +try: + pkg_resources.get_distribution('plone.app.widgets') +except pkg_resources.DistributionNotFound: + pass +else: + from Acquisition import aq_parent + from Products.CMFCore.utils import getToolByName + from collective.cover.tiles.richtext import IRichTextTile + from plone.app.widgets.base import dict_merge + from plone.app.widgets.dx import RichTextWidget + from plone.app.widgets.utils import get_tinymce_options + from z3c.form.interfaces import IFieldWidget, IFormLayer + from z3c.form.util import getSpecification + from z3c.form.widget import FieldWidget + from zope.component import adapter + from zope.interface import implementer + + + class TileRichTextWidget(RichTextWidget): + """ """ + + def _base_args(self): + args = { + 'pattern': self.pattern, + 'pattern_options': self.pattern_options.copy(), + } + context = aq_parent(self.wrapped_context()) + args['name'] = self.name + properties = getToolByName(context, 'portal_properties') + charset = properties.site_properties.getProperty( + 'default_charset', 'utf-8') + value = self.value and self.value.raw_encoded or '' + args['value'] = (self.request.get( + self.field.getName(), value)).decode(charset) + + args.setdefault('pattern_options', {}) + merged = dict_merge( + get_tinymce_options(context, self.field, self.request), + args['pattern_options']) + args['pattern_options'] = merged + + return args + + + @adapter(getSpecification(IRichTextTile['text']), IFormLayer) + @implementer(IFieldWidget) + def TileRichTextFieldWidget(field, request): + return FieldWidget(field, TileRichTextWidget(request)) From b34755b3888cafd341d159768f7d6297ecbfb846 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Tue, 30 May 2017 15:00:50 +0200 Subject: [PATCH 04/20] add upgrade step (cook JS resources) and remove unused import check --- src/collective/cover/profiles.zcml | 12 +++ .../cover/profiles/default/metadata.xml | 2 +- src/collective/cover/widgets/richtext.py | 93 +++++++++---------- 3 files changed, 56 insertions(+), 51 deletions(-) diff --git a/src/collective/cover/profiles.zcml b/src/collective/cover/profiles.zcml index d5aaf833f..f3aa0b313 100644 --- a/src/collective/cover/profiles.zcml +++ b/src/collective/cover/profiles.zcml @@ -126,4 +126,16 @@ + + + + + diff --git a/src/collective/cover/profiles/default/metadata.xml b/src/collective/cover/profiles/default/metadata.xml index c5a16dcf5..d7be9f7bc 100644 --- a/src/collective/cover/profiles/default/metadata.xml +++ b/src/collective/cover/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 16 + 17 profile-collective.js.galleria:default profile-collective.js.jqueryui:default diff --git a/src/collective/cover/widgets/richtext.py b/src/collective/cover/widgets/richtext.py index b64a1387e..315311599 100644 --- a/src/collective/cover/widgets/richtext.py +++ b/src/collective/cover/widgets/richtext.py @@ -1,50 +1,43 @@ -import pkg_resources - -try: - pkg_resources.get_distribution('plone.app.widgets') -except pkg_resources.DistributionNotFound: - pass -else: - from Acquisition import aq_parent - from Products.CMFCore.utils import getToolByName - from collective.cover.tiles.richtext import IRichTextTile - from plone.app.widgets.base import dict_merge - from plone.app.widgets.dx import RichTextWidget - from plone.app.widgets.utils import get_tinymce_options - from z3c.form.interfaces import IFieldWidget, IFormLayer - from z3c.form.util import getSpecification - from z3c.form.widget import FieldWidget - from zope.component import adapter - from zope.interface import implementer - - - class TileRichTextWidget(RichTextWidget): - """ """ - - def _base_args(self): - args = { - 'pattern': self.pattern, - 'pattern_options': self.pattern_options.copy(), - } - context = aq_parent(self.wrapped_context()) - args['name'] = self.name - properties = getToolByName(context, 'portal_properties') - charset = properties.site_properties.getProperty( - 'default_charset', 'utf-8') - value = self.value and self.value.raw_encoded or '' - args['value'] = (self.request.get( - self.field.getName(), value)).decode(charset) - - args.setdefault('pattern_options', {}) - merged = dict_merge( - get_tinymce_options(context, self.field, self.request), - args['pattern_options']) - args['pattern_options'] = merged - - return args - - - @adapter(getSpecification(IRichTextTile['text']), IFormLayer) - @implementer(IFieldWidget) - def TileRichTextFieldWidget(field, request): - return FieldWidget(field, TileRichTextWidget(request)) +from Acquisition import aq_parent +from Products.CMFCore.utils import getToolByName +from collective.cover.tiles.richtext import IRichTextTile +from plone.app.widgets.base import dict_merge +from plone.app.widgets.dx import RichTextWidget +from plone.app.widgets.utils import get_tinymce_options +from z3c.form.interfaces import IFieldWidget, IFormLayer +from z3c.form.util import getSpecification +from z3c.form.widget import FieldWidget +from zope.component import adapter +from zope.interface import implementer + + +class TileRichTextWidget(RichTextWidget): + """ """ + + def _base_args(self): + args = { + 'pattern': self.pattern, + 'pattern_options': self.pattern_options.copy(), + } + context = aq_parent(self.wrapped_context()) + args['name'] = self.name + properties = getToolByName(context, 'portal_properties') + charset = properties.site_properties.getProperty( + 'default_charset', 'utf-8') + value = self.value and self.value.raw_encoded or '' + args['value'] = (self.request.get( + self.field.getName(), value)).decode(charset) + + args.setdefault('pattern_options', {}) + merged = dict_merge( + get_tinymce_options(context, self.field, self.request), + args['pattern_options']) + args['pattern_options'] = merged + + return args + + +@adapter(getSpecification(IRichTextTile['text']), IFormLayer) +@implementer(IFieldWidget) +def TileRichTextFieldWidget(field, request): + return FieldWidget(field, TileRichTextWidget(request)) From a57a70ff4cd0f4fba48553ef8c4fd99d3ea2bd5a Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Tue, 30 May 2017 15:07:32 +0200 Subject: [PATCH 05/20] pep8 --- src/collective/cover/widgets/richtext.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/collective/cover/widgets/richtext.py b/src/collective/cover/widgets/richtext.py index 315311599..999d644e1 100644 --- a/src/collective/cover/widgets/richtext.py +++ b/src/collective/cover/widgets/richtext.py @@ -1,10 +1,13 @@ +# -*- coding: utf-8 -*- + from Acquisition import aq_parent from Products.CMFCore.utils import getToolByName from collective.cover.tiles.richtext import IRichTextTile from plone.app.widgets.base import dict_merge from plone.app.widgets.dx import RichTextWidget from plone.app.widgets.utils import get_tinymce_options -from z3c.form.interfaces import IFieldWidget, IFormLayer +from z3c.form.interfaces import IFieldWidget +from z3c.form.interfaces import IFormLayer from z3c.form.util import getSpecification from z3c.form.widget import FieldWidget from zope.component import adapter From 67258bf457c16e96731ed40816e6464f08395563 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Tue, 30 May 2017 15:57:01 +0200 Subject: [PATCH 06/20] add tests for Phone 4.3 + p.a.widgets 1.x and make flake8 happy --- .travis.yml | 8 +++++--- src/collective/cover/configure.zcml | 6 ++++-- src/collective/cover/testing.py | 16 ++++++++++++++++ src/collective/cover/widgets/richtext.py | 2 +- versions-4.3.x.cfg | 3 +++ 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 25b5953d6..f745578f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ env: - PLONE_VERSION=4.2 - PLONE_VERSION=4.3 - PLONE_VERSION=4.3 DEXTERITY_ONLY=true + - PLONE_VERSION=4.3 PLONE_WIDGETS=true - PLONE_VERSION=4.3 JQUERY=1.9.1.3 - PLONE_VERSION=5.0 - PLONE_VERSION=5.1 @@ -57,6 +58,7 @@ notifications: - "Robot Test Report for Plone 4.2: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.1/parts/test/robot_log.html" - "Robot Test Report for Plone 4.3: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.2/parts/test/robot_log.html" - "Robot Test Report for plone.app.contenttypes: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.3/parts/test/robot_log.html" - - "Robot Test Report for jQuery 1.9: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.4/parts/test/robot_log.html" - - "Robot Test Report for Plone 5.0: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.5/parts/test/robot_log.html" - - "Robot Test Report for Plone 5.1: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.6/parts/test/robot_log.html" + - "Robot Test Report for plone.app.widgets: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.4/parts/test/robot_log.html" + - "Robot Test Report for jQuery 1.9: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.5/parts/test/robot_log.html" + - "Robot Test Report for Plone 5.0: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.6/parts/test/robot_log.html" + - "Robot Test Report for Plone 5.1: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.7/parts/test/robot_log.html" diff --git a/src/collective/cover/configure.zcml b/src/collective/cover/configure.zcml index f9a983a8f..317dc537b 100644 --- a/src/collective/cover/configure.zcml +++ b/src/collective/cover/configure.zcml @@ -44,8 +44,10 @@ /> - - + + + + diff --git a/src/collective/cover/testing.py b/src/collective/cover/testing.py index 57e9d8943..fd36c7562 100644 --- a/src/collective/cover/testing.py +++ b/src/collective/cover/testing.py @@ -34,6 +34,14 @@ # this environment variable is set in .travis.yml test matrix DEXTERITY_ONLY = os.environ.get('DEXTERITY_ONLY') is not None +try: + pkg_resources.get_distribution('plone.app.widgets') +except pkg_resources.DistributionNotFound: + PLONE_WIDGETS = False +else: + # this environment variable is set in .travis.yml test matrix + PLONE_WIDGETS = os.environ.get('PLONE_WIDGETS') is not None + try: pkg_resources.get_distribution('Products.PloneFormGen') except pkg_resources.DistributionNotFound: @@ -138,6 +146,11 @@ def setUpZope(self, app, configurationContext): self.loadZCML(package=Products.PloneFormGen) z2.installProduct(app, 'Products.PloneFormGen') + if PLONE_WIDGETS: + import plone.app.widgets + self.loadZCML(package=plone.app.widgets) + z2.installProduct(app, 'plone.app.widgets') + import collective.cover self.loadZCML(package=collective.cover) @@ -158,6 +171,9 @@ def setUpPloneSite(self, portal): if HAS_PFG: self.applyProfile(portal, 'Products.PloneFormGen:default') + if PLONE_WIDGETS: + self.applyProfile(portal, 'plone.app.widgets:default') + self.applyProfile(portal, 'collective.cover:default') self.applyProfile(portal, 'collective.cover:testfixture') diff --git a/src/collective/cover/widgets/richtext.py b/src/collective/cover/widgets/richtext.py index 999d644e1..7218327c4 100644 --- a/src/collective/cover/widgets/richtext.py +++ b/src/collective/cover/widgets/richtext.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- from Acquisition import aq_parent -from Products.CMFCore.utils import getToolByName from collective.cover.tiles.richtext import IRichTextTile from plone.app.widgets.base import dict_merge from plone.app.widgets.dx import RichTextWidget from plone.app.widgets.utils import get_tinymce_options +from Products.CMFCore.utils import getToolByName from z3c.form.interfaces import IFieldWidget from z3c.form.interfaces import IFormLayer from z3c.form.util import getSpecification diff --git a/versions-4.3.x.cfg b/versions-4.3.x.cfg index 951edd9c8..6c483582a 100644 --- a/versions-4.3.x.cfg +++ b/versions-4.3.x.cfg @@ -12,6 +12,7 @@ find-links = test-eggs = plone.app.contenttypes plone.app.referenceablebehavior + plone.app.widgets [versions] collective.js.bootstrap = 2.3.1.1 @@ -27,3 +28,5 @@ plone.app.jquery = 1.7.2 # XXX: https://github.com/plone/plone.api/issues/364 plone.api = 1.6 + +plone.app.widgets = 1.9.1 From 6600a398d636e73a9aa41061a866cdd6cafda318 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Tue, 30 May 2017 17:00:34 +0200 Subject: [PATCH 07/20] remove tests for p.a.widgets I'll do it in a separate pull request ... --- .travis.yml | 8 +++----- src/collective/cover/testing.py | 16 ---------------- src/collective/cover/widgets/richtext.py | 7 ++++++- versions-4.3.x.cfg | 2 -- 4 files changed, 9 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index f745578f0..25b5953d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ env: - PLONE_VERSION=4.2 - PLONE_VERSION=4.3 - PLONE_VERSION=4.3 DEXTERITY_ONLY=true - - PLONE_VERSION=4.3 PLONE_WIDGETS=true - PLONE_VERSION=4.3 JQUERY=1.9.1.3 - PLONE_VERSION=5.0 - PLONE_VERSION=5.1 @@ -58,7 +57,6 @@ notifications: - "Robot Test Report for Plone 4.2: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.1/parts/test/robot_log.html" - "Robot Test Report for Plone 4.3: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.2/parts/test/robot_log.html" - "Robot Test Report for plone.app.contenttypes: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.3/parts/test/robot_log.html" - - "Robot Test Report for plone.app.widgets: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.4/parts/test/robot_log.html" - - "Robot Test Report for jQuery 1.9: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.5/parts/test/robot_log.html" - - "Robot Test Report for Plone 5.0: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.6/parts/test/robot_log.html" - - "Robot Test Report for Plone 5.1: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.7/parts/test/robot_log.html" + - "Robot Test Report for jQuery 1.9: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.4/parts/test/robot_log.html" + - "Robot Test Report for Plone 5.0: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.5/parts/test/robot_log.html" + - "Robot Test Report for Plone 5.1: http://s3-sa-east-1.amazonaws.com/collective-cover/collective/collective.cover/%{build_number}/%{build_number}.6/parts/test/robot_log.html" diff --git a/src/collective/cover/testing.py b/src/collective/cover/testing.py index fd36c7562..57e9d8943 100644 --- a/src/collective/cover/testing.py +++ b/src/collective/cover/testing.py @@ -34,14 +34,6 @@ # this environment variable is set in .travis.yml test matrix DEXTERITY_ONLY = os.environ.get('DEXTERITY_ONLY') is not None -try: - pkg_resources.get_distribution('plone.app.widgets') -except pkg_resources.DistributionNotFound: - PLONE_WIDGETS = False -else: - # this environment variable is set in .travis.yml test matrix - PLONE_WIDGETS = os.environ.get('PLONE_WIDGETS') is not None - try: pkg_resources.get_distribution('Products.PloneFormGen') except pkg_resources.DistributionNotFound: @@ -146,11 +138,6 @@ def setUpZope(self, app, configurationContext): self.loadZCML(package=Products.PloneFormGen) z2.installProduct(app, 'Products.PloneFormGen') - if PLONE_WIDGETS: - import plone.app.widgets - self.loadZCML(package=plone.app.widgets) - z2.installProduct(app, 'plone.app.widgets') - import collective.cover self.loadZCML(package=collective.cover) @@ -171,9 +158,6 @@ def setUpPloneSite(self, portal): if HAS_PFG: self.applyProfile(portal, 'Products.PloneFormGen:default') - if PLONE_WIDGETS: - self.applyProfile(portal, 'plone.app.widgets:default') - self.applyProfile(portal, 'collective.cover:default') self.applyProfile(portal, 'collective.cover:testfixture') diff --git a/src/collective/cover/widgets/richtext.py b/src/collective/cover/widgets/richtext.py index 7218327c4..aea5b135d 100644 --- a/src/collective/cover/widgets/richtext.py +++ b/src/collective/cover/widgets/richtext.py @@ -15,7 +15,12 @@ class TileRichTextWidget(RichTextWidget): - """ """ + """ fix plone.app.widgets.dx.RichTextWidget for @@edit-tile view. + We have to get the parent of self.wrapped_context to render the + tinymce_options correctly.tinymce_options + XXX: this code should go to plone.app.widgets instead + see https://github.com/plone/plone.app.widgets/issues/161 + """ def _base_args(self): args = { diff --git a/versions-4.3.x.cfg b/versions-4.3.x.cfg index 6c483582a..a830ed1e5 100644 --- a/versions-4.3.x.cfg +++ b/versions-4.3.x.cfg @@ -28,5 +28,3 @@ plone.app.jquery = 1.7.2 # XXX: https://github.com/plone/plone.api/issues/364 plone.api = 1.6 - -plone.app.widgets = 1.9.1 From a56519a7c8e1e3b1a5685cfaddcc1ac1dcc14fa5 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Wed, 31 May 2017 11:03:09 +0200 Subject: [PATCH 08/20] remove p.a.widgets test-egg --- versions-4.3.x.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/versions-4.3.x.cfg b/versions-4.3.x.cfg index a830ed1e5..951edd9c8 100644 --- a/versions-4.3.x.cfg +++ b/versions-4.3.x.cfg @@ -12,7 +12,6 @@ find-links = test-eggs = plone.app.contenttypes plone.app.referenceablebehavior - plone.app.widgets [versions] collective.js.bootstrap = 2.3.1.1 From 1d814c4de8c0f2da7d5391b37425811e9bad9453 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Fri, 23 Jun 2017 08:44:10 +0200 Subject: [PATCH 09/20] fix HTML markup for modal --- .../cover/tiles/templates/tileformlayout.pt | 12 ++++++++---- .../tiles/templates/tilesconfigurationlayout.pt | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/collective/cover/tiles/templates/tileformlayout.pt b/src/collective/cover/tiles/templates/tileformlayout.pt index c2f823630..eb683db3b 100644 --- a/src/collective/cover/tiles/templates/tileformlayout.pt +++ b/src/collective/cover/tiles/templates/tileformlayout.pt @@ -1,5 +1,9 @@ -
-

+ + +
+

Title

- -
+ +

+ + diff --git a/src/collective/cover/tiles/templates/tilesconfigurationlayout.pt b/src/collective/cover/tiles/templates/tilesconfigurationlayout.pt index 605d14ba6..40a617a78 100644 --- a/src/collective/cover/tiles/templates/tilesconfigurationlayout.pt +++ b/src/collective/cover/tiles/templates/tilesconfigurationlayout.pt @@ -1,5 +1,9 @@ + +

+ + From 5670fcf6616ba066a0cc35c4e2152484f990f47f Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Tue, 27 Jun 2017 17:07:26 +0200 Subject: [PATCH 10/20] pin zc.buildout and setuptools for test --- .travis.yml | 4 ++-- versions-4.3.x-widgets.cfg | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4654a7830..d4f9adb6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ env: - PLONE_VERSION=4.3 - PLONE_VERSION=4.3 DEXTERITY_ONLY=true - PLONE_VERSION=4.3 VERSIONS=versions:plone.app.jquery=1.9.2 - - PLONE_VERSION=4.3 WIDGETS=true + - PLONE_VERSION=4.3 WIDGETS=true BOOTSTRAP_PARAMS="--buildout-version=1.7.1 --setuptools-version=20.1.1" - PLONE_VERSION=5.0 - PLONE_VERSION=5.1 matrix: @@ -29,7 +29,7 @@ install: - sed -ie "s#test-4.3#test-$PLONE_VERSION#" buildout.cfg - sed -ie "s#versions-4.3#versions-$PLONE_VERSION#" buildout.cfg - test $WIDGETS && sed -ie "s#versions-4.3.x.cfg#versions-4.3.x-widgets.cfg#" buildout.cfg || true -- python bootstrap.py +- python bootstrap.py $BOOTSTRAP_PARAMS - bin/buildout $VERSIONS annotate - bin/buildout $VERSIONS before_script: diff --git a/versions-4.3.x-widgets.cfg b/versions-4.3.x-widgets.cfg index a8e9bffdd..862132a8d 100644 --- a/versions-4.3.x-widgets.cfg +++ b/versions-4.3.x-widgets.cfg @@ -16,5 +16,6 @@ auto-checkout = * plone.app.widgets = git https://github.com/plone/plone.app.widgets.git branch=1.x [versions] -plone.app.widgets = plone.app.z3cform = 1.0.1 +setuptools = 20.1.1 +zc.buildout = 1.7.1 From 8fa03401fc523095dd66d6c44028b0d2ef62a37d Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Tue, 27 Jun 2017 18:17:21 +0200 Subject: [PATCH 11/20] cleanup richtext widget --- .travis.yml | 2 +- src/collective/cover/widgets/richtext.py | 37 +----------------------- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index d4f9adb6f..d54869445 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ env: matrix: fast_finish: true allow_failures: - - env: PLONE_VERSION=4.3 WIDGETS=true + - env: PLONE_VERSION=4.3 WIDGETS=true BOOTSTRAP_PARAMS="--buildout-version=1.7.1 --setuptools-version=20.1.1" install: - sed -ie "s#test-4.3#test-$PLONE_VERSION#" buildout.cfg - sed -ie "s#versions-4.3#versions-$PLONE_VERSION#" buildout.cfg diff --git a/src/collective/cover/widgets/richtext.py b/src/collective/cover/widgets/richtext.py index aea5b135d..3186a29ca 100644 --- a/src/collective/cover/widgets/richtext.py +++ b/src/collective/cover/widgets/richtext.py @@ -1,11 +1,7 @@ # -*- coding: utf-8 -*- -from Acquisition import aq_parent from collective.cover.tiles.richtext import IRichTextTile -from plone.app.widgets.base import dict_merge from plone.app.widgets.dx import RichTextWidget -from plone.app.widgets.utils import get_tinymce_options -from Products.CMFCore.utils import getToolByName from z3c.form.interfaces import IFieldWidget from z3c.form.interfaces import IFormLayer from z3c.form.util import getSpecification @@ -14,38 +10,7 @@ from zope.interface import implementer -class TileRichTextWidget(RichTextWidget): - """ fix plone.app.widgets.dx.RichTextWidget for @@edit-tile view. - We have to get the parent of self.wrapped_context to render the - tinymce_options correctly.tinymce_options - XXX: this code should go to plone.app.widgets instead - see https://github.com/plone/plone.app.widgets/issues/161 - """ - - def _base_args(self): - args = { - 'pattern': self.pattern, - 'pattern_options': self.pattern_options.copy(), - } - context = aq_parent(self.wrapped_context()) - args['name'] = self.name - properties = getToolByName(context, 'portal_properties') - charset = properties.site_properties.getProperty( - 'default_charset', 'utf-8') - value = self.value and self.value.raw_encoded or '' - args['value'] = (self.request.get( - self.field.getName(), value)).decode(charset) - - args.setdefault('pattern_options', {}) - merged = dict_merge( - get_tinymce_options(context, self.field, self.request), - args['pattern_options']) - args['pattern_options'] = merged - - return args - - @adapter(getSpecification(IRichTextTile['text']), IFormLayer) @implementer(IFieldWidget) def TileRichTextFieldWidget(field, request): - return FieldWidget(field, TileRichTextWidget(request)) + return FieldWidget(field, RichTextWidget(request)) From 4b8b30834e7b1c1d371eff7036da4969f6b2e33b Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Thu, 29 Jun 2017 15:56:42 +0200 Subject: [PATCH 12/20] fix JS check for plone.app.widgets --- buildout.cfg | 2 +- src/collective/cover/static/js/compose.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/buildout.cfg b/buildout.cfg index 1e0dc2dd0..625902c0e 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -2,7 +2,7 @@ extends = https://raw.github.com/collective/buildout.plonetest/master/test-4.3.x.cfg https://raw.github.com/collective/buildout.plonetest/master/qa.cfg - versions-4.3.x.cfg + versions-4.3.x-widgets.cfg package-name = collective.cover package-extras = [test] diff --git a/src/collective/cover/static/js/compose.js b/src/collective/cover/static/js/compose.js index 100812385..b85474780 100644 --- a/src/collective/cover/static/js/compose.js +++ b/src/collective/cover/static/js/compose.js @@ -96,9 +96,8 @@ $(document).ready(function() { TitleMarkupSetup(); - // if mockup is installed let pat-plone-modal do its job - // XXX: the check for require === 'undefined' should probably be more explicit - if ($.fn.prepOverlay !== undefined && typeof require === 'undefined') { + // if plone.app.widgets is installed let them do their job + if (!$("body").hasClass('pat-plone-widgets')) { $('a.edit-tile-link').prepOverlay({ subtype: 'ajax', filter: '.tile-content', From aa05c0412bebf6d8bff49296d7b31169d4557040 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Thu, 29 Jun 2017 15:57:17 +0200 Subject: [PATCH 13/20] fix buildout --- buildout.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildout.cfg b/buildout.cfg index 625902c0e..1e0dc2dd0 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -2,7 +2,7 @@ extends = https://raw.github.com/collective/buildout.plonetest/master/test-4.3.x.cfg https://raw.github.com/collective/buildout.plonetest/master/qa.cfg - versions-4.3.x-widgets.cfg + versions-4.3.x.cfg package-name = collective.cover package-extras = [test] From e0f067f31d67c16c235e7bc7aad87c9463156645 Mon Sep 17 00:00:00 2001 From: Peter Mathis Date: Fri, 30 Jun 2017 11:52:01 +0200 Subject: [PATCH 14/20] fix conflicting bootstrap classes twitter bootstrap sets its .hide class to `display:none !important` so we do not get any configure modal at all when assigning hide class in templates ... use the strategy to set `.modal { display:none }` like bootstrap does... --- src/collective/cover/browser/templates/groupselect.pt | 2 +- src/collective/cover/browser/templates/layoutedit.pt | 6 +++--- src/collective/cover/browser/templates/tileselect.pt | 4 ++-- src/collective/cover/static/css/cover.css | 8 ++++++++ src/collective/cover/static/css/layout_edit.css | 5 +---- versions-4.3.x-widgets.cfg | 2 ++ 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/collective/cover/browser/templates/groupselect.pt b/src/collective/cover/browser/templates/groupselect.pt index 126d02289..455f25c2e 100644 --- a/src/collective/cover/browser/templates/groupselect.pt +++ b/src/collective/cover/browser/templates/groupselect.pt @@ -7,7 +7,7 @@ tal:omit-tag=""> - - - -