-
Notifications
You must be signed in to change notification settings - Fork 36
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
Set default cotype on the frontend #5224
Conversation
Hmm, this breaks a couple of resource api tests which doesn't sound good specify7/specifyweb/frontend/js_src/lib/components/DataModel/__tests__/resourceApi.test.ts Lines 201 to 219 in 1419cd7
|
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.
Had to do some workarounds here to get the tests working. Lots of tests involving CO don't have a linked CollectionObjectType or a linked Collection -> CollectionObjectType
. Some tests used data from static test files, which I have updated to include Collection/Cotype.
Let me know if there's a better way to do any of these.
specifyweb/frontend/js_src/lib/components/DataModel/__tests__/resourceApi.test.ts
Outdated
Show resolved
Hide resolved
specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts
Outdated
Show resolved
Hide resolved
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.
Testing instructions
- Go to Data Entry -> Collection Object
- Verify the default CoType on the form is same as the Collection's CoType
This does work but I am a little confused about the query behavior. When querying with cot as the base table it works as I expect showing the 2 cot I made in this collection, but when querying with collection as the base table cot is formatted and only shows the default. Since we added the ability to create multiple cot shouldn't it be aggregated when collection is the base table?
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.
Testing instructions
- Go to Data Entry -> Collection Object
- Verify the default CoType on the form is same as the Collection's CoType
I have the same concerns as #5224 (review), but it works!
@emenslin That does look strange. I think it's happening because each collection record in the db gets linked to only one collectionObjectType (the default one) and so using collection as the base table only shows the defaults. Not sure if that can be changed unless we change the schema |
The issue is that the schema caption for the default COT relationship field should clarify this. Currently, it appears ambiguous, suggesting there is only one COT in the collection. |
Yep, if I remember correctly the |
I agree that the schema caption could be clearer. We can make that change as a part of #5290 |
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.
This implementation works, but maybe it would be worth changing businessrules a little (in this case specifcially for customInit
rules) so we can await businessRuleManager.pendingPromise
instead of await new Promise(process.nextTick)
in tests.
Also, maybe it'd be worth just including the Collection -> CollectionObjectType in a domain context call so we can synchronously access the collection's default CollectionObjectType wherever the schema has already been fetched.
This would save a lot of calls to the backend, and be significantly faster from the user's perspective.
More information in my comments!
specifyweb/frontend/js_src/lib/components/DataModel/__tests__/resourceApi.test.ts
Outdated
Show resolved
Hide resolved
specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts
Outdated
Show resolved
Hide resolved
specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts
Outdated
Show resolved
Hide resolved
specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts
Outdated
Show resolved
Hide resolved
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! Take a look at my recent changes.
Instead of just returning the ID of the CollectionObjectType in the /context/domain.json
endpoint, I thought it might be easier if we just directly format it as the the api uri.
I updated the static /context/domain.json
endpoint for the frontend tests to include the defaultCollectionObjectType
property.
I also realized we weren't using a LOT of the static files in the */tests/fixtures/
directory, so I removed all the files which are unused.
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.
Testing instructions
- Go to Data Entry -> Collection Object
- Verify the default CoType on the form is same as the Collection's CoType
Looks good!
Fixes #5223
Checklist
and self-explanatory (or properly documented)
Testing instructions