Fixes: U4-7660 [7.4 Fix] Added a default value to the Umbaco.TrueFalse datatype. Thanks Jeremy Pyne

This commit is contained in:
Mads Rasmussen
2016-02-18 11:20:04 +01:00
parent 51ed441b85
commit dbb9386d22
2 changed files with 17 additions and 2 deletions

View File

@@ -4,6 +4,11 @@ function booleanEditorController($scope, $rootScope, assetsService) {
$scope.renderModel = {
value: false
};
if($scope.model.config.default.toString() === "1" && $scope.model && !$scope.model.value) {
$scope.renderModel.value = true;
}
if ($scope.model && $scope.model.value && ($scope.model.value.toString() === "1" || angular.lowercase($scope.model.value) === "true")) {
$scope.renderModel.value = true;
}
@@ -14,7 +19,7 @@ function booleanEditorController($scope, $rootScope, assetsService) {
$scope.$watch("renderModel.value", function (newVal) {
$scope.model.value = newVal === true ? "1" : "0";
});
//here we declare a special method which will be called whenever the value has changed from the server
//this is instead of doing a watch on the model.value = faster
$scope.model.onValueChanged = function (newVal, oldVal) {
@@ -23,4 +28,4 @@ function booleanEditorController($scope, $rootScope, assetsService) {
};
}
angular.module("umbraco").controller("Umbraco.PropertyEditors.BooleanController", booleanEditorController);
angular.module("umbraco").controller("Umbraco.PropertyEditors.BooleanController", booleanEditorController);

View File

@@ -6,5 +6,15 @@ namespace Umbraco.Web.PropertyEditors
[PropertyEditor(Constants.PropertyEditors.TrueFalseAlias, "True/False", "INT", "boolean", IsParameterEditor = true, Group = "Common", Icon="icon-checkbox")]
public class TrueFalsePropertyEditor : PropertyEditor
{
protected override PreValueEditor CreatePreValueEditor()
{
return new TrueFalsePreValueEditor();
}
internal class TrueFalsePreValueEditor : PreValueEditor
{
[PreValueField("default", "Default Value", "boolean")]
public string Default { get; set; }
}
}
}