Custom forms fixes (#361)
* added safety check * Prevent failing autocomplete field with type selectors in case more than one pair of type selectors and autocomplete field used --------- Co-authored-by: Georgy Litvinov <georgy.litvinov@tib.eu>
This commit is contained in:
parent
81e12cc492
commit
509e9cf22b
2 changed files with 21 additions and 4 deletions
|
@ -70,6 +70,9 @@ vitro.customFormUtils = {
|
||||||
},
|
},
|
||||||
|
|
||||||
capitalize: function(word) {
|
capitalize: function(word) {
|
||||||
return word.substring(0, 1).toUpperCase() + word.substring(1);
|
if (word){
|
||||||
|
return word.substring(0, 1).toUpperCase() + word.substring(1);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -340,8 +340,14 @@ var customForm = {
|
||||||
},
|
},
|
||||||
select: function(event, ui) {
|
select: function(event, ui) {
|
||||||
customForm.showAutocompleteSelection(ui.item.label, ui.item.uri, $(selectedObj));
|
customForm.showAutocompleteSelection(ui.item.label, ui.item.uri, $(selectedObj));
|
||||||
if ( $(selectedObj).attr('acGroupName') == customForm.typeSelector.attr('acGroupName') ) {
|
let currAttr = $(selectedObj).attr('acgroupname');
|
||||||
customForm.typeSelector.val(ui.item.msType);
|
if (currAttr) {
|
||||||
|
for (const customTypeSelector of customForm.typeSelector ) {
|
||||||
|
let customTypeAttr = $(customTypeSelector).attr('acgroupname');
|
||||||
|
if (customTypeAttr && currAttr === customTypeAttr) {
|
||||||
|
$(customTypeSelector).val(ui.item.msType);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -570,7 +576,15 @@ var customForm = {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$acSelectionObj = $(selectedObj);
|
$acSelectionObj = $(selectedObj);
|
||||||
customForm.typeSelector.val('');
|
let currAttr = $(selectedObj).attr('acgroupname');
|
||||||
|
if (currAttr) {
|
||||||
|
for (const customTypeSelector of customForm.typeSelector ) {
|
||||||
|
let customTypeAttr = $(customTypeSelector).attr('acgroupname');
|
||||||
|
if (customTypeAttr && currAttr === customTypeAttr) {
|
||||||
|
$(customTypeSelector).val('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$acSelector = this.getAcSelector($acSelectionObj);
|
$acSelector = this.getAcSelector($acSelectionObj);
|
||||||
|
|
Loading…
Add table
Reference in a new issue