From 20fd5acae68684a92d035d249cb1cd7c025cc931 Mon Sep 17 00:00:00 2001 From: Jan Skovgaard Date: Thu, 17 Oct 2019 17:32:19 +0200 Subject: [PATCH] v8: Extend the umb-checkbox component to handle localization (#5635) --- .../components/forms/umbcheckbox.directive.js | 22 +++++++++--- .../src/less/components/umb-list.less | 4 +++ .../src/less/properties.less | 4 +++ .../views/components/forms/umb-checkbox.html | 1 + .../src/views/content/overlays/publish.html | 14 ++++---- .../content/overlays/publishdescendants.html | 34 ++++++++----------- .../src/views/content/overlays/save.html | 14 ++++---- .../src/views/content/overlays/schedule.html | 14 ++++---- .../views/content/overlays/sendtopublish.html | 26 +++++++------- .../src/views/content/overlays/unpublish.html | 18 +++++----- .../src/views/packages/edit.html | 16 --------- .../listview/overlays/listviewpublish.html | 23 ++++++------- .../listview/overlays/listviewunpublish.html | 17 ++++------ 13 files changed, 97 insertions(+), 110 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbcheckbox.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbcheckbox.directive.js index 8560b5a3ea..0f3d251e82 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbcheckbox.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbcheckbox.directive.js @@ -26,6 +26,7 @@ @param {string} value Set the value of the checkbox. @param {string} name Set the name of the checkbox. @param {string} text Set the text for the checkbox label. +@param {string} labelKey Set a dictinary/localization string for the checkbox label @param {string} serverValidationField Set the val-server-field of the checkbox. @param {boolean} disabled Set the checkbox to be disabled. @param {boolean} required Set the checkbox to be required. @@ -35,13 +36,25 @@ (function () { 'use strict'; - - function UmbCheckboxController($timeout) { - + + function UmbCheckboxController($timeout, localizationService) { + var vm = this; + vm.$onInit = onInit; vm.change = change; + function onInit() { + // If a labelKey is passed let's update the returned text if it's does not contain an opening square bracket [ + if (vm.labelKey) { + localizationService.localize(vm.labelKey).then(function (data) { + if(data.indexOf('[') === -1){ + vm.text = data; + } + }); + } + } + function change() { if (vm.onChange) { $timeout(function () { @@ -50,7 +63,7 @@ } } } - + var component = { templateUrl: 'views/components/forms/umb-checkbox.html', controller: UmbCheckboxController, @@ -61,6 +74,7 @@ value: "@", name: "@", text: "@", + labelKey: "@?", serverValidationField: "@", disabled: "<", required: "<", diff --git a/src/Umbraco.Web.UI.Client/src/less/components/umb-list.less b/src/Umbraco.Web.UI.Client/src/less/components/umb-list.less index 12d7085b0a..94cfa6f62c 100644 --- a/src/Umbraco.Web.UI.Client/src/less/components/umb-list.less +++ b/src/Umbraco.Web.UI.Client/src/less/components/umb-list.less @@ -36,6 +36,10 @@ a.umb-list-item:focus { color: @gray-4; } +.umb-list-item__description--checkbox{ + margin: 0 0 0 26px; +} + .umb-list-checkbox { position: absolute; opacity: 0; diff --git a/src/Umbraco.Web.UI.Client/src/less/properties.less b/src/Umbraco.Web.UI.Client/src/less/properties.less index e14bb5c0d6..152ea49bbd 100644 --- a/src/Umbraco.Web.UI.Client/src/less/properties.less +++ b/src/Umbraco.Web.UI.Client/src/less/properties.less @@ -48,6 +48,10 @@ flex-direction: row; } +.date-wrapper-mini--checkbox{ + margin: 0 0 0 26px; +} + .date-wrapper-mini__date { display: flex; diff --git a/src/Umbraco.Web.UI.Client/src/views/components/forms/umb-checkbox.html b/src/Umbraco.Web.UI.Client/src/views/components/forms/umb-checkbox.html index fd3b451e90..c35c600ce1 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/forms/umb-checkbox.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/forms/umb-checkbox.html @@ -15,5 +15,6 @@ + {{vm.text}} diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/publish.html b/src/Umbraco.Web.UI.Client/src/views/content/overlays/publish.html index d4a3bdd2a0..9e3499db6f 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/publish.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/publish.html @@ -13,32 +13,30 @@
-
+
+ server-validation-field="{{variant.htmlId}}" + text="{{ variant.language.name }}" + />
-
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.html b/src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.html index 5002007e20..7256fefbf7 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/publishdescendants.html @@ -6,12 +6,11 @@
- - - - +
@@ -23,12 +22,11 @@
- - - - +
@@ -39,17 +37,17 @@
-
+
+ server-validation-field="{{variant.htmlId}}" + text="{{variant.language.name}}"/>
-
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.html b/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.html index 4ca52ffc85..ef135b7b48 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.html @@ -17,31 +17,29 @@
-
+
+ server-validation-field="{{variant.htmlId}}" + text="{{variant.language.name}}" + />
-
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/schedule.html b/src/Umbraco.Web.UI.Client/src/views/content/overlays/schedule.html index 4b0bd55e49..4f4e3c2874 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/schedule.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/schedule.html @@ -86,27 +86,25 @@
-
+
+ on-change="vm.changeSelection(variant)" + text="{{variant.language.name}}" + />
- -
+
Publish:  {{variant.releaseDateFormatted}}
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/sendtopublish.html b/src/Umbraco.Web.UI.Client/src/views/content/overlays/sendtopublish.html index 55e2121d28..ee20680089 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/sendtopublish.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/sendtopublish.html @@ -12,31 +12,29 @@
-
+
+ server-validation-field="{{variant.htmlId}}" + text="{{ variant.language.name }}" + />
- +
diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.html b/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.html index 32b1d38841..e384823cc3 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.html +++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/unpublish.html @@ -15,7 +15,7 @@
-
+
+ server-validation-field="{{variant.htmlId}}" + text="{{ variant.language.name }}" + />
- + + + - +
diff --git a/src/Umbraco.Web.UI.Client/src/views/packages/edit.html b/src/Umbraco.Web.UI.Client/src/views/packages/edit.html index 53a8e58b58..9f91e1d0f7 100644 --- a/src/Umbraco.Web.UI.Client/src/views/packages/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/packages/edit.html @@ -131,80 +131,64 @@ Add -
-
-
-
-
-
-
-
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewpublish.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewpublish.html index abe1db73d2..88dfb45d4a 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewpublish.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewpublish.html @@ -4,11 +4,11 @@

- +
- +
@@ -26,20 +26,17 @@
- + on-change="vm.changeSelection(language)" + text="{{language.name}}" + />
- -
+ + + +
diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewunpublish.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewunpublish.html index f59b351181..d7f33db58b 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewunpublish.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/listview/overlays/listviewunpublish.html @@ -26,19 +26,16 @@
- + on-change="vm.changeSelection(language)" + text="{{language.name}}" + />
- + + +