diff --git a/CHANGELOG.md b/CHANGELOG.md index f0f46cddce0ffcd2450c3ec8bcc5b6693b2161c5..1f9260a1c049c31ff724b3e1d4205e2976d038d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added (for new features, dependecies etc.) +* A `#version_history` URI fragment which can be used to directly open the modal + with the full version history of the first entity on the page. +* `BUILD_MODULE_SHOW_ID_IN_LABEL` build variable with which the showing of + entity ids together with their names if it is enabled (disabled by default). + ### Changed (for changes in existing functionality) ### Deprecated (for soon-to-be removed features) @@ -16,6 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed (for any bug fixes) +* Fixed saving of text properties that were changed in the Source-Editing mode + of the WYSIWYG editor. + ### Security (in case of vulnerabilities) ### Documentation (for notable additions or changes of the documentation) @@ -37,7 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Optional WYSIWYG editor with markdown output for text properties. Controled by the `BUILD_MODULE_EXT_EDITMODE_WYSIWYG_TEXT` build variable which is set do `DISABLED` by default. - - Added button to version history panel that allows restoring old versions +* Added button to version history panel that allows restoring old versions ### Changed (for changes in existing functionality) diff --git a/build.properties.d/00_default.properties b/build.properties.d/00_default.properties index 535a6c846a5c39c48937dee43f087501f43285ae..60616622c34259e572f3c1f984574972595e9316 100644 --- a/build.properties.d/00_default.properties +++ b/build.properties.d/00_default.properties @@ -53,6 +53,7 @@ BUILD_MODULE_EXT_ADD_QUERY_TO_BOOKMARKS=DISABLED BUILD_MODULE_EXT_ANNOTATION=ENABLED BUILD_MODULE_EXT_COSMETICS_LINKIFY=DISABLED BUILD_MODULE_EXT_QRCODE=ENABLED +BUILD_MODULE_SHOW_ID_IN_LABEL=DISABLED BUILD_MODULE_USER_MANAGEMENT=ENABLED BUILD_MODULE_USER_MANAGEMENT_CHANGE_OWN_PASSWORD_REALM=CaosDB diff --git a/src/core/css/webcaosdb.css b/src/core/css/webcaosdb.css index b76a5fe9ecc9f6d866dc159429ef7401ac3ddd5d..8fe10a153887a0c051846734a5a40cc195666f5b 100644 --- a/src/core/css/webcaosdb.css +++ b/src/core/css/webcaosdb.css @@ -279,9 +279,17 @@ h5 { left: 0px; } +.caosdb-label-link { + text-decoration: none; +} + +.caosdb-label-id { + margin-right: 0.3em; + display: none; +} + .caosdb-label-name { font-weight: bold; - text-decoration: none; } /* lists of values */ diff --git a/src/core/js/ext_editmode_wysiwyg_text.js b/src/core/js/ext_editmode_wysiwyg_text.js index f784dbd5d998ffeb95b4d594c907ff725441eadd..d5cd88a85084c76fd92c8710d9845bd80f09fb95 100644 --- a/src/core/js/ext_editmode_wysiwyg_text.js +++ b/src/core/js/ext_editmode_wysiwyg_text.js @@ -39,6 +39,8 @@ */ var ext_editmode_wysiwyg_text = function ($, logger, ClassicEditor, edit_mode, getPropertyElements, getPropertyDatatype, getPropertyName) { + var _callOnSave = []; + var insertEditorInProperty = async function (prop) { if (!(getPropertyDatatype(prop) === 'TEXT')) { // Ignore anything that isn't a list property, even LIST<TEXT> @@ -62,7 +64,7 @@ var ext_editmode_wysiwyg_text = function ($, logger, ClassicEditor, edit_mode, g logger.debug('Initialized editor for ' + getPropertyName(prop)); // Manually implement saving the data since edit mode is not // a form to be submitted. - editor.model.document.on("change:data", (e) => { + _callOnSave.push(() => { editor.updateSourceElement(); }); } catch (error) { @@ -70,7 +72,23 @@ var ext_editmode_wysiwyg_text = function ($, logger, ClassicEditor, edit_mode, g } } + const proxySaveMethod = function (original) { + const result = function (entity) { + _callOnSave.forEach(cb => { + cb(); + }); + if (typeof original === "function") { + return original(entity); + } + return undefined; + } + return result; + } + var replaceTextAreas = function (entity) { + // on save, call callbacks + edit_mode.app.onBeforeInsert = proxySaveMethod(edit_mode.app.onBeforeInsert); + edit_mode.app.onBeforeUpdate = proxySaveMethod(edit_mode.app.onBeforeUpdate); const properties = getPropertyElements(entity); for (let prop of properties) { // TODO(fspreck): This will be replaced by a whitelist of properties @@ -107,6 +125,12 @@ var ext_editmode_wysiwyg_text = function ($, logger, ClassicEditor, edit_mode, g logger.debug('Re-rendering ' + getPropertyName(e.target)); ext_editmode_wysiwyg_text.insertEditorInProperty(e.target); }, true); + + // Clear list of saving callbacks when leaving the edit mode (regardless + // of saving or cancelling) + document.body.addEventListener(edit_mode.end_edit.type, (e) => { + this._callOnSave = []; + }, true); }; return { diff --git a/src/core/js/webcaosdb.js b/src/core/js/webcaosdb.js index 03cc7bfbb399e898a88cb99dc0a05cc90289f96a..6d8971c044af8231dddb6c9d8f9b823262120ca9 100644 --- a/src/core/js/webcaosdb.js +++ b/src/core/js/webcaosdb.js @@ -4,8 +4,10 @@ * * Copyright (C) 2018 Research Group Biomedical Physics, * Max-Planck-Institute for Dynamics and Self-Organization Göttingen - * Copyright (C) 2019 IndiScale GmbH (info@indiscale.com) - * Copyright (C) 2019 Timm Fitschen (t.fitschen@indiscale.com) + * Copyright (C) 2022 IndiScale GmbH <info@indiscale.com> + * Copyright (C) 2019 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2022 Florian Spreckelsen <f.spreckelsen@indiscale.com> + * Copyright (C) 2022 Daniel Hornung <d.hornung@indiscale.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -990,6 +992,11 @@ var version_history = new function () { const logger = log.getLogger("version_history"); this.logger = logger; + this._has_version_fragment = function () { + const fragment = window.location.hash.substr(1); + return fragment === 'version_history'; + } + this._get = connection.get; /** * Retrieve the version history of an entity and return a table with the @@ -1161,6 +1168,18 @@ var version_history = new function () { this.init_load_history_buttons(); this.init_export_history_buttons(); this.init_restore_version_buttons(); + + // check for the version_history fragment and open the modal if present. + if (this._has_version_fragment()) { + const first_entity = $(".caosdb-entity-panel")[0]; + if (first_entity && hasEntityPermission(first_entity, "RETRIEVE:HISTORY")) { + logger.debug("Showing full version modal for first entity"); + const version_button = $(first_entity).find(".caosdb-f-entity-version-button"); + version_button.click(); + const full_version_history_button = $(first_entity).find(".caosdb-f-entity-version-load-history-btn"); + full_version_history_button.click(); + } + } } } @@ -1942,6 +1961,14 @@ function initOnDocumentReady() { if ("${BUILD_MODULE_USER_MANAGEMENT}" == "ENABLED") { caosdb_modules.register(user_management); } + + if ("${BUILD_MODULE_SHOW_ID_IN_LABEL}" == "ENABLED") { + // Remove the "display: none;" rule from the caosdb-label-id class + [...document.styleSheets] + .map(s => {return [...s.cssRules].find(x=> x.selectorText=='.caosdb-label-id')}) + .filter(Boolean) + .forEach( rule => rule.style.removeProperty("display")); + } } @@ -2000,4 +2027,4 @@ class _CaosDBModules { var caosdb_modules = new _CaosDBModules() -$(document).ready(initOnDocumentReady); \ No newline at end of file +$(document).ready(initOnDocumentReady); diff --git a/src/core/xsl/entity.xsl b/src/core/xsl/entity.xsl index d8ba00a9810e9861bfba741055ea113c7f2b88bc..ab7979367d2f77204a1e0c2e8acd9d5810649911 100644 --- a/src/core/xsl/entity.xsl +++ b/src/core/xsl/entity.xsl @@ -5,6 +5,10 @@ * * Copyright (C) 2018 Research Group Biomedical Physics, * Max-Planck-Institute for Dynamics and Self-Organization Göttingen + * Copyright (C) 2022 Indiscale GmbH <info@indiscale.com> + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2022 Florian Spreckelsen <f.spreckelsen@indiscale.com> + * Copyright (C) 2022 Daniel Hornung <d.hornung@indiscale.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -146,11 +150,14 @@ </xsl:for-each> </xsl:if> </span> - <a class="caosdb-label-name" title="Open this Entity separately."> + <a class="caosdb-label-link" title="Open this Entity separately."> <xsl:attribute name="href"> <xsl:value-of select="concat($entitypath, @id)"/> </xsl:attribute> - <xsl:value-of select="@name"/> + <span class="caosdb-label-id"><xsl:value-of select="@id"/></span> + <span class="caosdb-label-name"> + <xsl:value-of select="@name"/> + </span> </a> <div class="caosdb-v-entity-header-buttons-list ms-auto"> <xsl:apply-templates mode="entity-heading-attributes-state" select="State">