From 20f886aaec4fe41e64a1ae70fa65fddac1afb50f Mon Sep 17 00:00:00 2001 From: BatJan Date: Mon, 21 Oct 2019 19:57:26 +0200 Subject: [PATCH] Extend the umb-radio button directive to handle localizations --- .../components/forms/umbradiobutton.directive.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbradiobutton.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbradiobutton.directive.js index bb36e3b027..f3ecac2a74 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbradiobutton.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbradiobutton.directive.js @@ -26,6 +26,7 @@ @param {string} value Set the value of the radiobutton. @param {string} name Set the name of the radiobutton. @param {string} text Set the text for the radiobutton label. +@param {string} labelKey Set a dictinary/localization string for the checkbox label @param {boolean} disabled Set the radiobutton to be disabled. @param {boolean} required Set the radiobutton to be required. @param {callback} onChange Callback when the value of the radiobutton change by interaction. @@ -39,15 +40,27 @@ 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 () { vm.onChange({ model: vm.model, value: vm.value }); }, 0); } - } + } } var component = { @@ -60,6 +73,7 @@ value: "@", name: "@", text: "@", + labelKey: "@?", disabled: "<", required: "<", onChange: "&?"