From 6d88726479b17338dcc2f3860a4b423ade7fff7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Wed, 13 Mar 2019 11:46:33 +0100 Subject: [PATCH 1/2] Fixing code in sync functionality of checkbox-list --- .../checkboxlist/checkboxlist.controller.js | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/checkboxlist/checkboxlist.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/checkboxlist/checkboxlist.controller.js index 5ba9746c6eb7..43e50dc39265 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/checkboxlist/checkboxlist.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/checkboxlist/checkboxlist.controller.js @@ -33,9 +33,7 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.CheckboxListContro } function updateViewModel(configItems) { - - //check if it's already in sync - + //get the checked vals from the view model var selectedVals = _.map( _.filter($scope.selectedItems, @@ -47,22 +45,23 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.CheckboxListContro return m.value; } ); - //get all of the same values between the arrays - var same = _.intersection($scope.model.value, selectedVals); - //if the lengths are the same as the value, then we are in sync, just exit - - if (same.length === $scope.model.value.length === selectedVals.length) { + + //if the length is zero, then we are in sync, just exit. + if (_.difference($scope.model.value, selectedVals).length === 0) { + debugger; return; } $scope.selectedItems = []; - + + var iConfigItem; for (var i = 0; i < configItems.length; i++) { - var isChecked = _.contains($scope.model.value, configItems[i].value); + iConfigItem = configItems[i]; + var isChecked = _.contains($scope.model.value, iConfigItem.value); $scope.selectedItems.push({ checked: isChecked, - key: configItems[i].id, - val: configItems[i].value + key: iConfigItem.id, + val: iConfigItem.value }); } } From e16777fc28a1a8ce6bee9d8ec149820bfe380187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Fri, 22 Mar 2019 09:21:37 +0100 Subject: [PATCH 2/2] remove debugger; --- .../propertyeditors/checkboxlist/checkboxlist.controller.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/checkboxlist/checkboxlist.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/checkboxlist/checkboxlist.controller.js index 43e50dc39265..045a33ac3243 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/checkboxlist/checkboxlist.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/checkboxlist/checkboxlist.controller.js @@ -48,7 +48,6 @@ angular.module("umbraco").controller("Umbraco.PropertyEditors.CheckboxListContro //if the length is zero, then we are in sync, just exit. if (_.difference($scope.model.value, selectedVals).length === 0) { - debugger; return; }