describo / crate-builder-component

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

Unable to change crate data when entity-id="./" is set #68

Closed beepsoft closed 10 months ago

beepsoft commented 10 months ago

In the development app's EmbeddedComponent.component.vue I added entity-id="./" to make it navigate to the root entity explicitly:

        <describo-crate-builder
            :crate="data.selectedCrate"
            :profile="data.selectedProfile"
            :lookup="lookup"
            :readonly="data.readonly"
            :enable-context-editor="true"
            :enable-crate-preview="true"
            :enable-browse-entities="true"
            :enable-template-save="true"
            :enable-internal-routing="true"
            :enable-reverse-link-browser="true"
            :purge-unlinked-entities="true"
            :web-component="false"
            :language="data.selectedLanguage"

            entity-id="./"
        />

Now, if you try to select a crate (eg. "Complex item") and then try to change to any other example crate (say "Large Crate") the original selection will remain, so effectively changing the crate json is not possible if entity-id="./" is set.

In my application I am trying to implement an undo/redo mechanism, which takes care of crate json changes and can reset the crate json when the user wants to undo an editing. In this case the entity-id is always set the value of the currently selected entity, and if it happens to be entity-id="./" then I cannot change the crate json, or at least it is not visible in the crate builder.

marcolarosa commented 10 months ago

I'm not sure how I can resolve this inside the component without a lot of hacking around. I can't rewrite that property when the crate changes so as far as describo is concerned, if the current entity is ./ then there's nothing to do. I think this needs to be handled in your application. If you want to change the crate, first unset the entity id.

beepsoft commented 10 months ago

It is not really easy to make these property changes one after the other because React at least somehow batches such property updates and makes a rerender for changes in the batch. To set these values separately I may have to make those somehow async with setTimeout or sg. like this. But i think this is the same with Vue, as it also happens in your development app. How would you do it in Vue? How would you fix the dev app?

In our app whenever Describo emits @save:crate we may make some modifications to the crate JSON and reset it back in Describo, so updating the crate is a quite frequent action - and it is also quite usual that the user is at "./".

marcolarosa commented 10 months ago

It is not really easy to make these property changes one after the other because React at least somehow batches such property updates and makes a rerender for changes in the batch. To set these values separately I may have to make those somehow async with setTimeout or sg. like this. But i think this is the same with Vue, as it also happens in your development app. How would you do it in Vue? How would you fix the dev app?

Probably the same way.

In our app whenever Describo emits @save:crate we may make some modifications to the crate JSON and reset it back in Describo, so updating the crate is a quite frequent action - and it is also quite usual that the user is at "./".

I'll have a bit more a think about this. There should be a sensible way to do this somewhere.

beepsoft commented 10 months ago

Added comment on the commit: https://github.com/describo/crate-builder-component/commit/618b6cea63f31a8041706dd814ca4ad14f2cf889#commitcomment-126788422