Fix issue with duplicate author search keywords

This commit is contained in:
Tetrakern 2024-04-26 13:21:39 +02:00
parent cda7675aef
commit bc8937daa6
4 changed files with 16 additions and 9 deletions

File diff suppressed because one or more lines are too long

8
js/complete.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -91,7 +91,9 @@ if ( $show_advanced ) {
if ( ! $skip_author_keywords ) {
foreach ( $all_authors as $author ) {
$allow_list[ rawurlencode( strtolower( $author->display_name ) ) ] = $author->ID;
$author_key = rawurlencode( strtolower( $author->display_name ) );
$allow_list[ $author_key . '_' . $author->ID ] = $author->ID;
}
}
}

View File

@ -1698,10 +1698,15 @@ class FCN_KeywordInput {
this.noHint.hidden = !(value != '' && count < 1);
}
addNode(text = null) {
addNode(text = null, trigger = null) {
// Get and prepare value
const name = text ?? this.input.value.replace(',', '');
const value = this.allowList[this.encode(name)];
let value = this.allowList[this.encode(name)];
// Author names can be duplicates
if (this.collection.name == 'authors' && trigger) {
value = this.allowList[this.encode(name) + '_' + trigger.value];
}
// Only allowed value and no duplicates
if (!value || this.keywords.indexOf(value) > -1) {
@ -1866,7 +1871,7 @@ class FCN_KeywordInput {
'click',
event => {
clearTimeout(this.blurTimeout); // Stop blur event
this.addNode(event.currentTarget.innerText);
this.addNode(event.currentTarget.innerText, event.currentTarget);
}
);
});