-
Notifications
You must be signed in to change notification settings - Fork 49
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
New base table third party setting + Drupal 10.2 fixes #1805
Conversation
To fix the schema incomplete failures you will want to add the third party setting to the schema. Since the content type is defined in the Tripal module and this is chado specific you need to use the tripal_chado_config_schema_info_alter hook in the tripal_chado.module file to alter the schema.
|
I have implemented the "Quick Fix" with commit 01c081f and When I did this, I could proceed, and discovered that the ajax was broken under Drupal 10.2. A few fields are still broken when adding to a newly defined content type, but as Lacey said, there is a lot in this PR already so I will create a new issue for this, issue #1817 And probably a separate new issue would be to provide a way to define the base table when creating a new content type, this will make a site admin's job easier as it doesn't have to be selected over and over for each new field added. Issue #1818 |
I think we should fix this. If we don't require that a field's base table matches the one for the content type then you could get a bunch of fields referencing differnet tables, which will then cause problems if some one wants to "check for new fields". |
Perhaps the solution is that if the contnet type doesn't have a base table set, then when the first Chado field is added then it will set the base table for the content type. Then all others added later must match the base table of the content type. Also , I think our implementations of the |
AS per additional conversation with @laceysanderson on this last comment (on Slack) i'm working on the fix. |
Okay, I've added a fix that sets the base table on a content type automatically when the first Chado field is added. However, I'm really confused by the code that adjust the base table drop down. @dsenalik I think you need to look at it to see what's wrong. Here's the problem.
|
On Drupal 10.2 I created a library content type. First field I used Chado String Type and the The fix I made was for the error I will build a 10.1 docker to test there too |
You get this error under Drupal 10.1 Your new hook unfortunately needs to know how to handle both drupal versions it seems. The fix is not as easy as I hoped. In
so I could do this but then there is the check for entity type, which we cannot do from
If I just take out the entity type check it works under Drupal 10.1.
But I don't understand whether we need that or not. |
I think we don't need the check for tripal entity, because the check for the |
Thanks for doing all that cleanup work. It's unfortunate that the form_id's change as well as the form structure :-/ |
Thanks! If that's the case, I just pushed changes a4bc925 which should fix it for Drupal 10.1 |
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.
Ok, I retested and everything looks great except for a small hiccup on D10.0 regarding unsupported fields (see more below).
Task | D10.2/PHP8.3 | D10.1 (Doug) | D10.0/PHP8.2 |
---|---|---|---|
Add Chado Text field to existing content type | ✅ | ✅ | |
Add Chado Property field to existing content type | ✅ | ✅ | |
Add Chado Analysis field to existing content type | ✅ | ✅ | |
Unable to add unsupported field to content type | ✅ | ❌ | ❌ |
Add Chado Text field to new content type | ✅ | ✅ | |
Add Chado Dbxref field to a new content type | ✅ | ✅ | |
Unable to add unsupported field to content type | ✅ | ❌ | ❌ |
D10.0 ONLY, Unsupported fields bug
On Drupal 10.0 ONLY, if you try to add an unsupported field you will experience the following:
- You do get an error that the field is unsupported
- When you go back to the field listing though the unsupported field was added anyway and is in the listing 👿
- When you try to edit the unsupported field, again you get the message about it being unsupported and cannot set any details
- If you try to create content of that type, it will now fail as chado storage sees that unsupported field and adds it to the verification code 🙈
For example, I added a sequence checksum field on the existing project content type. When creating a project I now get errors about not having an organism, type, etc 😭
For Drupal ≤ 10.1 this is the point at which the field comes into existence, this is the form prior to where we check compatibility. Ideally, if the field is detected as not compatible in the next form, we would then have to also remove the field.
|
Co-authored-by: Lacey-Anne Sanderson <[email protected]>
Co-authored-by: Lacey-Anne Sanderson <[email protected]>
I just pushed a commit that adds a function to "clean up" when an incompatible field is added under Drupal ≤10.1 😀 |
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.
Works perfectly now! I just tested again on Drupal 10.2 and Drupal 10.1. I specifically tested one unsupported field and one supported field on an existing content type.
Thanks @spficklin and @dsenalik for all the work on this one!!! ❤️
New Feature + Bug Fix
Closes #1440
Closes #1791
Closes #1818
Tripal Version: 4.x
Description
Because they are so intertwined, this PR does several things:
is_compatible()
function that fields will implement a way to know what fields can be added to a particular content type.To quote @laceysanderson : "In Drupal 10.2 the UI for adding custom fields has changed quite a lot.
This is happening because in Drupal 10.2 the field settings and field storage settings have each become subforms and then been merged into a single form page. This means that where we originally were given the full form state, now we are given a subformstate which only has the values specific to our subform in it."
Drupal reference: https://www.drupal.org/node/3386675
This PR will replace Fixes for the new Drupal 10.2 subform #1795
Testing?
Test on BOTH Drupal 10.1 and 10.2:
Test a base column form element by adding a Chado Text Field Type, e.g. to project
You might notice that under 10.2 you can also see the description, so I took the opportunity to make the distinction between Text and String clear (I always seem to forget which is which)
The new third party setting will allow the field to know that the base table is
project
, so the selector should be pre-populated and grayed out. The "Table Column" should be populated with the only valid choice, "Description"Select any CV Term - this is a two-form process under 10.1, but now all on the same form in 10.2
Save and verify the field looks good.
Go back to view with Edit and make sure everything is still there
Test the property form by adding a Chado Property to e.g. pub. The base table selector will again be grayed out.
Use whatever CV term you like
Test the linking table form element by adding a Chado Contact field to e.g. project.
The CV term should not need to be entered for this one.
Test the linking table form element by adding an Analysis field to e.g. project.
In this case there is no default CV term so you will need to specify one.
Test the Chado Database Cross Reference field
Remove the original "Description", "Contact", and "Dbxref" (Database reference annotation) fields, we are going to test the ones we just added.
Create some content. First create a "contact", and then an "analysis".
Create a project and use this contact, fill in a description, your property, your analysis, and any dbxref value.
Other fields to test: Chado Type Reference (ChadoAdditionalTypeDefault) (e.g. on organism, pub, contact, or protocol)
Chado Synonym (on any feature table derived content, e.g. gene)
Chado Unit (on featuremap types only, Genetic Map or Physical Map)
Try to add a field that is wrong for the content type, e.g. put the Chado Unit field on a publication. Or consult the big linker table Expanding Tripal 4 Fields documentation tripal_doc#32 (comment) and find a blank cell, e.g. try to put the Feature field on a Study. (Sometimes there is an obscure linking table e.g. Contact on an Analysis through the quantification table, but that is not by default a content type)