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

Update default form definitions for Geo #5367

Draft
wants to merge 50 commits into
base: production
Choose a base branch
from

Conversation

grantfitzsimmons
Copy link
Member

@grantfitzsimmons grantfitzsimmons commented Nov 1, 2024

Fixes #5311, #5073, #3120, #2153, #1515, #584, #364, specify/specify6#1210, specify/specify6#1213, specify/specify6#1229, specify/specify6#1232, #4591, #5020, #2016 and specify/specify6#1223

This PR is intended to update underlying app resources necessary for the geology discipline as well as improve other defaults where possible.

Geo-focused Improvements

CollectionObject form for Geology

image image

Common Views

RelativeAge

image

Added AbsoluteAge form

image

Added TectonicUnit form

image

Added TectonicUnitTreeDef form

image

Added TectonicUnitTreeDefItem form

image

Major Improvements

Type Searches

  • You can now search for Collection, Institution, and SpecifyUser, improving a number of places around the app!
  • Instructions for users modifying this file are now included in the app resource itself

Record Sets

image
  • You can now transfer ownership of a record set to another user!

Agent

Screen.Recording.2024-11-07.at.9.56.15.AM.mov
  • Person is now the default value (huge improvement)
  • Only when the Agent is type Group will the members subview display
  • Agent Identifiers now displays properly, and subview is included on the default form

Taxon

hybridFieldsConditional.mov
  • Form is now conditional, displaying HybridParent fields only when IsHybrid is checked

Collection Relationships

Old form:

image

New form:

image
  • Can now easily create a Collection Relationship via the form
  • Using the updated TypeSearches, "Collection" can be searched and displayed properly

App Resources

AppResource

image

Reports

image
  • You can now easily find who owns the query and what the query is named from the app resource editor for a given report or label!
  • The Reports subview button only appears when the mimetype is jrxml/label
  • New SpReport form for the first time

SpViewSetObj

image

Pick List

Old form:

image

New form:

image
  • Removed redundant header
  • Now users can remove the pick list limit by setting it to -1

Tree Definition

Old Tree Definition form:

image

New Tree Definition form:

image
  • Can now change full name direction for all trees

Miscellaneous Improvements

  • Preparation countAmt can no longer be set to a negative number by default
  • Default form definition files and DataObjFormatters have finally been reformatted by the built-in Specify 7 system
  • Removed a number of invalid fields on all default forms
  • Updated hard-coded field labels to use schema-assigned captions instead

Testing instructions

THIS MUST BE TESTED LOCALLY UNTIL THE TEST PANEL SUPPORTS STATIC FILES

Okay, so this PR is big, but it is almost entirely XML changes. This touches a lot of the default forms, so I have a big ask– please test the following XML resources in Specify. You are likely to find issues that aren't related to this PR which I am happy to resolve, so report them. If it grows outside the scope of this, I'll open another and we'll resolve it in the future.

Remember to delete any custom form definitions / app resources before testing this as those will be used first.

  • Create a new DataObjFormatters app resource and verify that all table formats and aggregations appear as expected
  • Build queries and return the (formatted) and (aggregated) results of as many tables as you can, with a focus on new Geo tables. If a table format or aggregation is missing where it should be included, let me know. Some tables (e.g. *property, *attribute, *groupjoin) do not have a table format or aggregation defined as it is ambiguous as to which fields we should display.
  • Create a new TypeSearches app resource and verify that it is working as expected. Delete this resource after it is populated as you should be using the default.
  • Open the CollectionRelType form and search for a collection. You should be able to type the name of a collection and select it. You will encounter HierarchyException when loading Collectionreltype #4989, but that is not in the scope of this issue, and you can safely dismiss it.
  • Create an ExportFeed app resource and verify that you can search for a user in the database by name. You should see the name appear correctly and you should be able to search for a user in the query combo box without the 🔍 QB function.
  • Create a new WebLinks app resource and verify that all web links (~5) appear and work as expected. See this guide for setting up a conditional form on AgentIdentifier to leverage those new web links.
  • Verify that the geology.views.xml can be used as the basis of a new form (create a new form definition and select Geology). Let me know what you think. This is subjective to some extent, and I welcome suggested changes (especially via XML snippets).
  • Test that these new view definitions (mostly shown in this issue's body) are displayed properly (compare to defaults on production):
    • CollectionRelType
      • Verify that you can create a Collection Relationship without the query builder (ignoring this error)
    • Agent should default to Person instead of Organization finally!
      • Agent conditional: If the agent is not a Group, the Members subview should not be shown.
    • TectonicUnit
    • TectonicUnitTreeDef
    • TectonicUnitTreeDefItem
    • TaxonTreeDef
    • Taxon
      • Taxon conditional: Verify that when you check IsHybrid the fields HybridParent1 and HybridParent2 appear. When it is not checked, they should not appear.
    • GeographyTreeDef
    • StroageTreeDef
    • LithoStratTreeDef
    • GeologicTimePeriodTreeDef
    • RelativeAge
    • AbsoluteAge
    • PickList
      • Set the size limit to -1 and verify that you can add any number of pick list items (>500– and you can use the workbench to add the first 500)
    • PickListItem
    • SpAppResource (click pencil next to the title of an app resource)
      • SpAppResource conditional (should show Reports subview button if the resource is a report/label)
        • SpReport form should show ownership, associated query, title, in a read-only view
    • SpViewSetObj (click pencil next to the title of a form definition)
    • SpQuery (click pencil next to a query title)
      • Verify that you can change the ownership of a query
    • RecordSet (click pencil next to a record set title)
      • Verify that you can change the ownership of a record set
    • AgentIdentifier – navigate directly to the form via the data entry menu or by modifying the URL. It should no longer be auto-generated

Restructures common.views.xml for the first time in years based on the linting done by Specify 7

Fixes #5311
@grantfitzsimmons grantfitzsimmons added the 2 - Forms Issues that are related to the form system label Nov 1, 2024
@grantfitzsimmons grantfitzsimmons added this to the 7.9.8 milestone Nov 1, 2024
@CarolineDenis CarolineDenis modified the milestones: 7.9.8, 7.9.9 Nov 6, 2024
@grantfitzsimmons grantfitzsimmons marked this pull request as ready for review November 6, 2024 20:29
@grantfitzsimmons grantfitzsimmons marked this pull request as draft November 6, 2024 20:29
Fixes #2153
@grantfitzsimmons grantfitzsimmons linked an issue Nov 6, 2024 that may be closed by this pull request
Removes `FishBase` and `WEBLINK`, adds `ORCID`, `Bionomia`, and `Wikidata`
Removes autogenereated forms for SpecifyUser, CollectionRelType, and SpViewSetObj
Also enables users to transfer ownership of a record set
Triggered by 5727f70 on branch refs/heads/issue-5311
I want to show only the name of the resource when a new one is created
@melton-jason
Copy link
Contributor

melton-jason commented Nov 8, 2024

Haven't gone through all of the changes yet, but really nice so far!


The ideal fix would be to modify the default views, but since that can not occur until we separate from Specify 6, thankfully there seems to be enough consistency in cases for which this issue can be resolved

From #4760 (comment)

Now we can properly resolve this! 🥳

I've left a full breakdown of the Issue in the aforementioned comment (#4760 (comment)), but the important part in relation to this PR is the following:

In the default forms, it seems there are two separate ways to represent a FormTable.

The first and expected way is the case like Preparation, in which the Grid and Form view definitions are defined in a single view.

The other way which is present is to have two separate views, where each view and their view definitions separately represent the Grid and Form views in the form.

Specifically, the table-only views contain viewdefs which are not listed as altviews of the view and are only referenced through the formtable viewdef.

This causes a problem in Specify 7 which expects all view definitions relating to a view to be associated with the view and not split amongst multiple views.

It'd be great if we can go through and merge these separate views for the collapsed version of the Subview with the expanded "normal" views!

We already have a list of viewnames in the following commit: 5c91a89
(Which was recorded in #4737 (comment))

Which exist at the following locations:

View Name File Path
Authors backstop/global.views.xml
GroupPersons backstop/global.views.xml
Collectors common/common.views.xml
CollectionObjectSubTable common/common.views.xml
ContainerBriefTable common/common.views.xml
Determiners common/common.views.xml
Extractors common/common.views.xml
FundingAgents common/common.views.xml
PcrPersons common/common.views.xml

Specifically: for each of these views, we need to add the formtable viewdefs to the altviews of the main table's view (specifically, the table.view as specified in the datamodel. Which is [almost?] always just the table name).
Essentially, align the views with how a view like Preparation is defined.

I can make these changes if needed!

Related lines of code:

// REFACTOR: remove this once Specify 7 gets default forms
/**
* If `defaulttype` is not specified on a subview cell, Specify assumes the
* subview should be rendered in 'Form' mode. However there are many default
* `to-many` subviews which do not specify a `defaulttype` and should be
* rendered as a table by default
*
* See https://github.com/specify/specify7/issues/4878
*/
readonly defaultSubviewFormType?: FormType;

/**
* In the default forms for Specify 6, there are multiple ways to represent
* FormTables for SubViews.
* One problematic way to represent the Expanded and Collapsed
* states of the SubView is to separate the states into entirely
* separate views. If the Collapsed view needs to be expanded, it is assumed
* to use the view definition for the Expanded view
* (which is usually the default view as stated in the datamodel xml file,
* i.e. the table.view)
* See:
* https://github.com/specify/specify7/issues/2412#issuecomment-1327967090
* https://github.com/specify/specify7/pull/4760#issuecomment-2046022176
*/
const useDefaultExpanded =
new Set(Object.values(view.altviews).map((altView) => altView.viewdef))
.size === 1 &&
getAttribute(
xmlToJson(viewDefinitions[Object.values(view.altviews)[0].viewdef]),
'type'
) === 'formtable';
if (useDefaultExpanded) {
/**
* To correctly resolve this case, the non-formtable altviews and viewdefs
* of the table's default View are merged into the definition of the
* view which is supposed to represent the Collapsed/Grid view for the
* table
*/
return fetchView(strictGetTable(view.class).view).then(
(defaultExpandedDefinition) => {
if (defaultExpandedDefinition === undefined) return view;
const defaultViewDefs = parseViewDefinitions(
defaultExpandedDefinition.viewdefs
);
const newAltViews = {
...view.altviews,
...Object.fromEntries(
Object.entries(defaultExpandedDefinition.altviews).filter(
([_, { viewdef }]) =>
getAttribute(xmlToJson(defaultViewDefs[viewdef]), 'type') !==
'formtable'
)
),
};
const newViewDefs = {
...view.viewdefs,
...Object.fromEntries(
Object.entries(defaultExpandedDefinition.viewdefs).filter(
// eslint-disable-next-line unicorn/prevent-abbreviations
([viewDefName, _]) =>
getAttribute(
xmlToJson(defaultViewDefs[viewDefName]),
'type'
) !== 'formtable'
)
),
};
overwriteReadOnly(view, 'defaultSubviewFormType', 'formTable');
overwriteReadOnly(view, 'altviews', newAltViews);
overwriteReadOnly(view, 'viewdefs', newViewDefs);
return view;
}
);
}

@CarolineDenis CarolineDenis requested review from sharadsw and a team November 15, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment