describo / crate-builder-component

A VueJS UI component to build an RO-Crate
MIT License
6 stars 3 forks source link

Error: 'updateProperty' requires 'id' to be defined #70

Closed beepsoft closed 1 year ago

beepsoft commented 1 year ago

Using 0.39.0, when I try to edit a property without profile layouts, it works, but when using a profile with layouts it fails with Error: 'updateProperty' requires 'id' to be defined. It is reproducible with any property in a layout tab.

Here's a recording with the error in the development app:

https://github.com/describo/crate-builder-component/assets/1926265/8e96db3e-d008-4e38-9948-c15b3ec77f7d

I wanted to provide a fix, but was not sure how you imagined it working correctly.

So far I figured out that the entity is either set directly on the data object if there are no layout tabs, or if there are tabs the entity is set inside the tab structure and the data.entity is an empty object:

    let layout = applyLayout({ layouts, hide, entity });
    if (layout.entity) {
        data.tabs = [];
        data.entity = layout.entity;
    } else if (layout.tabs) {
        data.entity = {};
        data.tabs = layout.tabs;
    }

https://github.com/describo/crate-builder-component/blob/b8c9d2c6717ddc0fda34d108ce42e798bb1e41fe/src/crate-builder/RenderEntity/Shell.component.vue#L337C1-L344C6

When we arrive here data.entity is the empty object because there are tabs and the id this passes on is undefined and eventually reaches updateProperty where the error is printed.

https://github.com/describo/crate-builder-component/blob/b8c9d2c6717ddc0fda34d108ce42e798bb1e41fe/src/crate-builder/RenderEntity/Shell.component.vue#L556

A simple solution would be to set data.entity to the entity variable available in this block regardless of tabs, but I'm not sure if this is the way you would do it.

    if (layout.entity) {
        data.tabs = [];
        data.entity = layout.entity;
    } else if (layout.tabs) {
        data.entity = entity; // {};
        data.tabs = layout.tabs;
    }
marcolarosa commented 1 year ago

Thanks for reporting @beepsoft. I didn't test some recent changes well enough. Sorry about that. About to release 0.39.1 with this bugfix in it.