diff --git a/src/core/js/caosdb.js b/src/core/js/caosdb.js index e08fcf5db8860c02ecdd9eabf670770cba23777a..c864c614735ac53440ca8a6cd01926297b5d4217 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 +}