Add input id to args in toggleValue event (#13108)

This commit is contained in:
Bjarne Fyrstenborg
2022-11-28 21:33:59 +01:00
committed by GitHub
parent 2d560e9766
commit a7368542d8
2 changed files with 14 additions and 9 deletions

View File

@@ -82,7 +82,7 @@
// 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 });
eventsService.emit("toggleValue", { value: scope.checked, inputId: scope.inputId });
}, 100);
}
@@ -122,7 +122,7 @@
}
if (scope.onClick) {
eventsService.emit("toggleValue", { value: !scope.checked });
eventsService.emit("toggleValue", { value: !scope.checked, inputId: scope.inputId });
scope.onClick();
}
};

View File

@@ -1,7 +1,7 @@
angular.module("umbraco").controller("Umbraco.PrevalueEditors.MultiColorPickerController",
angular.module("umbraco").controller("Umbraco.PrevalueEditors.MultiColorPickerController",
function ($scope, angularHelper, $element, eventsService) {
var vm = this;
const vm = this;
vm.add = add;
vm.remove = remove;
@@ -15,10 +15,10 @@
vm.labelEnabled = false;
vm.editItem = null;
//NOTE: We need to make each color an object, not just a string because you cannot 2-way bind to a primitive.
var defaultColor = "000000";
var defaultLabel = null;
// NOTE: We need to make each color an object, not just a string because you cannot 2-way bind to a primitive.
const defaultColor = "000000";
const defaultLabel = null;
$scope.newColor = defaultColor;
$scope.newLabel = defaultLabel;
$scope.hasError = false;
@@ -48,15 +48,20 @@
}
});
}
var evts = [];
evts.push(eventsService.on("toggleValue", function (e, args) {
vm.labelEnabled = args.value;
if (args.inputId === "useLabel") {
vm.labelEnabled = args.value;
}
}));
$scope.$on('$destroy', function () {
for (var e in evts) {
eventsService.unsubscribe(evts[e]);
}
});
if (!Utilities.isArray($scope.model.value)) {
//make an array from the dictionary
var items = [];