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
Allow configuring uniqueness rules #4215
Conversation
At the moment, I am unable to recreate this issue. I will keep an eye open for it, but let me know if other @specify/ux-testing can recreate it.
I have went ahead and gone through with the change as requested in #4215 (review) and moved the Add Uniqueness Rule button to be in-line with the other Dialog Buttons. Let me know what you all think of the change. |
Uniqueness Rules explicitly scoped to a scoping hierarchy above discipline will now be "global". This means that it will appear in every discipline's uniqueness rules (changes to the rule while in one discipline will apply to all disciplines, unless the rule is "de-elevated" from global status by changing its scope to be in the discipline or below, in which case the rule will be set to that discipline). To expand on what I mean by "explicitly scoped": any rule that is scoped to the Database, or whose scope traverses through either division or institution. (For example, this means the scope Currently there is no distinction in the UI between "Global" rules and "Discipline" rules, although I assume that would be a desired feature. |
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.
Global uniqueness rules do seem to be working and I like the placement of the add uniqueness rules button so that looks good.
Problem though is that I was able to recreate the issue Carlos mentioned.
OK, the issue is now fixed |
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.
Looks good, all issues I found seem to be fixed and I'm not getting any more errors. Good job!
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.
I think there might be a way to improve the UI as the mapper is not the most effective way to represent the selected item for the scope.
Current
Request
Suggestions:
- Use the WorkBench or Query Builder in-line mapper instead of the full mapping interface that shows more information than necessary
- Move the 'Add' button after the field picker in the same div
- Remove the redundant explainer at the bottom and only display that in the 'Scope; column when viewed in grid view
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.
I think there might be a way to improve the UI as the mapper is not the most effective way to represent the selected item for the scope.
Current
Request
Suggestions:
- Use the WorkBench or Query Builder in-line mapper instead of the full mapping interface that shows more information than necessary
- Move the 'Add' button after the field picker in the same div
- Remove the redundant explainer at the bottom and only display that in the 'Scope; column when viewed in grid view
Some (small) changes have been made:
I agree, that proposal to use a single in-line mapper does look far cleaner than the current approach of using the full mapper. However, given the urgency for this release I would suggest a feature request Issue be made and this be implemented in the future. |
The suggested changes have since been made or addressed
Implements #2712
Uniqueness Rules can be configured from the Schema Config, currently found under the Table Aggregation option for a table's Schema Configuration:
The interface is table/grid-like.
Rules which are defined as constraints on the database level, and thus should not be editable, have all components disabled and remain visible.
Each rule is split into 'groups': the 'fields' and the 'scope'.
The 'fields' represent the values which must be unique in a particular scope.
For example, on CollectionObject there is a rule which has catalogNumber as a unique field and Collection as a scope. Thus, there must be a unique catalogNumber within a Collection.
If a rule is editable, it can be "expanded" to add and/or remove individual unique fields, or delete it from the table's uniqueness rules
The Uniqueness Rules have live validation: this is, after every edit to a specific rule, Specify checks to make sure there are no records violating that rule.
If violating records are found, saving the edited Uniqueness Rules is prevented and the option to export all found duplicate values (to a CSV format) for the given fields and scope is presented.
Preferably, an embedded QueryBuilder would be utilized in this case, but it is not currently possible to achieve every Query as needed and thus the export is a necessity.
The rules are only 'committed' to the database once the Save button is clicked.
Changes are lost if the Uniqueness Rule dialog is closed or navigated away from before the changes have been Saved.
At the database level, these are implemented in two django migrations from the
businessrules
app: