New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check if item exists when creating new, fixes #573 #1000
Conversation
Hooray, I caught the 1000! 😜 |
Job #114: Bundle Size — 10.44MB (+0.02%).Changed metrics (2/8)
|
Just uploaded a slight adjustment that fixes the Vue warning to not alter props. |
Not a bad idea, but I think it would cause all items to be loaded again when the item form is displayed in the Model page. model.vue => item-details.vue => item-form.vue openhab-webui/bundles/org.openhab.ui/web/src/components/model/item-details.vue Lines 11 to 16 in 0bcbd8c
The model component already has a flat list of items at hand so it could pass it to item-details as a prop (currently it has only a Storing the items in Vuex is naturally the best way to go, but the challenge would become to detect/invalidate the cache when that list has changed - apart from keeping an EventSource open, which I don't think is reasonable, I have no good solution for this. That's why for instance the item picker fetches the list of items every time - they might have changed at any time, not only from the current UI tab. See also #793. |
I see.
So, does that mean passing the items as props would be ok (for now)? (since Vuex and caching would be more of a big, "global" change) |
Yes, sorry. I was talking "in the long run". Even if the info is rather volatile because it has to be checked regularly for changes, for instance the Model page could tell the Vuex store's items list to update and the children components would reuse it. There could even be some logic on how to update, that would avoid fetching the entire response if it's not necessary, like a |
I just committed an update. |
I just discovered that this actually also fixes #906. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, mostly LGTM, have a few final remarks.
Also it would be good to expand the cautious "sharing" of these lists of reusable items in the Vuex store as discussed, since passing such data as props down the component tree is not ideal and not a Vue best practice. But for now, it's fine!
Ok, so I updated this and checked it more thoroughly 😅. Changes:
As discussed before, having the items handled and cached in a Vuex-store would be much better. I'm planning on doing some tests and maybe open a community forum thread for discussions regarding this. |
bundles/org.openhab.ui/web/src/pages/settings/model/add-from-thing.vue
Outdated
Show resolved
Hide resolved
…hab#906 Signed-off-by: Hubert Nusser <hubsif@gmx.de>
This addresses #573. It adds an existence check to item-form.
Since the UI would load the items from the server multiple times and also each time the radio button is toggled between "new" and "existing", I modified
item-form
anditem-picker
to accept already loaded items as property. Items are now loaded inlink-add
(if required) and passed on to those components.Originally I wanted to start migrating this to Vuex. But during planning I realized that this would become too big a change, since I think when doing this the whole REST API should be wrapped in a cache (e.g. vuex-rest-api-cache), so unchanged stuff doesn't always get loaded from the server. Since this would have had major impact in API communications and required a lot of time for testing, I dropped it.