From 969b012f4097b492147ff77459bcff458d63c0aa Mon Sep 17 00:00:00 2001 From: alesan99 Date: Tue, 9 Dec 2025 15:16:25 -0600 Subject: [PATCH 01/12] Create discipline type picklist in migration --- .../0042_discipline_type_picklist.py | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 specifyweb/specify/migrations/0042_discipline_type_picklist.py diff --git a/specifyweb/specify/migrations/0042_discipline_type_picklist.py b/specifyweb/specify/migrations/0042_discipline_type_picklist.py new file mode 100644 index 00000000000..df51f742905 --- /dev/null +++ b/specifyweb/specify/migrations/0042_discipline_type_picklist.py @@ -0,0 +1,72 @@ +from django.db import migrations, models +import django.db.models.deletion + +DISCIPLINE_TYPE_PICKLIST_NAME = 'COGTypes' +# TODO: Build this from backend/context/app_resource.py +DISCIPLINE_TYPES = [ + { 'value': 'fish', 'label': 'Fish' }, + { 'value': 'herpetology', 'label': 'Herpetology' }, + { 'value': 'paleobotany', 'label': 'Paleobotany' }, + { 'value': 'invertpaleo', 'label': 'Invertebrate Paleontology' }, + { 'value': 'vertpaleo', 'label': 'Vertebrate Paleontology' }, + { 'value': 'bird', 'label': 'Bird' }, + { 'value': 'mammal', 'label': 'Mammal' }, + { 'value': 'insect', 'label': 'Insect' }, + { 'value': 'botany', 'label': 'Botany' }, + { 'value': 'invertebrate', 'label': 'Invertebrate' }, + { 'value': 'geology', 'label': 'Geology' }, +]; + +def create_discipline_type_picklist(apps): + Collection = apps.get_model('specify', 'Collection') + Picklist = apps.get_model('specify', 'Picklist') + Picklistitem = apps.get_model('specify', 'Picklistitem') + + # Create a discipline type picklist for each collection + for collection in Collection.objects.all(): + picklist, created = Picklist.objects.get_or_create( + name=DISCIPLINE_TYPE_PICKLIST_NAME, + type=1, + tablename='discipline', + collection=collection, + defaults={ + "issystem": True, + "readonly": True, + "sizelimit": -1, + "sorttype": 1, + } + ) + # If the picklist doesn't exist, create a new one + if created: + ordinal = 1 + items = [] + for type in DISCIPLINE_TYPES: + items.append( + Picklistitem( + picklist=picklist, + ordinal=ordinal, + value=type['value'], + title=type['label'], + ) + ) + ordinal += 1 + Picklistitem.objects.bulk_create(items) + +def revert_discipline_type_picklist(apps): + Picklist = apps.get_model('specify', 'Picklist') + + Picklist.objects.filter(name=DISCIPLINE_TYPE_PICKLIST_NAME).delete() + + +class Migration(migrations.Migration): + dependencies = [ + ('specify', '0041_add_missing_schema_after_reorganization'), + ] + + def apply_migration(apps, schema_editor): + create_discipline_type_picklist(apps) + + def revert_migration(apps, schema_editor): + revert_discipline_type_picklist(apps) + + operations = [] From 07ab4b715c3dd4086391fcec48d2ec10264e6a06 Mon Sep 17 00:00:00 2001 From: alesan99 Date: Tue, 9 Dec 2025 15:36:03 -0600 Subject: [PATCH 02/12] Remove unused modules --- specifyweb/specify/migrations/0042_discipline_type_picklist.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/specifyweb/specify/migrations/0042_discipline_type_picklist.py b/specifyweb/specify/migrations/0042_discipline_type_picklist.py index df51f742905..948240478e4 100644 --- a/specifyweb/specify/migrations/0042_discipline_type_picklist.py +++ b/specifyweb/specify/migrations/0042_discipline_type_picklist.py @@ -1,5 +1,4 @@ -from django.db import migrations, models -import django.db.models.deletion +from django.db import migrations DISCIPLINE_TYPE_PICKLIST_NAME = 'COGTypes' # TODO: Build this from backend/context/app_resource.py From b65326058959797c80a09e980abe49b3d55c5d2e Mon Sep 17 00:00:00 2001 From: alesan99 Date: Tue, 9 Dec 2025 15:39:01 -0600 Subject: [PATCH 03/12] Fix --- specifyweb/specify/migrations/0042_discipline_type_picklist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specifyweb/specify/migrations/0042_discipline_type_picklist.py b/specifyweb/specify/migrations/0042_discipline_type_picklist.py index 948240478e4..ecce09b0068 100644 --- a/specifyweb/specify/migrations/0042_discipline_type_picklist.py +++ b/specifyweb/specify/migrations/0042_discipline_type_picklist.py @@ -14,7 +14,7 @@ { 'value': 'botany', 'label': 'Botany' }, { 'value': 'invertebrate', 'label': 'Invertebrate' }, { 'value': 'geology', 'label': 'Geology' }, -]; +] def create_discipline_type_picklist(apps): Collection = apps.get_model('specify', 'Collection') From 6c4cd69f6c633a23ecb93115b68aa58d724b3518 Mon Sep 17 00:00:00 2001 From: alesan99 Date: Wed, 10 Dec 2025 08:51:50 -0600 Subject: [PATCH 04/12] Move DISCIPLINE_NAMES --- specifyweb/backend/context/app_resource.py | 13 ++++++++++++ .../0042_discipline_type_picklist.py | 21 ++++--------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/specifyweb/backend/context/app_resource.py b/specifyweb/backend/context/app_resource.py index ef01e17058b..5f6934e83a0 100644 --- a/specifyweb/backend/context/app_resource.py +++ b/specifyweb/backend/context/app_resource.py @@ -36,6 +36,19 @@ "invertebrate": "invertebrate", "geology": "geology", } +DISCIPLINE_NAMES = { + 'fish': 'Fish', + 'herpetology': 'Herpetology', + 'paleobotany': 'Paleobotany', + 'invertpaleo': 'Invertebrate Paleontology', + 'vertpaleo': 'Vertebrate Paleontology', + 'bird': 'Bird', + 'mammal': 'Mammal', + 'insect': 'Insect', + 'botany': 'Botany', + 'invertebrate': 'Invertebrate', + 'geology': 'Geology', +} FORM_RESOURCE_EXCLUDED_LST = [ "fish/fishbase.views.xml", diff --git a/specifyweb/specify/migrations/0042_discipline_type_picklist.py b/specifyweb/specify/migrations/0042_discipline_type_picklist.py index ecce09b0068..777c167b675 100644 --- a/specifyweb/specify/migrations/0042_discipline_type_picklist.py +++ b/specifyweb/specify/migrations/0042_discipline_type_picklist.py @@ -1,20 +1,7 @@ from django.db import migrations +from specifyweb.backend.context.app_resource import DISCIPLINE_NAMES DISCIPLINE_TYPE_PICKLIST_NAME = 'COGTypes' -# TODO: Build this from backend/context/app_resource.py -DISCIPLINE_TYPES = [ - { 'value': 'fish', 'label': 'Fish' }, - { 'value': 'herpetology', 'label': 'Herpetology' }, - { 'value': 'paleobotany', 'label': 'Paleobotany' }, - { 'value': 'invertpaleo', 'label': 'Invertebrate Paleontology' }, - { 'value': 'vertpaleo', 'label': 'Vertebrate Paleontology' }, - { 'value': 'bird', 'label': 'Bird' }, - { 'value': 'mammal', 'label': 'Mammal' }, - { 'value': 'insect', 'label': 'Insect' }, - { 'value': 'botany', 'label': 'Botany' }, - { 'value': 'invertebrate', 'label': 'Invertebrate' }, - { 'value': 'geology', 'label': 'Geology' }, -] def create_discipline_type_picklist(apps): Collection = apps.get_model('specify', 'Collection') @@ -39,13 +26,13 @@ def create_discipline_type_picklist(apps): if created: ordinal = 1 items = [] - for type in DISCIPLINE_TYPES: + for value, title in DISCIPLINE_NAMES.items(): items.append( Picklistitem( picklist=picklist, ordinal=ordinal, - value=type['value'], - title=type['label'], + value=value, + title=title, ) ) ordinal += 1 From 7a052fb7dc57ec02cedb192696f3ebccb17e15a3 Mon Sep 17 00:00:00 2001 From: alesan99 Date: Wed, 10 Dec 2025 09:17:13 -0600 Subject: [PATCH 05/12] Apply migrations --- .../specify/migrations/0042_discipline_type_picklist.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/specifyweb/specify/migrations/0042_discipline_type_picklist.py b/specifyweb/specify/migrations/0042_discipline_type_picklist.py index 777c167b675..ba4ee9b76d3 100644 --- a/specifyweb/specify/migrations/0042_discipline_type_picklist.py +++ b/specifyweb/specify/migrations/0042_discipline_type_picklist.py @@ -55,4 +55,10 @@ def apply_migration(apps, schema_editor): def revert_migration(apps, schema_editor): revert_discipline_type_picklist(apps) - operations = [] + operations = [ + migrations.RunPython( + apply_migration, + revert_migration, + atomic=True, + ), + ] From 3764c126ba110b0a1d0d9ffa7837ccb0590e3d33 Mon Sep 17 00:00:00 2001 From: alesan99 Date: Wed, 10 Dec 2025 09:34:58 -0600 Subject: [PATCH 06/12] Fix Names --- specifyweb/specify/migrations/0042_discipline_type_picklist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specifyweb/specify/migrations/0042_discipline_type_picklist.py b/specifyweb/specify/migrations/0042_discipline_type_picklist.py index ba4ee9b76d3..f99e39b442d 100644 --- a/specifyweb/specify/migrations/0042_discipline_type_picklist.py +++ b/specifyweb/specify/migrations/0042_discipline_type_picklist.py @@ -1,7 +1,7 @@ from django.db import migrations from specifyweb.backend.context.app_resource import DISCIPLINE_NAMES -DISCIPLINE_TYPE_PICKLIST_NAME = 'COGTypes' +DISCIPLINE_TYPE_PICKLIST_NAME = 'DisciplineType' def create_discipline_type_picklist(apps): Collection = apps.get_model('specify', 'Collection') From a34de0dd55d2230cc5cb918929cc2e30c9572ebf Mon Sep 17 00:00:00 2001 From: alesan99 Date: Wed, 10 Dec 2025 10:25:04 -0600 Subject: [PATCH 07/12] Remove table --- specifyweb/specify/migrations/0042_discipline_type_picklist.py | 1 - 1 file changed, 1 deletion(-) diff --git a/specifyweb/specify/migrations/0042_discipline_type_picklist.py b/specifyweb/specify/migrations/0042_discipline_type_picklist.py index f99e39b442d..f30accc3fe1 100644 --- a/specifyweb/specify/migrations/0042_discipline_type_picklist.py +++ b/specifyweb/specify/migrations/0042_discipline_type_picklist.py @@ -13,7 +13,6 @@ def create_discipline_type_picklist(apps): picklist, created = Picklist.objects.get_or_create( name=DISCIPLINE_TYPE_PICKLIST_NAME, type=1, - tablename='discipline', collection=collection, defaults={ "issystem": True, From cfb91a9e205635c0e214260f1c9f58ebdcaffac5 Mon Sep 17 00:00:00 2001 From: alesan99 Date: Wed, 10 Dec 2025 10:39:22 -0600 Subject: [PATCH 08/12] Update schema config picklist for discipline --- .../0042_discipline_type_picklist.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/specifyweb/specify/migrations/0042_discipline_type_picklist.py b/specifyweb/specify/migrations/0042_discipline_type_picklist.py index f30accc3fe1..5f988326ae3 100644 --- a/specifyweb/specify/migrations/0042_discipline_type_picklist.py +++ b/specifyweb/specify/migrations/0042_discipline_type_picklist.py @@ -42,6 +42,23 @@ def revert_discipline_type_picklist(apps): Picklist.objects.filter(name=DISCIPLINE_TYPE_PICKLIST_NAME).delete() +def update_discipline_type_splocalecontaineritem(apps): + Splocalecontaineritem = apps.get_model("specify", "Splocalecontaineritem") + + Splocalecontaineritem.objects.filter( + container__name="discipline", + container__schematype=0, + name="type", + ).update(picklistname=DISCIPLINE_TYPE_PICKLIST_NAME, isrequired=True) + +def revert_discipline_type_splocalecontaineritem(apps): + Splocalecontaineritem = apps.get_model("specify", "Splocalecontaineritem") + + Splocalecontaineritem.objects.filter( + container__name="discipline", + container__schematype=0, + name="type", + ).update(picklistname=None, isrequired=None) class Migration(migrations.Migration): dependencies = [ @@ -50,9 +67,11 @@ class Migration(migrations.Migration): def apply_migration(apps, schema_editor): create_discipline_type_picklist(apps) + update_discipline_type_splocalecontaineritem(apps) def revert_migration(apps, schema_editor): revert_discipline_type_picklist(apps) + revert_discipline_type_splocalecontaineritem(apps) operations = [ migrations.RunPython( From 8c40d1b915ac9802e92a84b0f3f0baaa23bf32ff Mon Sep 17 00:00:00 2001 From: alesan99 Date: Wed, 10 Dec 2025 10:52:13 -0600 Subject: [PATCH 09/12] Update picklist type --- specifyweb/specify/migrations/0042_discipline_type_picklist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specifyweb/specify/migrations/0042_discipline_type_picklist.py b/specifyweb/specify/migrations/0042_discipline_type_picklist.py index 5f988326ae3..f5e04e2d613 100644 --- a/specifyweb/specify/migrations/0042_discipline_type_picklist.py +++ b/specifyweb/specify/migrations/0042_discipline_type_picklist.py @@ -12,7 +12,7 @@ def create_discipline_type_picklist(apps): for collection in Collection.objects.all(): picklist, created = Picklist.objects.get_or_create( name=DISCIPLINE_TYPE_PICKLIST_NAME, - type=1, + type=0, collection=collection, defaults={ "issystem": True, From e9d05225a925af694684deeddc8681e5f843b9fd Mon Sep 17 00:00:00 2001 From: alesan99 Date: Fri, 12 Dec 2025 11:24:11 -0600 Subject: [PATCH 10/12] Add discipline picklist to run_key_migration_functions --- .../commands/run_key_migration_functions.py | 2 + .../migration_utils/update_schema_config.py | 65 +++++++++++++++++ .../0042_discipline_type_picklist.py | 69 ++----------------- 3 files changed, 72 insertions(+), 64 deletions(-) diff --git a/specifyweb/specify/management/commands/run_key_migration_functions.py b/specifyweb/specify/management/commands/run_key_migration_functions.py index 6209a0d0094..83a14b9e7bc 100644 --- a/specifyweb/specify/management/commands/run_key_migration_functions.py +++ b/specifyweb/specify/management/commands/run_key_migration_functions.py @@ -74,6 +74,8 @@ def fix_schema_config(stdout: WriteToStdOut | None = None): usc.add_quantities_gift, # specify 0032 usc.update_paleo_desc, # specify 0033 usc.update_accession_date_fields # specify 0034 + usc.create_discipline_type_picklist # specify 0042 + usc.update_discipline_type_splocalecontaineritem # specify specify 0042 ] log_and_run(funcs, stdout) diff --git a/specifyweb/specify/migration_utils/update_schema_config.py b/specifyweb/specify/migration_utils/update_schema_config.py index 775299a8d07..cf69b4066df 100644 --- a/specifyweb/specify/migration_utils/update_schema_config.py +++ b/specifyweb/specify/migration_utils/update_schema_config.py @@ -1397,3 +1397,68 @@ def revert_version_required(apps): for table, fields in MIGRATION_0035_FIELDS.items(): for field in fields: update_table_field_schema_config_params(table, discipline.id, field, updated_config_params, apps) + +# ########################################## +# Used in 0042_discipline_type_picklist.py +# ########################################## + +from specifyweb.backend.context.app_resource import DISCIPLINE_NAMES + +DISCIPLINE_TYPE_PICKLIST_NAME = 'DisciplineType' + +def create_discipline_type_picklist(apps): + Collection = apps.get_model('specify', 'Collection') + Picklist = apps.get_model('specify', 'Picklist') + Picklistitem = apps.get_model('specify', 'Picklistitem') + + # Create a discipline type picklist for each collection + for collection in Collection.objects.all(): + picklist, created = Picklist.objects.get_or_create( + name=DISCIPLINE_TYPE_PICKLIST_NAME, + type=0, + collection=collection, + defaults={ + "issystem": True, + "readonly": True, + "sizelimit": -1, + "sorttype": 1, + } + ) + # If the picklist doesn't exist, create a new one + if created: + ordinal = 1 + items = [] + for value, title in DISCIPLINE_NAMES.items(): + items.append( + Picklistitem( + picklist=picklist, + ordinal=ordinal, + value=value, + title=title, + ) + ) + ordinal += 1 + Picklistitem.objects.bulk_create(items) + +def revert_discipline_type_picklist(apps): + Picklist = apps.get_model('specify', 'Picklist') + + Picklist.objects.filter(name=DISCIPLINE_TYPE_PICKLIST_NAME).delete() + +def update_discipline_type_splocalecontaineritem(apps): + Splocalecontaineritem = apps.get_model("specify", "Splocalecontaineritem") + + Splocalecontaineritem.objects.filter( + container__name="discipline", + container__schematype=0, + name="type", + ).update(picklistname=DISCIPLINE_TYPE_PICKLIST_NAME, isrequired=True) + +def revert_discipline_type_splocalecontaineritem(apps): + Splocalecontaineritem = apps.get_model("specify", "Splocalecontaineritem") + + Splocalecontaineritem.objects.filter( + container__name="discipline", + container__schematype=0, + name="type", + ).update(picklistname=None, isrequired=None) diff --git a/specifyweb/specify/migrations/0042_discipline_type_picklist.py b/specifyweb/specify/migrations/0042_discipline_type_picklist.py index f5e04e2d613..f75d72aeb45 100644 --- a/specifyweb/specify/migrations/0042_discipline_type_picklist.py +++ b/specifyweb/specify/migrations/0042_discipline_type_picklist.py @@ -1,64 +1,5 @@ from django.db import migrations -from specifyweb.backend.context.app_resource import DISCIPLINE_NAMES - -DISCIPLINE_TYPE_PICKLIST_NAME = 'DisciplineType' - -def create_discipline_type_picklist(apps): - Collection = apps.get_model('specify', 'Collection') - Picklist = apps.get_model('specify', 'Picklist') - Picklistitem = apps.get_model('specify', 'Picklistitem') - - # Create a discipline type picklist for each collection - for collection in Collection.objects.all(): - picklist, created = Picklist.objects.get_or_create( - name=DISCIPLINE_TYPE_PICKLIST_NAME, - type=0, - collection=collection, - defaults={ - "issystem": True, - "readonly": True, - "sizelimit": -1, - "sorttype": 1, - } - ) - # If the picklist doesn't exist, create a new one - if created: - ordinal = 1 - items = [] - for value, title in DISCIPLINE_NAMES.items(): - items.append( - Picklistitem( - picklist=picklist, - ordinal=ordinal, - value=value, - title=title, - ) - ) - ordinal += 1 - Picklistitem.objects.bulk_create(items) - -def revert_discipline_type_picklist(apps): - Picklist = apps.get_model('specify', 'Picklist') - - Picklist.objects.filter(name=DISCIPLINE_TYPE_PICKLIST_NAME).delete() - -def update_discipline_type_splocalecontaineritem(apps): - Splocalecontaineritem = apps.get_model("specify", "Splocalecontaineritem") - - Splocalecontaineritem.objects.filter( - container__name="discipline", - container__schematype=0, - name="type", - ).update(picklistname=DISCIPLINE_TYPE_PICKLIST_NAME, isrequired=True) - -def revert_discipline_type_splocalecontaineritem(apps): - Splocalecontaineritem = apps.get_model("specify", "Splocalecontaineritem") - - Splocalecontaineritem.objects.filter( - container__name="discipline", - container__schematype=0, - name="type", - ).update(picklistname=None, isrequired=None) +from specifyweb.specify.migration_utils import update_schema_config as usc class Migration(migrations.Migration): dependencies = [ @@ -66,12 +7,12 @@ class Migration(migrations.Migration): ] def apply_migration(apps, schema_editor): - create_discipline_type_picklist(apps) - update_discipline_type_splocalecontaineritem(apps) + usc.create_discipline_type_picklist(apps) + usc.update_discipline_type_splocalecontaineritem(apps) def revert_migration(apps, schema_editor): - revert_discipline_type_picklist(apps) - revert_discipline_type_splocalecontaineritem(apps) + usc.revert_discipline_type_picklist(apps) + usc.revert_discipline_type_splocalecontaineritem(apps) operations = [ migrations.RunPython( From 010784846b9ddb714564f51aa29bc337345b6894 Mon Sep 17 00:00:00 2001 From: alesan99 Date: Tue, 16 Dec 2025 22:06:03 +0000 Subject: [PATCH 11/12] Lint code with ESLint and Prettier Triggered by 55f5353fb8cca1e9f984a1608dced016294166e9 on branch refs/heads/issue-7582 --- .../lib/components/FormSliders/IntegratedRecordSelector.tsx | 2 +- .../frontend/js_src/lib/components/FormSliders/helpers.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/FormSliders/IntegratedRecordSelector.tsx b/specifyweb/frontend/js_src/lib/components/FormSliders/IntegratedRecordSelector.tsx index 5326c3b1c83..d703a0a5220 100644 --- a/specifyweb/frontend/js_src/lib/components/FormSliders/IntegratedRecordSelector.tsx +++ b/specifyweb/frontend/js_src/lib/components/FormSliders/IntegratedRecordSelector.tsx @@ -32,8 +32,8 @@ import { InteractionDialog } from '../Interactions/InteractionDialog'; import { hasTablePermission } from '../Permissions/helpers'; import { relationshipIsToMany } from '../WbPlanView/mappingHelpers'; import { AttachmentsCollection } from './AttachmentsCollection'; -import { shouldBeToOne } from './helpers'; import { AttachmentWarningDeletion } from './AttachmentWarningDeletion'; +import { shouldBeToOne } from './helpers'; import { RecordSelectorFromCollection } from './RecordSelectorFromCollection'; /** A wrapper for RecordSelector to integrate with Backbone.Collection */ diff --git a/specifyweb/frontend/js_src/lib/components/FormSliders/helpers.ts b/specifyweb/frontend/js_src/lib/components/FormSliders/helpers.ts index 64b8b34de79..c7470c8b61f 100644 --- a/specifyweb/frontend/js_src/lib/components/FormSliders/helpers.ts +++ b/specifyweb/frontend/js_src/lib/components/FormSliders/helpers.ts @@ -1,4 +1,4 @@ -import { Relationship } from '../DataModel/specifyField'; +import type { Relationship } from '../DataModel/specifyField'; export const shouldBeToOne = ( relationship: Relationship | undefined From 2f6c7e8b16b78b7b86a23c3e6744d269390d2830 Mon Sep 17 00:00:00 2001 From: alesan99 Date: Mon, 22 Dec 2025 14:23:58 +0000 Subject: [PATCH 12/12] Lint code with ESLint and Prettier Triggered by 811425bff466c7911716a2aef1b3c1a6ce0ac444 on branch refs/heads/issue-7582 --- .../lib/components/AppResources/Filters.tsx | 2 +- .../lib/components/Attachments/Plugin.tsx | 2 +- .../AttachmentsBulkImport/Upload.tsx | 2 +- .../lib/components/DataModel/businessRules.ts | 6 +- .../FormPlugins/__tests__/dateUtils.test.ts | 36 ++-- .../lib/components/Preferences/Aside.tsx | 3 +- .../Preferences/CollectionDefinitions.tsx | 9 +- .../lib/components/Preferences/index.tsx | 74 ++++--- .../lib/components/TreeView/Actions.tsx | 2 +- .../components/WbImportAttachments/index.tsx | 2 +- .../WbPlanView/__tests__/automapper.test.ts | 49 ++--- .../WbPlanView/__tests__/linesGetter.test.ts | 187 +++++++++--------- 12 files changed, 192 insertions(+), 182 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/AppResources/Filters.tsx b/specifyweb/frontend/js_src/lib/components/AppResources/Filters.tsx index 02811602936..44e458072e4 100644 --- a/specifyweb/frontend/js_src/lib/components/AppResources/Filters.tsx +++ b/specifyweb/frontend/js_src/lib/components/AppResources/Filters.tsx @@ -15,6 +15,7 @@ import { Input, Label } from '../Atoms/Form'; import { icons } from '../Atoms/Icons'; import { Link } from '../Atoms/Link'; import { Dialog } from '../Molecules/Dialog'; +import { hasPermission } from '../Permissions/helpers'; import { allAppResources, countAppResources, @@ -23,7 +24,6 @@ import { } from './filtersHelpers'; import type { AppResources } from './hooks'; import { appResourceSubTypes, appResourceTypes } from './types'; -import { hasPermission } from '../Permissions/helpers'; export function AppResourcesFilters({ initialResources, diff --git a/specifyweb/frontend/js_src/lib/components/Attachments/Plugin.tsx b/specifyweb/frontend/js_src/lib/components/Attachments/Plugin.tsx index 57084c9fd9c..3924016f65f 100644 --- a/specifyweb/frontend/js_src/lib/components/Attachments/Plugin.tsx +++ b/specifyweb/frontend/js_src/lib/components/Attachments/Plugin.tsx @@ -23,11 +23,11 @@ import { loadingBar } from '../Molecules'; import { Dialog } from '../Molecules/Dialog'; import { FilePicker } from '../Molecules/FilePicker'; import { ProtectedTable } from '../Permissions/PermissionDenied'; +import { collectionPreferences } from '../Preferences/collectionPreferences'; import { userPreferences } from '../Preferences/userPreferences'; import { AttachmentPluginSkeleton } from '../SkeletonLoaders/AttachmentPlugin'; import { attachmentSettingsPromise, uploadFile } from './attachments'; import { AttachmentViewer } from './Viewer'; -import { collectionPreferences } from '../Preferences/collectionPreferences'; export function AttachmentsPlugin( props: Parameters[0] diff --git a/specifyweb/frontend/js_src/lib/components/AttachmentsBulkImport/Upload.tsx b/specifyweb/frontend/js_src/lib/components/AttachmentsBulkImport/Upload.tsx index fa85db57fd3..e9b9bd05253 100644 --- a/specifyweb/frontend/js_src/lib/components/AttachmentsBulkImport/Upload.tsx +++ b/specifyweb/frontend/js_src/lib/components/AttachmentsBulkImport/Upload.tsx @@ -23,6 +23,7 @@ import { strictGetTable } from '../DataModel/tables'; import type { Attachment, Tables } from '../DataModel/types'; import { Dialog } from '../Molecules/Dialog'; import { hasPermission } from '../Permissions/helpers'; +import { collectionPreferences } from '../Preferences/collectionPreferences'; import { ActionState } from './ActionState'; import type { AttachmentUploadSpec, EagerDataSet } from './Import'; import { PerformAttachmentTask } from './PerformAttachmentTask'; @@ -39,7 +40,6 @@ import { saveForAttachmentUpload, validateAttachmentFiles, } from './utils'; -import { collectionPreferences } from '../Preferences/collectionPreferences'; async function prepareForUpload( dataSet: EagerDataSet, diff --git a/specifyweb/frontend/js_src/lib/components/DataModel/businessRules.ts b/specifyweb/frontend/js_src/lib/components/DataModel/businessRules.ts index 87a88209da6..fbbcd168f57 100644 --- a/specifyweb/frontend/js_src/lib/components/DataModel/businessRules.ts +++ b/specifyweb/frontend/js_src/lib/components/DataModel/businessRules.ts @@ -71,8 +71,10 @@ export class BusinessRuleManager { fieldName: string & (keyof SCHEMA['fields'] | keyof SCHEMA['toOneIndependent']) ): Promise>> { - // REFACTOR: When checkField is called directly, the promises are not - // added to the public pendingPromise + /* + * REFACTOR: When checkField is called directly, the promises are not + * added to the public pendingPromise + */ const field = this.resource.specifyTable.getField(fieldName); if (field === undefined) return []; diff --git a/specifyweb/frontend/js_src/lib/components/FormPlugins/__tests__/dateUtils.test.ts b/specifyweb/frontend/js_src/lib/components/FormPlugins/__tests__/dateUtils.test.ts index b2b20c07d2f..f38a72f6a8e 100644 --- a/specifyweb/frontend/js_src/lib/components/FormPlugins/__tests__/dateUtils.test.ts +++ b/specifyweb/frontend/js_src/lib/components/FormPlugins/__tests__/dateUtils.test.ts @@ -17,24 +17,24 @@ describe('getDateParser', () => { new Date() ) ).toMatchInlineSnapshot(` - { - "formatters": [ - [Function], - [Function], - ], - "max": "9999-12-31", - "minLength": 10, - "parser": [Function], - "required": false, - "title": "Required Format: MM/DD/YYYY.", - "type": "date", - "validators": [ - [Function], - ], - "value": "2022-08-31", - "whiteSpaceSensitive": false, - } -`)); + { + "formatters": [ + [Function], + [Function], + ], + "max": "9999-12-31", + "minLength": 10, + "parser": [Function], + "required": false, + "title": "Required Format: MM/DD/YYYY.", + "type": "date", + "validators": [ + [Function], + ], + "value": "2022-08-31", + "whiteSpaceSensitive": false, + } + `)); test('month-year', () => expect(getDateParser(undefined, 'month-year', undefined)) diff --git a/specifyweb/frontend/js_src/lib/components/Preferences/Aside.tsx b/specifyweb/frontend/js_src/lib/components/Preferences/Aside.tsx index 6aaa1115190..2e4e6cd813e 100644 --- a/specifyweb/frontend/js_src/lib/components/Preferences/Aside.tsx +++ b/specifyweb/frontend/js_src/lib/components/Preferences/Aside.tsx @@ -7,7 +7,8 @@ import type { GetSet, WritableArray } from '../../utils/types'; import { Link } from '../Atoms/Link'; import { pathIsOverlay } from '../Router/UnloadProtect'; import { scrollIntoView } from '../TreeView/helpers'; -import { PreferenceType, usePrefDefinitions } from './index'; +import type { PreferenceType } from './index'; +import { usePrefDefinitions } from './index'; export function PreferencesAside({ activeCategory, diff --git a/specifyweb/frontend/js_src/lib/components/Preferences/CollectionDefinitions.tsx b/specifyweb/frontend/js_src/lib/components/Preferences/CollectionDefinitions.tsx index 7af14f3f74c..e487b6876cc 100644 --- a/specifyweb/frontend/js_src/lib/components/Preferences/CollectionDefinitions.tsx +++ b/specifyweb/frontend/js_src/lib/components/Preferences/CollectionDefinitions.tsx @@ -1,4 +1,5 @@ -import { LocalizedString } from 'typesafe-i18n'; +import type { LocalizedString } from 'typesafe-i18n'; + import { attachmentsText } from '../../localization/attachments'; import { preferencesText } from '../../localization/preferences'; import { queryText } from '../../localization/query'; @@ -8,13 +9,13 @@ import { treeText } from '../../localization/tree'; import { f } from '../../utils/functools'; import type { RA } from '../../utils/types'; import { ensure } from '../../utils/types'; +import { camelToHuman } from '../../utils/utils'; import { genericTables } from '../DataModel/tables'; -import { Tables } from '../DataModel/types'; +import type { Tables } from '../DataModel/types'; +import type { QueryView } from '../QueryBuilder/Header'; import type { StatLayout } from '../Statistics/types'; import type { GenericPreferences } from './types'; import { definePref } from './types'; -import { camelToHuman } from '../../utils/utils'; -import { QueryView } from '../QueryBuilder/Header'; const tableLabel = (tableName: keyof Tables): LocalizedString => genericTables[tableName]?.label ?? camelToHuman(tableName); diff --git a/specifyweb/frontend/js_src/lib/components/Preferences/index.tsx b/specifyweb/frontend/js_src/lib/components/Preferences/index.tsx index 246bc9ffb34..2c8b96df308 100644 --- a/specifyweb/frontend/js_src/lib/components/Preferences/index.tsx +++ b/specifyweb/frontend/js_src/lib/components/Preferences/index.tsx @@ -9,9 +9,11 @@ import type { LocalizedString } from 'typesafe-i18n'; import { usePromise } from '../../hooks/useAsyncState'; import { useBooleanState } from '../../hooks/useBooleanState'; import { commonText } from '../../localization/common'; +import { headerText } from '../../localization/header'; import { preferencesText } from '../../localization/preferences'; import { StringToJsx } from '../../localization/utils'; import { f } from '../../utils/functools'; +import type { IR } from '../../utils/types'; import { Container, H2, Key } from '../Atoms'; import { Button } from '../Atoms/Button'; import { className } from '../Atoms/className'; @@ -21,7 +23,13 @@ import { Submit } from '../Atoms/Submit'; import { LoadingContext, ReadOnlyContext } from '../Core/Contexts'; import { ErrorBoundary } from '../Errors/ErrorBoundary'; import { hasPermission } from '../Permissions/helpers'; +import { + ProtectedAction, + ProtectedTool, +} from '../Permissions/PermissionDenied'; import { PreferencesAside } from './Aside'; +import type { BasePreferences } from './BasePreferences'; +import { collectionPreferenceDefinitions } from './CollectionDefinitions'; import { collectionPreferences } from './collectionPreferences'; import { useDarkMode } from './Hooks'; import { DefaultPreferenceItemRender } from './Renderers'; @@ -29,14 +37,6 @@ import type { GenericPreferences, PreferenceItem } from './types'; import { userPreferenceDefinitions } from './UserDefinitions'; import { userPreferences } from './userPreferences'; import { useTopChild } from './useTopChild'; -import { IR } from '../../utils/types'; -import { headerText } from '../../localization/header'; -import { BasePreferences } from './BasePreferences'; -import { - ProtectedAction, - ProtectedTool, -} from '../Permissions/PermissionDenied'; -import { collectionPreferenceDefinitions } from './CollectionDefinitions'; export type PreferenceType = keyof typeof preferenceInstances; @@ -142,9 +142,9 @@ function Preferences({ > @@ -323,9 +323,7 @@ export function PreferencesContent({ />

{item.description !== undefined && ( -

+

{item.description !== undefined && ( { - return ( - - -

- {typeof title === 'function' ? title() : title} -

- {description !== undefined && ( -

- {typeof description === 'function' - ? description() - : description} -

- )} - {subCategories.map(([subcategory, data]) => - renderSubCategory(category, subcategory, data) - )} - - - ); - } + ) => ( + + +

+ {typeof title === 'function' ? title() : title} +

+ {description !== undefined && ( +

+ {typeof description === 'function' + ? description() + : description} +

+ )} + {subCategories.map(([subcategory, data]) => + renderSubCategory(category, subcategory, data) + )} +
+
+ ) )} ); @@ -484,7 +480,7 @@ function UserPrefItem(props: PreferenceItemProps) { props.subcategory as any, props.name as any ); - return ; + return ; } function CollectionPrefItem(props: PreferenceItemProps) { @@ -493,7 +489,7 @@ function CollectionPrefItem(props: PreferenceItemProps) { props.subcategory as any, props.name as any ); - return ; + return ; } function CollectionPreferences(): JSX.Element { diff --git a/specifyweb/frontend/js_src/lib/components/TreeView/Actions.tsx b/specifyweb/frontend/js_src/lib/components/TreeView/Actions.tsx index 7155fc0a9d7..28c3c8c7faf 100644 --- a/specifyweb/frontend/js_src/lib/components/TreeView/Actions.tsx +++ b/specifyweb/frontend/js_src/lib/components/TreeView/Actions.tsx @@ -20,9 +20,9 @@ import { DeleteButton } from '../Forms/DeleteButton'; import { Dialog } from '../Molecules/Dialog'; import { ResourceLink } from '../Molecules/ResourceLink'; import { hasPermission, hasTablePermission } from '../Permissions/helpers'; +import { collectionPreferences } from '../Preferences/collectionPreferences'; import type { Row } from './helpers'; import { checkMoveViolatesEnforced } from './helpers'; -import { collectionPreferences } from '../Preferences/collectionPreferences'; const treeActions = [ 'add', diff --git a/specifyweb/frontend/js_src/lib/components/WbImportAttachments/index.tsx b/specifyweb/frontend/js_src/lib/components/WbImportAttachments/index.tsx index 0f46b44f669..54abf29e444 100644 --- a/specifyweb/frontend/js_src/lib/components/WbImportAttachments/index.tsx +++ b/specifyweb/frontend/js_src/lib/components/WbImportAttachments/index.tsx @@ -36,6 +36,7 @@ import { loadingBar } from '../Molecules'; import { Dialog } from '../Molecules/Dialog'; import { FilePicker } from '../Molecules/FilePicker'; import { Preview } from '../Molecules/FilePicker'; +import { collectionPreferences } from '../Preferences/collectionPreferences'; import { uniquifyDataSetName } from '../WbImport/helpers'; import { ChooseName } from '../WbImport/index'; import { @@ -43,7 +44,6 @@ import { attachmentsToCell, BASE_TABLE_NAME, } from '../WorkBench/attachmentHelpers'; -import { collectionPreferences } from '../Preferences/collectionPreferences'; export function WbImportAttachmentsView(): JSX.Element { useMenuItem('workBench'); diff --git a/specifyweb/frontend/js_src/lib/components/WbPlanView/__tests__/automapper.test.ts b/specifyweb/frontend/js_src/lib/components/WbPlanView/__tests__/automapper.test.ts index f1838e3e7cf..801eca21018 100644 --- a/specifyweb/frontend/js_src/lib/components/WbPlanView/__tests__/automapper.test.ts +++ b/specifyweb/frontend/js_src/lib/components/WbPlanView/__tests__/automapper.test.ts @@ -27,16 +27,19 @@ theories( * TODO: The tests are mapping these Taxon headers to Component * over Determination. The issue is not happening within the * application - * */ - // 'Class', - // 'Superfamily', - // 'Family', - // 'Genus', - // 'Subgenus', - // 'Species', - // 'Subspecies', - // 'Species Author', - // 'Subspecies Author', + * + */ + /* + * 'Class', + * 'Superfamily', + * 'Family', + * 'Genus', + * 'Subgenus', + * 'Species', + * 'Subspecies', + * 'Species Author', + * 'Subspecies Author', + */ 'Who ID First Name', 'Determiner 1 Title', 'Determiner 1 First Name', @@ -184,18 +187,20 @@ theories( Latitude2: [['collectingEvent', 'locality', 'latitude2']], Longitude1: [['collectingEvent', 'locality', 'longitude1']], Longitude2: [['collectingEvent', 'locality', 'longitude2']], - // Class: [['determinations', '#1', 'taxon', '$Class', 'name']], - // Family: [['determinations', '#1', 'taxon', '$Family', 'name']], - // Genus: [['determinations', '#1', 'taxon', '$Genus', 'name']], - // Subgenus: [['determinations', '#1', 'taxon', '$Subgenus', 'name']], - // 'Species Author': [ - // ['determinations', '#1', 'taxon', '$Species', 'author'], - // ], - // Species: [['determinations', '#1', 'taxon', '$Species', 'name']], - // 'Subspecies Author': [ - // ['determinations', '#1', 'taxon', '$Subspecies', 'author'], - // ], - // Subspecies: [['determinations', '#1', 'taxon', '$Subspecies', 'name']], + /* + * Class: [['determinations', '#1', 'taxon', '$Class', 'name']], + * Family: [['determinations', '#1', 'taxon', '$Family', 'name']], + * Genus: [['determinations', '#1', 'taxon', '$Genus', 'name']], + * Subgenus: [['determinations', '#1', 'taxon', '$Subgenus', 'name']], + * 'Species Author': [ + * ['determinations', '#1', 'taxon', '$Species', 'author'], + * ], + * Species: [['determinations', '#1', 'taxon', '$Species', 'name']], + * 'Subspecies Author': [ + * ['determinations', '#1', 'taxon', '$Subspecies', 'author'], + * ], + * Subspecies: [['determinations', '#1', 'taxon', '$Subspecies', 'name']], + */ 'Prep Type 1': [['preparations', '#1', 'prepType', 'name']], Country: [ ['collectingEvent', 'locality', 'geography', '$Country', 'name'], diff --git a/specifyweb/frontend/js_src/lib/components/WbPlanView/__tests__/linesGetter.test.ts b/specifyweb/frontend/js_src/lib/components/WbPlanView/__tests__/linesGetter.test.ts index d3703ff070f..8d804e02644 100644 --- a/specifyweb/frontend/js_src/lib/components/WbPlanView/__tests__/linesGetter.test.ts +++ b/specifyweb/frontend/js_src/lib/components/WbPlanView/__tests__/linesGetter.test.ts @@ -21,16 +21,19 @@ theories(getLinesFromHeaders, [ * TODO: The tests are mapping these Taxon headers to Component * over Determination. The issue is not happening within the * application - * */ - // 'Class', - // 'Superfamily', - // 'Family', - // 'Genus', - // 'Subgenus', - // 'Species', - // 'Subspecies', - // 'Species Author', - // 'Subspecies Author', + * + */ + /* + * 'Class', + * 'Superfamily', + * 'Family', + * 'Genus', + * 'Subgenus', + * 'Species', + * 'Subspecies', + * 'Species Author', + * 'Subspecies Author', + */ ], runAutoMapper: true, baseTableName: 'CollectionObject', @@ -46,87 +49,89 @@ theories(getLinesFromHeaders, [ default: null, }, }, - // { - // mappingPath: ['determinations', '#1', 'taxon', '$Class', 'name'], - // headerName: 'Class', - // columnOptions: { - // matchBehavior: 'ignoreNever', - // nullAllowed: true, - // default: null, - // }, - // }, - // { - // mappingPath: [emptyMapping], - // headerName: 'Superfamily', - // columnOptions: { - // matchBehavior: 'ignoreNever', - // nullAllowed: true, - // default: null, - // }, - // }, - // { - // mappingPath: ['determinations', '#1', 'taxon', '$Family', 'name'], - // headerName: 'Family', - // columnOptions: { - // matchBehavior: 'ignoreNever', - // nullAllowed: true, - // default: null, - // }, - // }, - // { - // mappingPath: ['determinations', '#1', 'taxon', '$Genus', 'name'], - // headerName: 'Genus', - // columnOptions: { - // matchBehavior: 'ignoreNever', - // nullAllowed: true, - // default: null, - // }, - // }, - // { - // mappingPath: ['determinations', '#1', 'taxon', '$Subgenus', 'name'], - // headerName: 'Subgenus', - // columnOptions: { - // matchBehavior: 'ignoreNever', - // nullAllowed: true, - // default: null, - // }, - // }, - // { - // mappingPath: ['determinations', '#1', 'taxon', '$Species', 'name'], - // headerName: 'Species', - // columnOptions: { - // matchBehavior: 'ignoreNever', - // nullAllowed: true, - // default: null, - // }, - // }, - // { - // mappingPath: ['determinations', '#1', 'taxon', '$Subspecies', 'name'], - // headerName: 'Subspecies', - // columnOptions: { - // matchBehavior: 'ignoreNever', - // nullAllowed: true, - // default: null, - // }, - // }, - // { - // mappingPath: ['determinations', '#1', 'taxon', '$Species', 'author'], - // headerName: 'Species Author', - // columnOptions: { - // matchBehavior: 'ignoreNever', - // nullAllowed: true, - // default: null, - // }, - // }, - // { - // mappingPath: ['determinations', '#1', 'taxon', '$Subspecies', 'author'], - // headerName: 'Subspecies Author', - // columnOptions: { - // matchBehavior: 'ignoreNever', - // nullAllowed: true, - // default: null, - // }, - // }, + /* + * { + * mappingPath: ['determinations', '#1', 'taxon', '$Class', 'name'], + * headerName: 'Class', + * columnOptions: { + * matchBehavior: 'ignoreNever', + * nullAllowed: true, + * default: null, + * }, + * }, + * { + * mappingPath: [emptyMapping], + * headerName: 'Superfamily', + * columnOptions: { + * matchBehavior: 'ignoreNever', + * nullAllowed: true, + * default: null, + * }, + * }, + * { + * mappingPath: ['determinations', '#1', 'taxon', '$Family', 'name'], + * headerName: 'Family', + * columnOptions: { + * matchBehavior: 'ignoreNever', + * nullAllowed: true, + * default: null, + * }, + * }, + * { + * mappingPath: ['determinations', '#1', 'taxon', '$Genus', 'name'], + * headerName: 'Genus', + * columnOptions: { + * matchBehavior: 'ignoreNever', + * nullAllowed: true, + * default: null, + * }, + * }, + * { + * mappingPath: ['determinations', '#1', 'taxon', '$Subgenus', 'name'], + * headerName: 'Subgenus', + * columnOptions: { + * matchBehavior: 'ignoreNever', + * nullAllowed: true, + * default: null, + * }, + * }, + * { + * mappingPath: ['determinations', '#1', 'taxon', '$Species', 'name'], + * headerName: 'Species', + * columnOptions: { + * matchBehavior: 'ignoreNever', + * nullAllowed: true, + * default: null, + * }, + * }, + * { + * mappingPath: ['determinations', '#1', 'taxon', '$Subspecies', 'name'], + * headerName: 'Subspecies', + * columnOptions: { + * matchBehavior: 'ignoreNever', + * nullAllowed: true, + * default: null, + * }, + * }, + * { + * mappingPath: ['determinations', '#1', 'taxon', '$Species', 'author'], + * headerName: 'Species Author', + * columnOptions: { + * matchBehavior: 'ignoreNever', + * nullAllowed: true, + * default: null, + * }, + * }, + * { + * mappingPath: ['determinations', '#1', 'taxon', '$Subspecies', 'author'], + * headerName: 'Subspecies Author', + * columnOptions: { + * matchBehavior: 'ignoreNever', + * nullAllowed: true, + * default: null, + * }, + * }, + */ ], }, {