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

Don't trigger unload protect when initializing resources #3774

Merged
merged 2 commits into from Jul 18, 2023

Conversation

melton-jason
Copy link
Contributor

Addresses #3259 (comment)

This was caused because of changes related to Business Rules.
Beforehand, we were not triggering the Backbone change event for business rules while the resource was being fetched or saved by Backbone. I have restored this functionality.

This has probably not solved the underlying cause of #3259 in its entirety, but should prevent business rules from triggering unload protect while the record is being loaded.

To test:
Navigate to an existing Determination record which has taxon data.
The Save Button should be disabled, and when navigating away from the Determination in a record set, the unload protect dialog should not be displayed.

@melton-jason melton-jason requested review from CarolineDenis and a team July 12, 2023 20:00
@melton-jason
Copy link
Contributor Author

melton-jason commented Jul 12, 2023

@CarolineDenis
I should've separated the formatting of resourceApi.js into its own commit 🤦

Here are the lines in resourceApi.js related to this fix:
https://github.com/specify/specify7/pull/3774/files#diff-2f5423edccb3536d3e2c4fedda8f2513a4827fb943cbd51eb5536835f408f460R80-R87

Copy link
Member

@maxpatiiuk maxpatiiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's helpful, but you can make a field change not trigger a save blocker by adding silent: true:

? void resource.set('isAccepted', true, { silent: true })

@melton-jason
Copy link
Contributor Author

Not sure if it's helpful, but you can make a field change not trigger a save blocker by adding silent: true:

? void resource.set('isAccepted', true, { silent: true })

This was the very first thing I tried, but does not quite cover every case.
The resource was still triggering the change event when we were setting a many-to-one field (specifically, setting preferredTaxon on Determination).
The following lines of code was the culprit:

field.isDependent() && this.storeDependent(field, toOne);
this.trigger(`change:${ fieldName}`, this);
this.trigger('change', this);
return toOne.url();

@melton-jason melton-jason linked an issue Jul 14, 2023 that may be closed by this pull request
Copy link

@bronwyncombs bronwyncombs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working as expected. Can now navigate Browse in Forms from query builder and stats query without unload protect dialog.

Screen.Recording.2023-07-14.at.9.54.40.AM.mov
  • macOS, chrome, uoregonpaleo

@grantfitzsimmons
Copy link
Contributor

Let's merge this tomorrow.

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

Successfully merging this pull request may close these issues.

Unedited record triggering save button without any changes
5 participants