Skip to content
Snippets Groups Projects

F fix max dropdown options

Merged Florian Spreckelsen requested to merge f-fix-max-dropdown-options into dev
All threads resolved!
Files
2
+ 13
9
@@ -1033,14 +1033,16 @@ var edit_mode = new function () {
$(manualInsertButton).click(function () {
// toggle input
// forward:
if ($(result).find('input.caosdb-f-manual-id-insert').is(':hidden')){
if ($(result).find('input.caosdb-f-manual-id-insert').is(':hidden')) {
// show ID input; hide dropdown
$(result).find('.dropdown').hide();
$(result).find('input.caosdb-f-manual-id-insert').show();
$('.caosdb-f-entity-save-button').hide()
} else {
// backward:
$(result).find('input.caosdb-f-manual-id-insert')[0].dispatchEvent(new KeyboardEvent('keyup', {'key':'Enter'}));
$(result).find('input.caosdb-f-manual-id-insert')[0].dispatchEvent(new KeyboardEvent('keyup', {
'key': 'Enter'
}));
}
});
// Add input for manual ID insertion
@@ -1053,8 +1055,8 @@ var edit_mode = new function () {
// was entered to the candidates and select that item
$(result).find('input.caosdb-f-manual-id-insert').hide();
var sel_id = $(result).find('input.caosdb-f-manual-id-insert')[0].value
if (sel_id!=""){
if ($(result).find(`option[value="${sel_id}"]`).length==0){
if (sel_id != "") {
if ($(result).find(`option[value="${sel_id}"]`).length == 0) {
select.append(`<option value="${sel_id}">ID: ${sel_id}</option>`);
// workaround for selectpicker bug (options are
// doubled otherwise)
@@ -1891,14 +1893,16 @@ var edit_mode = new function () {
* which can be referenced by the property.
*/
this.retrieve_datatype_list = async function (datatype) {
var find_entity = ["FILE", "REFERENCE"].includes(datatype) ? "" : `"${datatype}"`;
const find_entity = ["FILE", "REFERENCE"].includes(datatype) ? "" : `"${datatype}"`;
const max_options = parseInt("${BUILD_MAX_EDIT_MODE_DROPDOWN_OPTIONS}"); //for each query; there might be more candidates in total
if (max_options != -1){
const query_suffix = max_options != -1 ? `&P=0L${max_options}` : "";
if (max_options != -1) {
var n_entities = datatype !== "FILE" ? await edit_mode.query(`COUNT Record ${find_entity}`, true) : 0;
var n_files = await edit_mode.query(`COUNT File ${find_entity}`, true);
}
var entities = datatype !== "FILE" ? edit_mode.query(`FIND Record ${find_entity}&P=0L${max_options}`, true) : [];
var files = edit_mode.query(`FIND File ${find_entity}&P=0L${max_options}`, true);
const entities = datatype !== "FILE" ? edit_mode.query(`FIND Record ${find_entity}${query_suffix}`, true) : [];
const files = edit_mode.query(`FIND File ${find_entity}${query_suffix}`, true);
await Promise.all([entities, files])
@@ -1907,7 +1911,7 @@ var edit_mode = new function () {
.concat(edit_mode
._create_reference_options(await files));
if (max_options !=- 1 && (n_entities > max_options || n_files > max_options)) {
if (max_options != -1 && (n_entities > max_options || n_files > max_options)) {
// add notification that not all entities are shown
options = [$(`<option disabled=true value="NA"/>`).text(
`More than ${max_options} possible options; showing only a subset. You may need to enter the id manually.`
Loading