diff --git a/src/core/js/fileupload.js b/src/core/js/fileupload.js index c6d133de8f1d87fe8fdd9080b1fc51f4db0794b2..cd272117e92d89e28850c2ba4af2678dcb40c438 100644 --- a/src/core/js/fileupload.js +++ b/src/core/js/fileupload.js @@ -261,24 +261,29 @@ var fileupload = new function() { } this.init = function() { - if ("${BUILD_EDIT_MODE_LAZY_DROPDOWN_LOADING}" == "ENABLED") { + if ("${BUILD_EDIT_MODE_LAZY_DROPDOWN_LOADING}" == "ENABLED") { + // If we have to manually enable editting of reference + // properties, we only want to add the file-upload button + // **after** we started editing the particular + // property. So no global event listener and not + // immediatly after adding a new reference property. document.body.addEventListener(edit_mode.property_edit_reference_value.type, function(e) { - fileupload.create_upload_app(e.target); - }, true); - } else { - // add global listener for start_edit event + fileupload.create_upload_app(e.target); + }, true); + } else { + // add global listener for start_edit event document.body.addEventListener(edit_mode.start_edit.type, function(e) { - $(e.target).find(".caosdb-properties .caosdb-f-entity-property").each(function(idx) { + $(e.target).find(".caosdb-properties .caosdb-f-entity-property").each(function(idx) { fileupload.create_upload_app(this); - }); + }); }, true); - } - // add global listener for property_added event - document.body.addEventListener(edit_mode.property_added.type, function(e) { - fileupload.create_upload_app(e.target); - }, true); + // add global listener for property_added event + document.body.addEventListener(edit_mode.property_added.type, function(e) { + fileupload.create_upload_app(e.target); + }, true); + } // add global listener for data_type_changed event document.body.addEventListener(edit_mode.property_data_type_changed.type, function(e) { @@ -302,7 +307,7 @@ var fileupload = new function() { this.create_upload_app = function(target) { const non_file_datatypes = ["TEXT", "DOUBLE", "BOOLEAN", "INTEGER", "DATETIME"]; var par = getPropertyDatatype(target); - var atom_par = par && par.startsWith("LIST<") && par.endsWith(">") ? par.substring(5, par.length-1) : par; + var atom_par = par && par.startsWith("LIST<") && par.endsWith(">") ? par.substring(5, par.length - 1) : par; if (non_file_datatypes.indexOf(atom_par) !== -1) { return; @@ -344,7 +349,7 @@ var fileupload = new function() { */ this.get_default_path = function() { var by = "unauthenticated/"; - if(isAuthenticated()) { + if (isAuthenticated()) { by = getUserRealm() + "/" + getUserName() + "/"; } return "/uploaded.by/" + by + fileupload.uuidv4() + "/";