From c882035f9b57e9dbda572031c4889ec2a691dc30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Grabowski?= Date: Tue, 14 Apr 2020 12:49:49 +0200 Subject: [PATCH 1/3] EZP-29475: changed titles for udw --- .../js/alloyeditor/src/buttons/ez-btn-embed.js | 2 +- .../src/buttons/ez-btn-embedinline.js | 2 +- .../src/buttons/ez-btn-embedupdate.js | 2 +- .../js/alloyeditor/src/buttons/ez-btn-image.js | 2 +- .../src/buttons/ez-btn-imageupdate.js | 2 +- .../js/scripts/fieldType/ezobjectrelationlist.js | 5 ++++- .../Resources/translations/alloy_editor.en.xliff | 16 ++++++++-------- .../universal_discovery_widget.en.xliff | 13 +++++++++---- .../fieldtypes/edit/relation_base.html.twig | 1 + 9 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-embed.js b/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-embed.js index 5d73a8b2a0..44b0765e42 100644 --- a/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-embed.js +++ b/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-embed.js @@ -79,7 +79,7 @@ eZ.addConfig('ezAlloyEditor.ezBtnEmbed', EzBtnEmbed); EzBtnEmbed.defaultProps = { command: 'ezembed', modifiesSelection: true, - udwTitle: Translator.trans(/*@Desc("Select a content to embed")*/ 'embed_btn.udw.title', {}, 'alloy_editor'), + udwTitle: Translator.trans(/*@Desc("Select a Content item to embed")*/ 'embed_btn.udw.title', {}, 'alloy_editor'), udwContentDiscoveredMethod: 'addEmbed', udwConfigName: 'richtext_embed', }; diff --git a/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-embedinline.js b/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-embedinline.js index 33e5541c56..7093e7527b 100644 --- a/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-embedinline.js +++ b/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-embedinline.js @@ -34,7 +34,7 @@ eZ.addConfig('ezAlloyEditor.ezBtnEmbedInline', EzBtnEmbedInline); EzBtnEmbedInline.defaultProps = { command: 'ezembedinline', modifiesSelection: true, - udwTitle: Translator.trans(/*@Desc("Select a content to embed")*/ 'embed_btn.udw.title', {}, 'alloy_editor'), + udwTitle: Translator.trans(/*@Desc("Select a Content item to embed")*/ 'embed_btn.udw.title', {}, 'alloy_editor'), udwContentDiscoveredMethod: 'addEmbed', udwConfigName: 'richtext_embed', }; diff --git a/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-embedupdate.js b/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-embedupdate.js index 4b53cf50c4..e13ff9c4e1 100644 --- a/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-embedupdate.js +++ b/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-embedupdate.js @@ -50,7 +50,7 @@ AlloyEditor.Buttons[EzBtnEmbedUpdate.key] = AlloyEditor.EzBtnEmbedUpdate = EzBtn eZ.addConfig('ezAlloyEditor.ezBtnEmbedUpdate', EzBtnEmbedUpdate); EzBtnEmbedUpdate.defaultProps = { - udwTitle: Translator.trans(/*@Desc("Select a content to embed")*/ 'embed_update_btn.udw.title', {}, 'alloy_editor'), + udwTitle: Translator.trans(/*@Desc("Select a Content item to embed")*/ 'embed_update_btn.udw.title', {}, 'alloy_editor'), udwContentDiscoveredMethod: 'updateEmbed', udwConfigName: 'richtext_embed', label: Translator.trans(/*@Desc("Select another content item")*/ 'embed_update_btn.label', {}, 'alloy_editor'), diff --git a/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-image.js b/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-image.js index f09e4ca4c3..a2081ccc14 100644 --- a/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-image.js +++ b/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-image.js @@ -81,7 +81,7 @@ eZ.addConfig('ezAlloyEditor.ezBtnImage', EzBtnImage); EzBtnImage.defaultProps = { command: 'ezembed', modifiesSelection: true, - udwTitle: Translator.trans(/*@Desc("Select an image to embed")*/ 'image_btn.udw.label', {}, 'alloy_editor'), + udwTitle: Translator.trans(/*@Desc("Select an image")*/ 'image_btn.udw.label', {}, 'alloy_editor'), udwContentDiscoveredMethod: 'addImage', udwConfigName: 'richtext_embed_image', udwLoadContent: true, diff --git a/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-imageupdate.js b/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-imageupdate.js index dad1b152d8..060f9e5fc9 100644 --- a/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-imageupdate.js +++ b/src/bundle/Resources/public/js/alloyeditor/src/buttons/ez-btn-imageupdate.js @@ -51,7 +51,7 @@ AlloyEditor.Buttons[EzBtnImageUpdate.key] = AlloyEditor.EzBtnImageUpdate = EzBtn eZ.addConfig('ezAlloyEditor.ezBtnImageUpdate', EzBtnImageUpdate); EzBtnImageUpdate.defaultProps = { - udwTitle: Translator.trans(/*@Desc("Select an image to embed")*/ 'image_update_btn.udw.title', {}, 'alloy_editor'), + udwTitle: Translator.trans(/*@Desc("Select an image")*/ 'image_update_btn.udw.title', {}, 'alloy_editor'), udwContentDiscoveredMethod: 'updateImage', udwConfigName: 'richtext_embed_image', label: Translator.trans(/*@Desc("Select another image item")*/ 'image_update_btn.label', {}, 'alloy_editor'), diff --git a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js index 3d3eccbbce..03b2d3e3e9 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js @@ -121,7 +121,10 @@ event.preventDefault(); const config = JSON.parse(event.currentTarget.dataset.udwConfig); - const title = Translator.trans(/*@Desc("Select content")*/ 'ezobjectrelationlist.title', {}, 'universal_discovery_widget'); + const limit = parseInt(event.currentTarget.dataset.limit); + const title = limit === 1 + ? Translator.trans(/*@Desc("Select a Content item")*/ 'ezobjectrelationlist.title.single', {}, 'universal_discovery_widget') + : Translator.trans(/*@Desc("Select Content item(s)")*/ 'ezobjectrelationlist.title.multi', {}, 'universal_discovery_widget'); ReactDOM.render( React.createElement( diff --git a/src/bundle/Resources/translations/alloy_editor.en.xliff b/src/bundle/Resources/translations/alloy_editor.en.xliff index b7c10ca91d..805261ee93 100644 --- a/src/bundle/Resources/translations/alloy_editor.en.xliff +++ b/src/bundle/Resources/translations/alloy_editor.en.xliff @@ -87,8 +87,8 @@ key: embed_btn.label - Select a content to embed - Select a content to embed + Select a Content item to embed + Select a Content item to embed key: embed_btn.udw.title @@ -97,8 +97,8 @@ key: embed_update_btn.label - Select a content to embed - Select a content to embed + Select a Content item to embed + Select a Content item to embed key: embed_update_btn.udw.title @@ -112,8 +112,8 @@ key: image_btn.label - Select an image to embed - Select an image to embed + Select an image + Select an image key: image_btn.udw.label @@ -122,8 +122,8 @@ key: image_update_btn.label - Select an image to embed - Select an image to embed + Select an image + Select an image key: image_update_btn.udw.title diff --git a/src/bundle/Resources/translations/universal_discovery_widget.en.xliff b/src/bundle/Resources/translations/universal_discovery_widget.en.xliff index 793222af22..cb0c4b311e 100644 --- a/src/bundle/Resources/translations/universal_discovery_widget.en.xliff +++ b/src/bundle/Resources/translations/universal_discovery_widget.en.xliff @@ -31,10 +31,15 @@ Select Image Asset key: ezimageasset.title - - Select content - Select content - key: ezobjectrelationlist.title + + Select Content item(s) + Select Content item(s) + key: ezobjectrelationlist.title.multi + + + Select a Content item + Select a Content item + key: ezobjectrelationlist.title.single Failed to fetch content names diff --git a/src/bundle/Resources/views/fieldtypes/edit/relation_base.html.twig b/src/bundle/Resources/views/fieldtypes/edit/relation_base.html.twig index df6d2635f5..ae57f30c9e 100644 --- a/src/bundle/Resources/views/fieldtypes/edit/relation_base.html.twig +++ b/src/bundle/Resources/views/fieldtypes/edit/relation_base.html.twig @@ -100,6 +100,7 @@ 'allowed_content_types': allowed_content_types }) }}" {% endif %} + data-limit="{{limit}}" class="ez-relations__cta-btn btn btn-primary" type="button"> From 06e7d3ec3f2cdfcc503f29ebdf33b0d385d0db31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Grabowski?= Date: Wed, 15 Apr 2020 13:22:46 +0200 Subject: [PATCH 2/3] EZP-29475: after prettier --- .../scripts/fieldType/ezobjectrelationlist.js | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js index 03b2d3e3e9..55f03eb7b8 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js @@ -1,4 +1,4 @@ -(function(global, doc, eZ, React, ReactDOM, Translator) { +(function (global, doc, eZ, React, ReactDOM, Translator) { const CLASS_FIELD_SINGLE = 'ez-field-edit--ezobjectrelation'; const SELECTOR_FIELD_MULTIPLE = '.ez-field-edit--ezobjectrelationlist'; const SELECTOR_FIELD_SINGLE = '.ez-field-edit--ezobjectrelation'; @@ -122,9 +122,18 @@ const config = JSON.parse(event.currentTarget.dataset.udwConfig); const limit = parseInt(event.currentTarget.dataset.limit); - const title = limit === 1 - ? Translator.trans(/*@Desc("Select a Content item")*/ 'ezobjectrelationlist.title.single', {}, 'universal_discovery_widget') - : Translator.trans(/*@Desc("Select Content item(s)")*/ 'ezobjectrelationlist.title.multi', {}, 'universal_discovery_widget'); + const title = + limit === 1 + ? Translator.trans( + /*@Desc("Select a Content item")*/ 'ezobjectrelationlist.title.single', + {}, + 'universal_discovery_widget' + ) + : Translator.trans( + /*@Desc("Select Content item(s)")*/ 'ezobjectrelationlist.title.multi', + {}, + 'universal_discovery_widget' + ); ReactDOM.render( React.createElement( @@ -166,9 +175,9 @@ ${contentName} ${contentTypeName} ${new Date(item.ContentInfo.Content.publishedDate).toLocaleString()} - + `; }; @@ -219,7 +228,7 @@ }; const attachRowsEventHandlers = () => { const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; - + findOrderInputs().forEach((item) => { item.addEventListener('blur', updateSelectedItemsOrder, false); From 3b2617bcb75856cddd9319fdb0f46944634beaa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Grabowski?= Date: Wed, 15 Apr 2020 13:24:59 +0200 Subject: [PATCH 3/3] EZP-29475: added 10 to parseInt --- .../public/js/scripts/fieldType/ezobjectrelationlist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js index 55f03eb7b8..28f0bd4264 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/ezobjectrelationlist.js @@ -121,7 +121,7 @@ event.preventDefault(); const config = JSON.parse(event.currentTarget.dataset.udwConfig); - const limit = parseInt(event.currentTarget.dataset.limit); + const limit = parseInt(event.currentTarget.dataset.limit, 10); const title = limit === 1 ? Translator.trans(