Skip to content
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

[FR] "Binded" templates #992

Open
Matthieu-LAURENT39 opened this issue Nov 27, 2023 · 0 comments
Open

[FR] "Binded" templates #992

Matthieu-LAURENT39 opened this issue Nov 27, 2023 · 0 comments

Comments

@Matthieu-LAURENT39
Copy link
Contributor

Problem

Currently, if a template is changed, all your old items that used that templates will still be using the old fields, and you have to go through each ones to reload the template, then reorder the fields.
It's slow and error-prone (you can easily miss items or screw up when re-applying the template).

This could be fix by "binding" the template to items.
When the item is created with a template, it will remember which template was used to create it, being "binded" to that template.

Proposed solution

When an item's fields don't match with the template's current fields, a warning is shown.
This would be very simple, just add a small warning icon on the item and the parent collections
image
image

This makes it a lot easier to find items that are using outdated fields, however it doesn't help with the other issues.

For that, i would also suggest adding a "sync with template" button on the item edit form.
Using that button would automatically add the missing fields that are in the template but not in the item. It would also reorder the fields in the item to match the template's order.
It wouldn't delete old fields that were deleted from the template, as deleting data automatically is probably a bad idea. However, a warning icon could be displayed next to those fields, to show they don't match the template.

Automatically syncing all items with template when the template is modified could be possible, but this would make it hard to find modified items and to fill in the new fields.

Finally, it should be possible to "unbind" the template from the item, to keep Koillection's flexibility for example if you decide to have extra fields for that particular item.
It would also be nice to be able to bind a template to an unbinded item after the item has already been created, but that's not as important.

Things to consider

When syncing with template, some automatic migrations could be possible.
For example, if i have a field named notes that used to be a text and it got replaced by a field named notes that is a long text, it could be automatically migrated.
Same for other changes where no data loss occur (price -> text, number -> text, etc...)

As for changes to a type where data loss can occur, it could be converted as well but only when data loss wouldn't occur.
For example, text -> number could automatically convert the text value "12".
However, if the text value was "23 and a half", then the conversion wouldn't occur, the field would be left as-is, and therefore a warning would be shown as the field isn't in-sync with the template. The user could then choose the best course of action.

Overall, this would be a big change, but i feel like it would make using Koillection and keeping the data in a consistent shape much easier.
It also wouldn't make Koillection any less flexible (items can still be bound to no templates, leaving full freedom as to which fields they contain. And even when bound to a template, it isn't strictly enforced).

It's a feature i would reallly like to see added, so i wouldn't mind working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant