diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/buttons/umbtoggle.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/buttons/umbtoggle.directive.js index 5cdd23d4af..bbda02806e 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/buttons/umbtoggle.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/buttons/umbtoggle.directive.js @@ -79,7 +79,7 @@ setLabelText(); - // must wait until the current digest cycle is finished before we emit this event on init, + // Must wait until the current digest cycle is finished before we emit this event on init, // otherwise other property editors might not yet be ready to receive the event $timeout(function () { eventsService.emit("toggleValue", { value: scope.checked }); @@ -87,22 +87,28 @@ } function setLabelText() { - - // set default label for "on" + if (scope.labelOn) { scope.displayLabelOn = scope.labelOn; - } else { - localizationService.localize("general_on").then(function (value) { - scope.displayLabelOn = value; - }); } - - // set default label for "Off" + if (scope.labelOff) { scope.displayLabelOff = scope.labelOff; - } else { - localizationService.localize("general_off").then(function (value) { - scope.displayLabelOff = value; + } + + if (scope.displayLabelOn.length === 0 && scope.displayLabelOff.length === 0) + { + var labelKeys = [ + "general_on", + "general_off" + ]; + + localizationService.localizeMany(labelKeys).then(function (data) { + // Set default label for "On" + scope.displayLabelOn = data[0]; + + // Set default label for "Off" + scope.displayLabelOff = data[1]; }); } diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/boolean/boolean.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/boolean/boolean.controller.js index f06beed6cd..dab8d2c6f8 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/boolean/boolean.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/boolean/boolean.controller.js @@ -7,9 +7,14 @@ function booleanEditorController($scope, angularHelper) { // Maybe sometime later we can make it support "Yes/No" or "On/Off" as well similar to ng-true-value and ng-false-value in Angular. var config = { truevalue: "1", - falsevalue: "0" + falsevalue: "0", + showLabels: false }; + if ($scope.model.config && $scope.model.config.showLabels && Object.toBoolean($scope.model.config.showLabels)) { + config.showLabels = true; + } + // Map the user config Utilities.extend(config, $scope.model.config); diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/boolean/boolean.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/boolean/boolean.html index 21ed753c15..75f3f5452a 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/boolean/boolean.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/boolean/boolean.html @@ -3,9 +3,9 @@ input-id="{{model.alias}}" checked="renderModel.value" on-click="toggle()" - show-labels="{{model.config.labelOn ? 'true': 'false'}}" + show-labels="{{model.config.showLabels}}" label-position="right" label-on="{{model.config.labelOn}}" - label-off="{{model.config.labelOn}}"> + label-off="{{model.config.labelOff}}"> diff --git a/src/Umbraco.Web/PropertyEditors/TrueFalseConfiguration.cs b/src/Umbraco.Web/PropertyEditors/TrueFalseConfiguration.cs index 3fa82aa37e..03973cfc90 100644 --- a/src/Umbraco.Web/PropertyEditors/TrueFalseConfiguration.cs +++ b/src/Umbraco.Web/PropertyEditors/TrueFalseConfiguration.cs @@ -7,10 +7,16 @@ namespace Umbraco.Web.PropertyEditors /// public class TrueFalseConfiguration { - [ConfigurationField("default","Initial State", "boolean",Description = "The initial state for this checkbox, when it is displayed for the first time in the backoffice, eg. for a new content item.")] - public string Default { get; set; } // TODO: well, true or false?! + [ConfigurationField("default", "Initial State", "boolean", Description = "The initial state for the toggle, when it is displayed for the first time in the backoffice, eg. for a new content item.")] + public bool Default { get; set; } - [ConfigurationField("labelOn", "Write a label text", "textstring")] - public string Label { get; set; } + [ConfigurationField("showLabels", "Show toggle labels", "boolean", Description = "Show labels next to toggle button.")] + public bool ShowLabels { get; set; } + + [ConfigurationField("labelOn", "Label On", "textstring", Description = "Label text when enabled.")] + public string LabelOn { get; set; } + + [ConfigurationField("labelOff", "Label Off", "textstring", Description = "Label text when disabled.")] + public string LabelOff { get; set; } } } diff --git a/src/Umbraco.Web/PropertyEditors/TrueFalsePropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TrueFalsePropertyEditor.cs index fb2d2b29fe..76a78c65ba 100644 --- a/src/Umbraco.Web/PropertyEditors/TrueFalsePropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TrueFalsePropertyEditor.cs @@ -10,7 +10,7 @@ namespace Umbraco.Web.PropertyEditors [DataEditor( Constants.PropertyEditors.Aliases.Boolean, EditorType.PropertyValue | EditorType.MacroParameter, - "Checkbox", + "Toggle", "boolean", ValueType = ValueTypes.Integer, Group = Constants.PropertyEditors.Groups.Common,