From 59ba2599d8f50aaa47e4b2569886868817912bf3 Mon Sep 17 00:00:00 2001 From: Florian Spreckelsen <f.spreckelsen@indiscale.com> Date: Mon, 23 Sep 2024 15:00:08 +0200 Subject: [PATCH] WIP: Lazy-load dropdown options --- src/core/js/edit_mode.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/core/js/edit_mode.js b/src/core/js/edit_mode.js index 5b97fe30..d73227aa 100644 --- a/src/core/js/edit_mode.js +++ b/src/core/js/edit_mode.js @@ -1389,7 +1389,25 @@ var edit_mode = new function () { // create inputs - var inputs = edit_mode.create_value_inputs(property); + if (property.reference && ("${BUILD_EDIT_MODE_LAZY_DROPDOWN_LOADING}" == "ENABLED")) { + // Only add button to load reference options lazily. + const editValueButton = $(`<button title="Edit this property" class="btn btn-link caosdb-update-entity-button-caosdb-f-list-item-button"><i class="bi-pencil"/></button>`); + $(editValueButton).click(() => edit_mode._addPropertyEditInputs(property, editfield)); + $(editfield).append(editValueButton); + // Trash button can exist without having to load all options + edit_mode.add_property_trash_button($(element).find(".caosdb-property-edit")[0], element); + } + else { + edit_mode._addPropertyEditInputs(property, editfield); + } + } + + /** + * Add input elements for value, units, list toggling, and + * deletion to a property row. + */ + this._addPropertyEditInputs(property, editfield) { + var inputs = edit_mode.create_value_inputs(property); editfield.children().remove(); editfield.append(inputs); // selectpicker is based on bootstrap-select and must be initializes -- GitLab