diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.controller.js index 771d854aae..a5924e17d3 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.controller.js @@ -11,7 +11,7 @@ if (!$scope.model.value) { $scope.model.value = []; } - + //add any fields that there isn't values for if ($scope.model.config.min > 0) { for (var i = 0; i < $scope.model.config.min; i++) { @@ -21,13 +21,43 @@ } } + //TODO remove text box only when is empty + $scope.addRemoveOnKeyDown = function (event, index) { + console.log("Index: " + index); + console.log($scope.model.value); + console.log("KeyCode: " + event.keyCode); + var txtBoxValue = $scope.model.value[index]; + console.log(txtBoxValue.value); + switch (event.keyCode) { + case 13: + if ($scope.model.config.max <= 0 || $scope.model.value.length < $scope.model.config.max) { + $scope.model.value.push({ value: "" }); + } + break; + case 8: + var remainder = []; + if ($scope.model.value.length > 1) { + if (txtBoxValue.value === "") { + for (var x = 0; x < $scope.model.value.length; x++) { + if (x !== index) { + remainder.push($scope.model.value[x]); + } + } + $scope.model.value = remainder; + } + } + break; + default: + } + } + $scope.add = function () { if ($scope.model.config.max <= 0 || $scope.model.value.length < $scope.model.config.max) { $scope.model.value.push({ value: "" }); } }; - $scope.remove = function(index) { + $scope.remove = function (index) { var remainder = []; for (var x = 0; x < $scope.model.value.length; x++) { if (x !== index) { diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.html index 7aba2d9432..ea7db2b4d5 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/multipletextbox/multipletextbox.html @@ -3,7 +3,7 @@
- +