Commit 695480e9 by kevalbhatt

ATLAS-3617 : Labels , UI : Attempting to add duplicate label removes both the…

ATLAS-3617 : Labels , UI : Attempting to add duplicate label removes both the duplicate and already existing label with same name.
parent ac808af0
......@@ -74,7 +74,7 @@ define(['require',
});
this.ui.addLabelOptions.html(str);
var getLabelData = function(data, selectedData) {
if (data.suggestions) {
if (data.suggestions.length) {
return _.map(data.suggestions, function(name, index) {
var findValue = _.find(selectedData, { id: name })
if (findValue) {
......@@ -87,7 +87,8 @@ define(['require',
}
});
} else {
return [];
var findValue = _.find(selectedData, { id: data.prefixString })
return findValue ? [findValue] : [];
}
};
this.ui.addLabelOptions.select2({
......@@ -110,6 +111,12 @@ define(['require',
},
cache: true
},
createTag: function(data) {
var found = _.find(this.$element.select2("data"), { id: data.term });
if (!found) {
return { id: data.term, text: data.term };
}
},
templateResult: this.formatResultSearch
});
},
......
......@@ -74,7 +74,7 @@ define(['require',
});
this.ui.addLabelOptions.html(str);
var getLabelData = function(data, selectedData) {
if (data.suggestions) {
if (data.suggestions.length) {
return _.map(data.suggestions, function(name, index) {
var findValue = _.find(selectedData, { id: name })
if (findValue) {
......@@ -87,7 +87,8 @@ define(['require',
}
});
} else {
return [];
var findValue = _.find(selectedData, { id: data.prefixString })
return findValue ? [findValue] : [];
}
};
this.ui.addLabelOptions.select2({
......@@ -110,6 +111,12 @@ define(['require',
},
cache: true
},
createTag: function(data) {
var found = _.find(this.$element.select2("data"), { id: data.term });
if (!found) {
return { id: data.term, text: data.term };
}
},
templateResult: this.formatResultSearch
});
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment