From b1df439b7618af54cbf1cac606563480ee2c3fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Wed, 11 Oct 2023 10:42:38 +0200 Subject: [PATCH] ENH: introduce a build var for max_options --- build.properties.d/00_default.properties | 6 ++++++ src/core/js/edit_mode.js | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/build.properties.d/00_default.properties b/build.properties.d/00_default.properties index 99a031ce..96017406 100644 --- a/build.properties.d/00_default.properties +++ b/build.properties.d/00_default.properties @@ -151,6 +151,12 @@ BUILD_FOOTER_CUSTOM_ELEMENT_TWO='<p class="caosdb-footer-element"> <a href="http ############################################################################## BUILD_MODULE_EXT_TRIGGER_CRAWLER_FORM_TOOLBOX="Tools" +############################################################################## +# Reduce the number of candidates for references in the edit mode to this +# value. -1 means: no limit. +############################################################################## +BUILD_MAX_EDIT_MODE_DROPDOWN_OPTIONS=-1 + ############################################################################## # Build a dist file containing all JS code from the files in the # MODULE_DEPENDENCIES array. diff --git a/src/core/js/edit_mode.js b/src/core/js/edit_mode.js index 641cd1b6..afb3da92 100644 --- a/src/core/js/edit_mode.js +++ b/src/core/js/edit_mode.js @@ -1892,9 +1892,11 @@ var edit_mode = new function () { */ this.retrieve_datatype_list = async function (datatype) { var find_entity = ["FILE", "REFERENCE"].includes(datatype) ? "" : `"${datatype}"`; - const max_options = 100; //for each query; there might be more candidates in total - 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); + const max_options = parseInt("${BUILD_MAX_EDIT_MODE_DROPDOWN_OPTIONS}"); //for each query; there might be more candidates in total + 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); @@ -1905,7 +1907,7 @@ var edit_mode = new function () { .concat(edit_mode ._create_reference_options(await files)); - if (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.` -- GitLab