Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

fixed declining tagging via returning null #755 #903

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/uiSelectMultipleDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,16 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
stashArr = stashArr.slice(1,stashArr.length);
}
newItem = $select.tagging.fct($select.search);
newItem.isTag = true;
// verify the the tag doesn't match the value of an existing item
if ( stashArr.filter( function (origItem) { return angular.equals( origItem, $select.tagging.fct($select.search) ); } ).length > 0 ) {
return;

//Check if the tagging is declined
if(newItem !== null){
newItem.isTag = true;
// verify the the tag doesn't match the value of an existing item
if ( stashArr.filter( function (origItem) { return angular.equals( origItem, $select.tagging.fct($select.search) ); } ).length > 0 ) {
return;
}
newItem.isTag = true;
}
newItem.isTag = true;
// handle newItem string and stripping dupes in tagging string context
} else {
// find any tagging items already in the $select.items array and store them
Expand Down Expand Up @@ -342,11 +346,15 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
// dupe found, shave the first item
if ( dupeIndex > -1 ) {
items = items.slice(dupeIndex+1,items.length-1);
} else {
} else{
items = [];
items.push(newItem);
//push only if the item is not null
if(newItem !== null){
items.push(newItem);
}
items = items.concat(stashArr);
}

scope.$evalAsync( function () {
$select.activeIndex = 0;
$select.items = items;
Expand Down