Skip to content
Snippets Groups Projects
Commit 43ccb2b0 authored by florian's avatar florian
Browse files

FIX: Unhide entities in preview container

parent b4d2ba9f
No related branches found
No related tags found
1 merge request!92F fix hidden prop in preview
Pipeline #32720 passed
......@@ -25,7 +25,7 @@
* @requires log (singleton from loglevel library)
* @requires load_config (function from webcaosdb.js)
*/
var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, getPropertyElements, getPropertyName, getUserName, getUserRoles, logger, load_config, query) {
var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, getPropertyElements, getPropertyName, getUserName, getUserRoles, logger, load_config, preview, query) {
/**
* Return the property-display config file; `ext_prop_display.json` by
......@@ -210,29 +210,34 @@ var prop_display = new function ($, edit_mode, getEntityName, getEntityRole, get
this.displayProperties(entities, conf, allTypes, userName, userRoles);
// If we are in the edit mode, (un)hide properties after ending
// the editing of an entity
for (let event_t of [edit_mode.start_edit.type, preview.showPreviewEvent.type]) {
document.body.addEventListener(event_t, (e) => {
edit_mode.app.onAfterShowResults = this._displayPropertiesWrapper(edit_mode.app.onAfterShowResults, conf, allTypes);
}, true);
}
document.body.addEventListener(edit_mode.start_edit.type, (e) => {
edit_mode.app.onAfterShowResults = this._displayPropertiesWrapper(edit_mode.app.onAfterShowResults, conf, allTypes);
}, true);
// After showing a preview for the first time, its entity card is
// added to the dom tree, so the properties have to be (un)hidden
// afterwards.
document.body.addEventListener(preview.previewReadyEvent.type, (e) => {
let newEntities = $(".caosdb-entity-preview");
this.displayProperties(newEntities, conf, allTypes, userName, userRoles);
console.log("unhiding properties in preview");
}, true);
} else {
// There are no properties to be hidden, so make this clear in HTML body
$("body").attr("data-hidden-properties", "false")
$("body").attr("data-hidden-properties", "false");
this.unhideAllProperties();
for (let event_t of [edit_mode.start_edit.type, preview.showPreviewEvent.type]) {
document.body.addEventListener(edit_mode.start_edit.type, (e) => {
// also unhide properties when leaving the edit mode
// TODO(fspreck): We're lacking a proper state/event here in the
// edit mode, so do this on "init", since this is the state to which
// the state machine returns after either successfully saving an
// entity or canceling the edit.
edit_mode.app.onAfterShowResults = this._unhideAllPropertiesWrapper(edit_mode.app.onAfterShowResults);
}, true);
}
document.body.addEventListener(edit_mode.start_edit.type, (e) => {
// also unhide properties when leaving the edit mode
// TODO(fspreck): We're lacking a proper state/event here in the
// edit mode, so do this on "init", since this is the state to which
// the state machine returns after either successfully saving an
// entity or canceling the edit.
edit_mode.app.onAfterShowResults = this._unhideAllPropertiesWrapper(edit_mode.app.onAfterShowResults);
}, true);
document.body.addEventListener(preview.previewReadyEvent.type, (e) => this.unhideAllProperties(), true);
}
}
}($, edit_mode, getEntityName, getEntityRole, getPropertyElements, getPropertyName, getUserName, getUserRoles, log.getLogger("ext_prop_display"), load_config, query);
}($, edit_mode, getEntityName, getEntityRole, getPropertyElements, getPropertyName, getUserName, getUserRoles, log.getLogger("ext_prop_display"), load_config, preview, query);
$(document).ready(() => {
if ("${BUILD_MODULE_EXT_PROPERTY_DISPLAY}" == "ENABLED") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment