From 1242c64d058c7a7dd4522874809a4ddc912f1233 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Fri, 11 Dec 2020 13:47:36 +0100 Subject: [PATCH] REVIEW: minor changes, docs --- src/core/js/caosdb.js | 44 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/core/js/caosdb.js b/src/core/js/caosdb.js index e08fcf5d..c864c614 100644 --- a/src/core/js/caosdb.js +++ b/src/core/js/caosdb.js @@ -218,40 +218,38 @@ function getEntityName(element) { } /** - * Return the path of element. This attribute is always set for file entities. + * Return the path of an entity. + * + * This attribute is always set for file entities. + * * If the corresponding label can not be found or the label is ambigious undefined is returned. - * @return A string containing the path of the element. + * + * @param {HTMLElement} entity - entity in HTML representation. + * @return A string containing the path of the entity. */ function getEntityPath(element) { - // TODO: check if this if block is needed - // it is analogous to getEntityDescription - // if ($(element).find('[data-entity-path]').length == 1) { - // return $(element).find('[data-entity-path]')[0].dataset.entityPath; - // } - - if (typeof $(element).find('.caosdb-f-entity-path').val() !== 'undefined') { - // This is needed for the edit mode to work properly: - return $(element).find('.caosdb-f-entity-path').val(); + const path = $(element).find('.caosdb-f-entity-path').val(); + if (typeof path !== 'undefined') { + return path; } return getEntityHeadingAttribute(element, "path"); } /** - * Return the checksum of element. This attribute is always set for file entities. + * Return the checksum of an entity. + * + * This attribute is always set for file entities. + * * If the corresponding label can not be found or the label is ambigious undefined is returned. - * @return A string containing the checksum of the element. + * + * @param {HTMLElement} entity - entity in HTML representation. + * @return A string containing the checksum of the entity. */ function getEntityChecksum(element) { - // TODO: check if this if block is needed - // it is analogous to getEntityDescription - // if ($(element).find('[data-entity-checksum]').length == 1) { - // return $(element).find('[data-entity-checksum]')[0].dataset.entityChecksum; - // } - - if (typeof $(element).find('.caosdb-f-entity-checksum').val() !== 'undefined') { - // This is needed for the edit mode to work properly: - return $(element).find('.caosdb-f-entity-checksum').val(); + const checksum = $(element).find('.caosdb-f-entity-checksum').val(); + if (typeof checksum !== 'undefined') { + return checksum; } return getEntityHeadingAttribute(element, "checksum"); @@ -1116,4 +1114,4 @@ async function update(xml) { async function insert(xml) { var wrapped = createInsert(xml); return await transaction.insertEntitiesXml(wrapped); -} \ No newline at end of file +} -- GitLab