Skip to content

Commit 315b4e9

Browse files
committed
TD-4430: Duplicate keywords issue
1 parent 03f6801 commit 315b4e9

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

AdminUI/LearningHub.Nhs.AdminUI/Views/Catalogue/Edit.cshtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,14 @@
360360
361361
// Split the input value by commas and trim each keyword
362362
var values = value.split(',').map(function (item) {
363-
return item.trim();
363+
return item.trim().toLowerCase();
364364
});
365365
366366
var duplicateKeywords = [];
367367
$('#keyword-error-span').hide();
368368
values.forEach(function (value) {
369369
if (value && keywords.indexOf(value) === -1) {
370-
keywords.push(value);
370+
keywords.push(value);
371371
$('#Keywords').val(keywords);
372372
var tag = $('<div class="keyword-tag"><p>' + value + '</p><i class="fa fa-times"></i><input class="keyword-value" type="hidden" value="' + value + '" /></div>');
373373
tag.find('.fa-times').on('click', removeKeyword);
@@ -386,7 +386,7 @@
386386
}
387387
});
388388
389-
$keywordInput.val("");
389+
$keywordInput.val("");
390390
if (keywords.length > 4) {
391391
$('#add-keyword').attr('disabled', 'disabled');
392392
$('#add-keyword-input').attr('disabled', 'disabled');

LearningHub.Nhs.WebUI/Scripts/vuesrc/contribute-resource/components/KeyWordsEditor.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@
8282
},
8383
async addKeyword() {
8484
if (this.newKeyword && this.newKeywordTrimmed.length > 0) {
85+
this.keywordChange();
8586
let allTrimmedKeyword = this.newKeywordTrimmed.toLowerCase().split(',');
8687
allTrimmedKeyword = allTrimmedKeyword.filter(e => String(e).trim());
8788
for (var i = 0; i < allTrimmedKeyword.length; i++) {
88-
let item = allTrimmedKeyword[i];
89+
let item = allTrimmedKeyword[i].trim();
8990
if (item.length > 0 && item.length <= 50) {
9091
let newKeywordObj = new KeywordModel({
9192
keyword: item,
@@ -96,6 +97,7 @@
9697
this.resourceDetails.resourceKeywords.push(newKeywordObj);
9798
this.newKeyword = '';
9899
} else if (newKeywordObj.id == 0) {
100+
this.newKeyword = '';
99101
this.keywordError = true;
100102
this.keywordErrorMessage.push(item);
101103
}

LearningHub.Nhs.WebUI/Scripts/vuesrc/contribute/ContentCommon.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,11 @@
537537
},
538538
async addKeyword() {
539539
if (this.newKeyword && this.newKeywordTrimmed.length > 0) {
540+
this.keywordChange();
540541
let allTrimmedKeyword = this.newKeywordTrimmed.toLowerCase().split(',');
541542
allTrimmedKeyword = allTrimmedKeyword.filter(e => String(e).trim());
542543
for (var i = 0; i < allTrimmedKeyword.length; i++) {
543-
let item = allTrimmedKeyword[i];
544+
let item = allTrimmedKeyword[i].trim();
544545
if (item.length > 0 && item.length <= 50) {
545546
let newkeywordObj = new KeywordModel();
546547
newkeywordObj.keyword = item;
@@ -554,6 +555,7 @@
554555
}
555556
this.newKeyword = '';
556557
} else if (newkeywordObj.id == 0) {
558+
this.newKeyword = '';
557559
this.keywordError = true;
558560
this.keywordErrorMessage.push(item);
559561
}

0 commit comments

Comments
 (0)