Prevent angular crash when adding already existing tag

This commit is contained in:
Johannes Zellner
2020-03-25 06:51:39 +01:00
parent 4153fb7d1e
commit 9f0d694f0a

View File

@@ -595,11 +595,13 @@ app.directive('tagInput', function () {
});
};
$scope.addTag = function () {
var tagArray;
if ($scope.tagText.length === 0) {
return;
var tagArray = $scope.tagArray();
// prevent adding empty or existing items
if ($scope.tagText.length === 0 || tagArray.indexOf($scope.tagText) !== -1) {
return $scope.tagText = '';
}
tagArray = $scope.tagArray();
tagArray.push($scope.tagText);
$scope.inputTags = tagArray.join(',');
return $scope.tagText = '';