Skip to content

getParents() returns wrong list of parents, when preview panels are opened (that contain parents)

Created by: Alexander Schlemmer

Assume you have a Record with exactly one parent. This Record furthermore has a (referenced) Property that also has exactly one parent.

Calling getParents() on the Record without having pressed the preview (eye) button: correctly returns 1 parent. Calling getParents() on the Record after having pressed the preview (eye) button: incorrectly returns both parents.

Imported comments:

By Alexander Schlemmer on 2021-02-20T13:55:09.960Z

mentioned in merge request !115 (merged)

By Alexander Schlemmer on 2021-02-18T13:32:08.637Z

Yes.

By Timm Fitschen on 2021-02-18T12:40:34.651Z

@salexan Do you have the capacity to implement your proposed solution? I could implement the test.

By Alexander Schlemmer on 2021-02-17T16:06:52.539Z

@timm.fitschen Same problem probably occurs for other functions within caosdb.js . We should carefully review and refactor this!

By Alexander Schlemmer on 2021-02-17T16:06:01.116Z

Proposed solution:

function getParents(element) {
    var res = element.getElementsByClassName("caosdb-parent-name"); // <- has to be replaced with findElementByConditions
    var list = [];
    for (var i = 0; i < res.length; i++) {
        list.push({
            id: getIDfromHREF(res[i]),
            name: res[i].textContent
        });
    }
    return list;
}
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information