From 0ab492611f6efcf1ec3ba6d95958d8431abe110a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Grabowski?= Date: Fri, 17 Apr 2020 10:25:37 +0200 Subject: [PATCH] EZP-29475: Changes for UDW title (#1346) --- .../alloyeditor/src/buttons/ez-btn-embed.js | 2 +- .../src/buttons/ez-btn-embedinline.js | 2 +- .../src/buttons/ez-btn-embedupdate.js | 2 +- .../alloyeditor/src/buttons/ez-btn-image.js | 2 +- .../src/buttons/ez-btn-imageupdate.js | 2 +- .../scripts/fieldType/ezobjectrelationlist.js | 24 ++++++++++++++----- .../translations/alloy_editor.en.xliff | 16 ++++++------- .../universal_discovery_widget.en.xliff | 13 ++++++---- .../fieldtypes/edit/relation_base.html.twig | 1 + 9 files changed, 41 insertions(+), 23 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 0c4914298c..04581d4095 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 @@ -63,7 +63,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..28f0bd4264 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'; @@ -121,7 +121,19 @@ 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, 10); + 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( @@ -163,9 +175,9 @@ ${contentName} ${contentTypeName} ${new Date(item.ContentInfo.Content.publishedDate).toLocaleString()} - + `; }; @@ -216,7 +228,7 @@ }; const attachRowsEventHandlers = () => { const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; - + findOrderInputs().forEach((item) => { item.addEventListener('blur', updateSelectedItemsOrder, false); 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">