ReadOnlyValueController - enabled filters

Previously the code checks if the `config` is an array,
but with how config options are set, this would typically
be an object (dictionary). So the previous code would
never allow a filter to be set.

Now the check is on the object property.
This commit is contained in:
leekelleher
2019-06-07 15:31:00 +01:00
committed by Sebastiaan Janssen
parent 9ce996cbba
commit ee2ebc7d14

View File

@@ -14,13 +14,7 @@
function ReadOnlyValueController($rootScope, $scope, $filter) {
function formatDisplayValue() {
if ($scope.model.config &&
angular.isArray($scope.model.config) &&
$scope.model.config.length > 0 &&
$scope.model.config[0] &&
$scope.model.config.filter) {
if ($scope.model.config && $scope.model.config.filter) {
if ($scope.model.config.format) {
$scope.displayvalue = $filter($scope.model.config.filter)($scope.model.value, $scope.model.config.format);
} else {
@@ -29,12 +23,11 @@ function ReadOnlyValueController($rootScope, $scope, $filter) {
} else {
$scope.displayvalue = $scope.model.value;
}
}
//format the display value on init:
formatDisplayValue();
$scope.$watch("model.value", function (newVal, oldVal) {
//cannot just check for !newVal because it might be an empty string which we
//want to look for.
@@ -45,4 +38,4 @@ function ReadOnlyValueController($rootScope, $scope, $filter) {
});
}
angular.module('umbraco').controller("Umbraco.PropertyEditors.ReadOnlyValueController", ReadOnlyValueController);
angular.module('umbraco').controller("Umbraco.PropertyEditors.ReadOnlyValueController", ReadOnlyValueController);