Skip to content

Enable copying an existing species' taxonomy when creating new species, and add a taxonomy check #834

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

Open
wants to merge 56 commits into
base: main
Choose a base branch
from

Conversation

juhanikat
Copy link
Collaborator

@juhanikat juhanikat commented Jun 2, 2025

Made another PR since I accidentally did some git magic with the previous one (#759).

@juhanikat juhanikat changed the title Copy species taxonomy Enable copying an existing species' taxonomy when creating new species, and add a taxonomy check Jun 2, 2025
@karilint karilint requested review from Copilot and karilint June 4, 2025 06:44
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables copying an existing species’ taxonomy when creating a new species and adds a client‐side taxonomy consistency check before saving. Key changes include validator enhancements, new taxonomy utilities, UI updates to the taxonomy tab, integration of the taxonomy check in the save flow, and extensive test updates.

  • Added checkTaxonomy and convertTaxonomyFields to enforce and normalize taxonomy data.
  • Updated WriteButton and DetailView to run taxonomy validation before write.
  • Enhanced TaxonomyTab with a “Copy existing taxonomy” button and trimming options in text fields.
  • Expanded E2E tests to cover taxonomy rules and trimming behavior.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
shared/validators/species.ts Added species‐level validation rules for genus, species, order, family, and unique identifier.
redux/speciesReducer.ts Exported useLazyGetAllSpeciesQuery for taxonomy checks.
components/Species/taxonomyFunctions.tsx Introduced checkTaxonomy and convertTaxonomyFields.
components/Species/Tabs/TaxonomyTab.tsx Added copy button, trimming options, and updated classification layout.
components/Species/SpeciesDetails.tsx Passed new taxonomy prop to DetailView.
components/Notification.tsx Allowed multi‐line alert messages with whiteSpace: 'pre-line'.
components/DetailView/common/editingComponents.tsx Added trim option and onBlur trimming to EditableTextField.
components/DetailView/common/SelectingTable.tsx Added buttonTooltip prop; adjusted modal invocation.
components/DetailView/common/EditingModal.tsx Wrapped modal button in tooltip when provided.
components/DetailView/components.tsx Integrated taxonomy flag and utilities into save button logic.
frontend/src/common.tsx Defined smallSpeciesTableColumns for species selection.
documentation/.../EditableTextField.md Documented new trim option.
cypress/e2e/species.cy.js Extended tests for copying taxonomy and validation rules.
Comments suppressed due to low confidence (3)

frontend/src/shared/validators/species.ts:4

  • The function name isEmptyUniqIdentifier uses an inconsistent abbreviation (Uniq). Rename to isEmptyUniqueIdentifier for clarity and consistency.
const isEmptyUniqIdentifier = (unique_identifier: string) => {

frontend/src/common.tsx:144

  • [nitpick] Header text capitalization is inconsistent ('Taxon status'). Consider changing to 'Taxon Status' or 'Taxonomic Status' to match title‐case style used elsewhere.
    header: 'Taxon status',

frontend/src/components/DetailView/common/SelectingTable.tsx:72

  • You’ve added buttonTooltip, but the dataCy prop is no longer forwarded to EditingModal, potentially breaking test selectors. Pass dataCy through to maintain the data-cy attribute on the button.
<EditingModal buttonText={buttonText} buttonTooltip={buttonTooltip}>

Copy link
Contributor

@karilint karilint left a comment

Choose a reason for hiding this comment

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

Select an existing species as the source to copy taxonomy from.
- there is +New button on the selection list which in this case is odd
- after selecting the species by pressing the + button, the window could be closed right away instead of pressing the Close button.
- I could create duplicates for Canis aureus, Canis lupus, Alopex lagopus for the first time, but not for the second time.
- the species should always be lower case, genus and others lower case with capital first letter (but see next)
- lower case: fam., gen., sp., indet., incertae sedis
- dot at the end: fam->fam., gen->gen., sp->sp., indet->indet.
- incertaesedis->incertae sedis
- NEW: while creating a new taxon, check also the existing synonyms for duplicates (Rhinoceros mercki is a synonym of Stephanorhinus kirchbergensis)

Create a new entry and set the Order or Family field to “Incertae sedis”
System should allow this entry, even if taxonomic parent fields are missing or unconstrained
- try adding genus New into Carnivora and set Family field to “Incertae sedis”
- I get Family Incertae sedis belongs to order Sparassodonta, not Carnivora.

NEW: Try to enter a new species (e.g., Crocuta yangula which is imagenary taxon), where the same subspecies name already exists as a species-level entry in the same genus (e.g., Crocuta crocuta yangula)
System should warn or block the entry, highlighting the duplicate at the species level in the same genus.
- I could add Crocuta yangula but did not enter it

@juhanikat
Copy link
Collaborator Author

Thank you!

  • "New" button has been removed.
  • Closing the window after the + button as been pressed would be much better but is not straightforward to implement, I will look into it before publishing this PR.
  • I could not create duplicate species for Canis aureus, Canis lupus or Alopex lagopus, you might have an outdated version of the branch? This was an issue before but should be fixed now.
  • All taxonomy fields should now be automatically converted to proper format (capitalized/uppercased/lowercased).
  • Should the user be allowed to enter values such as "gen", "indet" and "incertaesedis", which would be accepted but automatically converted to "gen.", "indet." and "incertae sedis"? Currently those values must be typed properly, otherwise they are treated like any other normal value.

The other things you mentioned are still a work in progress.

@karilint
Copy link
Contributor

Indet without a dot has the taxonomy check. Indet should be --> indet.
See Genus Indet belongs to family Nyanzapithecidae, not Canidae.

Copy species data from Eucladoceros/megaloceros giullii/savinii. The system allows saving a duplicate after the "informal species" is selected.

@juhanikat
Copy link
Collaborator Author

  1. "Indet" and "indet" (without the dot) are currently treated as normal taxonomic values, for some reason the database contains some species which have this value and so it is treated as an existing family (these should probably be manually changed to "indet."). The automatic conversion from indet --> indet. will be done in another PR in the future.
  2. The automatic capitalization had some issues with the slash (/) which broke the duplicate checking, this should be fixed now.

@juhanikat juhanikat marked this pull request as ready for review June 17, 2025 09:40
@karilint
Copy link
Contributor

When I edit a species that belongs to the family Nyanzapithecidae, I receive an error: "Family Nyanzapithecidae belongs to suborder Euprimates, not Hominoidea." If I edit the suborder to "Euprimates", I get an error "Family Nyanzapithecidae belongs to suborder Hominoidea, not Euprimates." This must be due to the database contents, which include Nyanzapithecidae that belong to both suborders, Euprimates and Hominoidea. This could be informed to the user with a message "This taxon has several entries for suborder [or order, family,...]: item1, item2" followed by
"Please contact the NOW administration to fix this taxonomy" <-- This is for users with limited user rights (we'll decide it later)
"Continue with the edit by using this taxonomy", add a button for this. <-- This is for admin users and users with unrestricted user rights (we'll decide it later)

@juhanikat
Copy link
Collaborator Author

The taxonomy check now notifies the user if the database contains multiple different parent values for the taxonomy field they are editing, and does not let them edit the entry. There are no tests for this at the moment, and the "continue with edit" button needs to be implemented later, possibly in another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants