-
Notifications
You must be signed in to change notification settings - Fork 51
Fix the "Remove" button on field widgets #1958
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
laceysanderson
approved these changes
Sep 9, 2024
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.
✅ Code looks good. There is an assumption that there will be a record_id and a field_name element in the widget but I just documented it.
✅ Manual testing was successful. I tested the following situations:
- deleted the last/only linker record
- deleted by emptying the element
- deleted by clicking the remove button
- removed multiple entries in different fields in the same save
- removed an entry with the remove button and then added one in the same page load
- created multiple property fields with the same values and removed some values from each field but not the same ones to ensure there was no cross over. Checked where the value was the same and checked delta-wise as well.
- checked on genetic marker and study
- checked multiple different fields
- confirmed after each save that the database underneath matched my expectations
- confirmed nothing removed came back after publish
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Group 1 - Tripal Content Types | Terms | Fields
Any issue relating to Tripal Content including types, terms, and fields.
Group 2 - Data Storage | Tripal DBX | Chado
Any issue relating to biological data storage, Tripal DBX and Chado integration, Materialized Views
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug Fix
Closes #1920
Depends on #1921 (Merged)
Tripal Version: 4.x
Description
When editing an entity, the "Remove" button will remove a linked entity (e.g. remove analysis from project) in the Drupal table, but does not delete it from the underlying chado linker table. If instead it is changed to -- Select -- then it is removed from both the Drupal and Chado tables. This is because the "Remove" button removes the item from the form state so then Chado storage doesn't know it existed and doesn't know to delete it in Chado.
To resolve this problem, I am storing a few values in the form state on the very first creation of the form,
and then in the
massageFormValues()function, we can check for records that were there when the form was first built, but have been eliminated since. If that is the case, then put a reference in the$valuesarray which will inform chado storage to delete the record in chado.This problem will exist only for fields which support cardinality greater than one. Fields that need the fix:
These will probably be different
Changes not needed because cardinality is always 1
Testing?
(We need PR #1921 merged into this branch to test)mergeddrush trp-run-jobs --username=drupaladmin --root=/var/www/drupal/webgit checkout tv4g1-issue1920-fix-remove-buttondrush updatedbCreate three contacts
Create an organism
Create a "Genetic Marker", and a) link all of the contacts, b) add some "Database Reference Annotations", c) add some synonyms, and save.

Edit the Genetic Marker you created. Click the "Remove" button for one of the contacts, select "-- Select --" for another, then save.

Contacts deleted using either of these methods should no longer appear on the entity.

The two contacts should also be removed from the
project_contacttable and only one should remain - This is what was not happening before.feature_synonymtable.feature_dbxreftable.select * from featureprop FP left join cvterm T on FP.type_id=T.cvterm_id where FP.feature_id = (select feature_id from feature where name='PAU8');