Update boolean/toggle/checkbox label prevalues (#8477)
This commit is contained in:
committed by
GitHub
parent
2dedaf888b
commit
eef894c617
@@ -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];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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}}">
|
||||
</umb-toggle>
|
||||
</div>
|
||||
|
||||
@@ -7,10 +7,16 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// </summary>
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user