luomus / laji-api

New LajiApi, still in prototype phase
MIT License
0 stars 0 forks source link

Move form permissions controlling to collections #13

Open olzraiti opened 1 week ago

olzraiti commented 1 week ago

Currently form permissions are controlled with MHL.restrictAccess and MHL.hasAdmins properties of the forms.

This is a design flaw, as there can be multiple forms with the same collectionID. Currently it works so that if one of the forms has the option, then all the other forms with the same collectionID use the option. The forms also inherit the options (restrictAccess & hasAdmins). This works technically OK without risk of conflict, but the logic is very hard to follow for human minds.

It's especially difficult to follow the logic because there are two options, which could be defined for different forms of the same collectionID, and the inheritance must be checked for both options...

Also, the permissions are fetched by collectionID anyway which implies that it would be much clear if the permissions were tied directly to the collections instead of the forms. There are 1...n forms per collection, makes no sense that it's possible to define the permission n times - should be only one time.

More understandable solution would be to define the form permission options for the collections themselves.

olzraiti commented 4 days ago

I added the label bw-breaking-refactoring, which makes doing this a requirement for API v1. It might be too costly to implement - let's review later.

olzraiti commented 2 days ago

Also MHL.secondaryCopy would make more sense to be a collection's property. Now it would be possible to have two forms for the same collection, other one saving the data to store (primary) and other straight to warehouse (secondary), which doesn't make sense.