From 9f895cc14d5d5135182a5ff1d553db552bed8984 Mon Sep 17 00:00:00 2001 From: Caroline D <108160931+CarolineDenis@users.noreply.github.com> Date: Wed, 3 May 2023 07:37:53 -0700 Subject: [PATCH 1/7] Add prepType to query table to edit in same fictif record set Fixes #2754 --- .../js_src/lib/components/Toolbar/QueryTablesWrapper.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/specifyweb/frontend/js_src/lib/components/Toolbar/QueryTablesWrapper.tsx b/specifyweb/frontend/js_src/lib/components/Toolbar/QueryTablesWrapper.tsx index cef7d85f78b..c96cd2c65f7 100644 --- a/specifyweb/frontend/js_src/lib/components/Toolbar/QueryTablesWrapper.tsx +++ b/specifyweb/frontend/js_src/lib/components/Toolbar/QueryTablesWrapper.tsx @@ -62,6 +62,7 @@ export const defaultQueryTablesConfig: RA = [ 'PaleoContext', 'Permit', 'Preparation', + 'PrepType', 'Project', 'ReferenceWork', 'RepositoryAgreement', From bd2ba160a43bfb555757a8a0cc7c82095ac85e0e Mon Sep 17 00:00:00 2001 From: Caroline D <108160931+CarolineDenis@users.noreply.github.com> Date: Thu, 18 May 2023 11:15:56 -0700 Subject: [PATCH 2/7] Create a pick list editor componenent --- .../components/FormCells/PickListEditor.tsx | 62 +++++++++++++++++++ .../js_src/lib/components/FormCells/index.tsx | 38 +++++++++++- 2 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx diff --git a/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx b/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx new file mode 100644 index 00000000000..4c624135c0d --- /dev/null +++ b/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx @@ -0,0 +1,62 @@ +import React from 'react'; +import { IntegratedRecordSelector } from '../FormSliders/IntegratedRecordSelector'; +import { getModel } from '../DataModel/schema'; +import { SpecifyResource } from '../DataModel/legacyTypes'; +import { AnySchema } from '../DataModel/helperTypes'; +import { Collection } from '../DataModel/specifyModel'; +import { Relationship } from '../DataModel/specifyField'; +import { relationshipIsToMany } from '../WbPlanView/mappingHelpers'; +import { PickList } from '../DataModel/types'; +import { f } from '../../utils/functools'; +import { resourceOn } from '../DataModel/resource'; + +export function PickListEditor({ + resource, + relationship, +}: { + readonly resource: SpecifyResource; + readonly relationship: Relationship; +}): JSX.Element | null { + const [tableName, setTableName] = React.useState(null); + React.useEffect( + () => + resourceOn( + resource, + 'change:tableName', + () => setTableName(resource.get('tableName')), + true + ), + [resource] + ); + + const table = tableName === null ? undefined : getModel(tableName); + + const collection = React.useMemo( + () => + (table === undefined + ? undefined + : new table.LazyCollection({ + filters: { domainfilter: true }, + })) as Collection, + [table] + ); + + return collection === undefined ? null : ( + + void resource.set(relationship.name, resource as never) + } + onClose={f.never} + /> + ); +} diff --git a/specifyweb/frontend/js_src/lib/components/FormCells/index.tsx b/specifyweb/frontend/js_src/lib/components/FormCells/index.tsx index efbb9995ee6..7ee2bcd6ba5 100644 --- a/specifyweb/frontend/js_src/lib/components/FormCells/index.tsx +++ b/specifyweb/frontend/js_src/lib/components/FormCells/index.tsx @@ -20,6 +20,10 @@ import { SubView } from '../Forms/SubView'; import { TableIcon } from '../Molecules/TableIcon'; import { relationshipIsToMany } from '../WbPlanView/mappingHelpers'; import { FormTableInteraction } from './FormTableInteraction'; +import { PickListEditor } from './PickListEditor'; +import { toTable } from '../DataModel/helpers'; +import { resourceOn } from '../DataModel/resource'; +import { PickListTypes } from '../PickLists/definitions'; const cellRenderers: { readonly [KEY in keyof CellTypes]: (props: { @@ -155,15 +159,45 @@ const cellRenderers: { ), false ); + const currentResource = data?.resource; + + const [showPickListForm, setShowPickListForm] = + React.useState(false); + React.useEffect( + () => + currentResource === undefined + ? undefined + : resourceOn( + currentResource, + 'change:type', + () => + setShowPickListForm( + currentResource.get('type') !== PickListTypes.ITEMS + ), + true + ), + [currentResource] + ); const mode = rawResource === data?.resource ? rawMode : 'view'; if ( relationship === undefined || - data?.resource === undefined || + currentResource === undefined || interactionCollection === undefined || actualFormType === undefined ) return null; + else if ( + typeof toTable(currentResource, 'PickList') === 'object' && + showPickListForm + ) + return ( + + ); else if (interactionCollection === false || actualFormType === 'form') return ( Date: Mon, 22 May 2023 12:41:42 -0500 Subject: [PATCH 3/7] Fix TypeScript not recognizing table name check --- .../js_src/lib/components/FormCells/index.tsx | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/FormCells/index.tsx b/specifyweb/frontend/js_src/lib/components/FormCells/index.tsx index 7ee2bcd6ba5..012d36e3dfd 100644 --- a/specifyweb/frontend/js_src/lib/components/FormCells/index.tsx +++ b/specifyweb/frontend/js_src/lib/components/FormCells/index.tsx @@ -187,17 +187,10 @@ const cellRenderers: { actualFormType === undefined ) return null; - else if ( - typeof toTable(currentResource, 'PickList') === 'object' && - showPickListForm - ) - return ( - - ); + const pickList = toTable(currentResource, 'PickList'); + // eslint-disable-next-line functional/no-conditional-statement + if (typeof pickList === 'object' && showPickListForm) + return ; else if (interactionCollection === false || actualFormType === 'form') return ( Date: Mon, 22 May 2023 13:21:05 -0500 Subject: [PATCH 4/7] Simplify check for domain filter --- .../lib/components/DataModel/collectionApi.js | 7 ++----- .../js_src/lib/components/DataModel/schema.ts | 14 +------------- .../lib/components/SchemaConfig/Components.tsx | 2 +- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/DataModel/collectionApi.js b/specifyweb/frontend/js_src/lib/components/DataModel/collectionApi.js index e951d81820b..c79bca3d4d1 100644 --- a/specifyweb/frontend/js_src/lib/components/DataModel/collectionApi.js +++ b/specifyweb/frontend/js_src/lib/components/DataModel/collectionApi.js @@ -2,7 +2,6 @@ import _ from 'underscore'; import {assert} from '../Errors/assert'; import {Backbone} from './backbone'; -import {hasHierarchyField} from './schema'; const Base = Backbone.Collection.extend({ @@ -67,10 +66,8 @@ const Base = Backbone.Collection.extend({ options ||= {}; Base.call(this, null, options); this.filters = options.filters || {}; - this.domainfilter = Boolean(options.domainfilter) && ( - typeof this.model?.specifyModel !== 'object' - || hasHierarchyField(this.model.specifyModel) - ); + this.domainfilter = Boolean(options.domainfilter) && + this.model?.specifyModel.getScopingRelationship() !== undefined; }, url() { return `/api/specify/${ this.model.specifyModel.name.toLowerCase() }/`; diff --git a/specifyweb/frontend/js_src/lib/components/DataModel/schema.ts b/specifyweb/frontend/js_src/lib/components/DataModel/schema.ts index 5d64d11514a..ec7ca63515b 100644 --- a/specifyweb/frontend/js_src/lib/components/DataModel/schema.ts +++ b/specifyweb/frontend/js_src/lib/components/DataModel/schema.ts @@ -22,7 +22,7 @@ import type { AnySchema, AnyTree } from './helperTypes'; import { schemaBase } from './schemaBase'; import { schemaExtras } from './schemaExtras'; import { LiteralField, Relationship } from './specifyField'; -import { type TableDefinition, SpecifyModel } from './specifyModel'; +import { SpecifyModel, type TableDefinition } from './specifyModel'; import type { Agent, Tables } from './types'; export type SchemaLocalization = { @@ -194,15 +194,3 @@ export const getModelById = ( (Object.values(schema.models).find((model) => model.tableId === tableId) as | SpecifyModel | undefined) ?? error(`Model with id ${tableId} does not exist`); - -// If this is true, then you can use {domainfilter:true} when fetching that model -export const hasHierarchyField = (model: SpecifyModel): boolean => - [ - 'collectionObject', - 'collection', - 'discipline', - 'division', - 'institution', - ].some((fieldName) => - model.relationships.some(({ name }) => name === fieldName) - ); diff --git a/specifyweb/frontend/js_src/lib/components/SchemaConfig/Components.tsx b/specifyweb/frontend/js_src/lib/components/SchemaConfig/Components.tsx index b4569089e01..54efcfe077e 100644 --- a/specifyweb/frontend/js_src/lib/components/SchemaConfig/Components.tsx +++ b/specifyweb/frontend/js_src/lib/components/SchemaConfig/Components.tsx @@ -25,7 +25,7 @@ export function SchemaConfigHeader({

{schemaText.schemaConfig()} ( - {languages[language]?.replaceAll(/[()]/g, '') ?? language}) + {languages[language]?.replaceAll(/[()]/gu, '') ?? language})

navigate(`/specify/schema-config/${language}/`)} From 19666c9aba60069cbbd3c69b17f913506dd3134a Mon Sep 17 00:00:00 2001 From: Max Patiiuk Date: Mon, 22 May 2023 13:22:02 -0500 Subject: [PATCH 5/7] Don't allow invalid usage of domainFilter --- .../frontend/js_src/lib/components/DataModel/specifyModel.ts | 3 +-- .../js_src/lib/components/FormCells/PickListEditor.tsx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/DataModel/specifyModel.ts b/specifyweb/frontend/js_src/lib/components/DataModel/specifyModel.ts index b0d8a0beda9..dc04aba1004 100644 --- a/specifyweb/frontend/js_src/lib/components/DataModel/specifyModel.ts +++ b/specifyweb/frontend/js_src/lib/components/DataModel/specifyModel.ts @@ -34,8 +34,8 @@ import { getTableOverwrite, modelViews } from './schemaOverrides'; import type { Relationship } from './specifyField'; import { type FieldDefinition, - type RelationshipDefinition, LiteralField, + type RelationshipDefinition, } from './specifyField'; type FieldAlias = { @@ -63,7 +63,6 @@ type CollectionConstructor = new ( readonly filters?: Partial< { readonly orderby: string; - readonly domainfilter: boolean; } & SCHEMA['fields'] & CommonFields & // This is required to allow for filters like leftSide__isnull diff --git a/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx b/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx index 4c624135c0d..215d9266d5a 100644 --- a/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx +++ b/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx @@ -36,7 +36,7 @@ export function PickListEditor({ (table === undefined ? undefined : new table.LazyCollection({ - filters: { domainfilter: true }, + domainfilter: true, })) as Collection, [table] ); From e6df6f34c537e60f429a711adcaa98fbfe90e5e0 Mon Sep 17 00:00:00 2001 From: Max Patiiuk Date: Mon, 22 May 2023 18:32:49 +0000 Subject: [PATCH 6/7] Lint code with ESLint and Prettier Triggered by 19666c9aba60069cbbd3c69b17f913506dd3134a on branch refs/heads/issue-2754 --- .../js_src/lib/components/DataModel/schema.ts | 2 +- .../lib/components/DataModel/specifyModel.ts | 2 +- .../components/FormCells/PickListEditor.tsx | 21 ++++++++++--------- .../js_src/lib/components/FormCells/index.tsx | 12 +++++------ .../components/FormFields/QueryComboBox.tsx | 2 +- .../js_src/lib/components/FormMeta/index.tsx | 2 +- .../lib/components/Forms/BaseResourceView.tsx | 2 +- .../components/InitialContext/treeRanks.ts | 2 +- .../js_src/lib/components/Leaflet/layers.ts | 2 +- .../Leaflet/localityRecordDataExtractor.ts | 2 +- .../Preferences/CollectionDefinitions.tsx | 3 ++- .../lib/components/Preferences/Editor.tsx | 4 ++-- .../lib/components/Preferences/Renderers.tsx | 4 ++-- .../QueryBuilder/AuditLogFormatter.tsx | 2 +- .../lib/components/QueryBuilder/Results.tsx | 4 ++-- .../components/QueryBuilder/ResultsTable.tsx | 2 +- .../lib/components/Router/OverlayRoutes.tsx | 5 +++-- .../lib/components/SpecifyNetwork/Overlay.tsx | 2 +- .../lib/components/SpecifyNetwork/hooks.tsx | 2 +- .../lib/components/SpecifyNetwork/index.tsx | 2 +- .../lib/components/SpecifyNetwork/overlays.ts | 2 +- .../SpecifyNetworkCollection/Map.tsx | 2 +- .../lib/components/Statistics/Pages.tsx | 2 +- .../WbPlanView/__tests__/automapper.test.ts | 2 +- .../lib/components/WorkBench/Template.tsx | 2 +- 25 files changed, 46 insertions(+), 43 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/DataModel/schema.ts b/specifyweb/frontend/js_src/lib/components/DataModel/schema.ts index ec7ca63515b..256e4e470d9 100644 --- a/specifyweb/frontend/js_src/lib/components/DataModel/schema.ts +++ b/specifyweb/frontend/js_src/lib/components/DataModel/schema.ts @@ -22,7 +22,7 @@ import type { AnySchema, AnyTree } from './helperTypes'; import { schemaBase } from './schemaBase'; import { schemaExtras } from './schemaExtras'; import { LiteralField, Relationship } from './specifyField'; -import { SpecifyModel, type TableDefinition } from './specifyModel'; +import { type TableDefinition, SpecifyModel } from './specifyModel'; import type { Agent, Tables } from './types'; export type SchemaLocalization = { diff --git a/specifyweb/frontend/js_src/lib/components/DataModel/specifyModel.ts b/specifyweb/frontend/js_src/lib/components/DataModel/specifyModel.ts index dc04aba1004..7cd6ce88c49 100644 --- a/specifyweb/frontend/js_src/lib/components/DataModel/specifyModel.ts +++ b/specifyweb/frontend/js_src/lib/components/DataModel/specifyModel.ts @@ -34,8 +34,8 @@ import { getTableOverwrite, modelViews } from './schemaOverrides'; import type { Relationship } from './specifyField'; import { type FieldDefinition, - LiteralField, type RelationshipDefinition, + LiteralField, } from './specifyField'; type FieldAlias = { diff --git a/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx b/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx index 215d9266d5a..55136019d35 100644 --- a/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx +++ b/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx @@ -1,14 +1,15 @@ import React from 'react'; -import { IntegratedRecordSelector } from '../FormSliders/IntegratedRecordSelector'; -import { getModel } from '../DataModel/schema'; -import { SpecifyResource } from '../DataModel/legacyTypes'; -import { AnySchema } from '../DataModel/helperTypes'; -import { Collection } from '../DataModel/specifyModel'; -import { Relationship } from '../DataModel/specifyField'; -import { relationshipIsToMany } from '../WbPlanView/mappingHelpers'; -import { PickList } from '../DataModel/types'; + import { f } from '../../utils/functools'; +import type { AnySchema } from '../DataModel/helperTypes'; +import type { SpecifyResource } from '../DataModel/legacyTypes'; import { resourceOn } from '../DataModel/resource'; +import { getModel } from '../DataModel/schema'; +import type { Relationship } from '../DataModel/specifyField'; +import type { Collection } from '../DataModel/specifyModel'; +import type { PickList } from '../DataModel/types'; +import { IntegratedRecordSelector } from '../FormSliders/IntegratedRecordSelector'; +import { relationshipIsToMany } from '../WbPlanView/mappingHelpers'; export function PickListEditor({ resource, @@ -45,8 +46,8 @@ export function PickListEditor({ | false >( React.useCallback( - () => + async () => typeof relationship === 'object' && relationshipIsToMany(relationship) && typeof data?.resource === 'object' && @@ -188,9 +188,9 @@ const cellRenderers: { ) return null; const pickList = toTable(currentResource, 'PickList'); - // eslint-disable-next-line functional/no-conditional-statement + if (typeof pickList === 'object' && showPickListForm) - return ; + return ; else if (interactionCollection === false || actualFormType === 'form') return ( (field.name) - .then((resource) => + .then(async (resource) => resource === undefined || resource === null ? { label: '' as LocalizedString, diff --git a/specifyweb/frontend/js_src/lib/components/FormMeta/index.tsx b/specifyweb/frontend/js_src/lib/components/FormMeta/index.tsx index c948e0ff0ed..48d82b3568a 100644 --- a/specifyweb/frontend/js_src/lib/components/FormMeta/index.tsx +++ b/specifyweb/frontend/js_src/lib/components/FormMeta/index.tsx @@ -18,6 +18,7 @@ import { PrintOnSave } from '../FormFields/Checkbox'; import type { ViewDescription } from '../FormParse'; import { SubViewContext } from '../Forms/SubView'; import { isTreeResource } from '../InitialContext/treeRanks'; +import { interactionTables } from '../Interactions/config'; import { Dialog } from '../Molecules/Dialog'; import { ProtectedAction, @@ -33,7 +34,6 @@ import { QueryTreeUsages } from './QueryTreeUsages'; import { ReadOnlyMode } from './ReadOnlyMode'; import { ShareRecord } from './ShareRecord'; import { SubViewMeta } from './SubViewMeta'; -import { interactionTables } from '../Interactions/config'; /** * Form preferences host context aware user preferences and other meta-actions. diff --git a/specifyweb/frontend/js_src/lib/components/Forms/BaseResourceView.tsx b/specifyweb/frontend/js_src/lib/components/Forms/BaseResourceView.tsx index 019cebbdeef..73a2e382475 100644 --- a/specifyweb/frontend/js_src/lib/components/Forms/BaseResourceView.tsx +++ b/specifyweb/frontend/js_src/lib/components/Forms/BaseResourceView.tsx @@ -10,6 +10,7 @@ import type { AnySchema } from '../DataModel/helperTypes'; import type { SpecifyResource } from '../DataModel/legacyTypes'; import { resourceOn } from '../DataModel/resource'; import { softFail } from '../Errors/Crash'; +import { ErrorBoundary } from '../Errors/ErrorBoundary'; import { FormMeta } from '../FormMeta'; import type { FormMode } from '../FormParse'; import { LoadingScreen } from '../Molecules/Dialog'; @@ -19,7 +20,6 @@ import { displaySpecifyNetwork, SpecifyNetworkBadge } from '../SpecifyNetwork'; import { format } from './dataObjFormatters'; import { SpecifyForm } from './SpecifyForm'; import { useViewDefinition } from './useViewDefinition'; -import { ErrorBoundary } from '../Errors/ErrorBoundary'; export type ResourceViewProps = { readonly isLoading?: boolean; diff --git a/specifyweb/frontend/js_src/lib/components/InitialContext/treeRanks.ts b/specifyweb/frontend/js_src/lib/components/InitialContext/treeRanks.ts index db43a60d0fe..ffbf628c434 100644 --- a/specifyweb/frontend/js_src/lib/components/InitialContext/treeRanks.ts +++ b/specifyweb/frontend/js_src/lib/components/InitialContext/treeRanks.ts @@ -62,7 +62,7 @@ export const treeRanksPromise = Promise.all([ import('../DataModel/schema').then(async ({ fetchContext }) => fetchContext), fetchDomain, ]) - .then(([{ hasTreeAccess, hasTablePermission }]) => + .then(async ([{ hasTreeAccess, hasTablePermission }]) => hasTablePermission('Discipline', 'read') ? getDomainResource('discipline') ?.fetch() diff --git a/specifyweb/frontend/js_src/lib/components/Leaflet/layers.ts b/specifyweb/frontend/js_src/lib/components/Leaflet/layers.ts index fef07d0daa1..64d6ec5c840 100644 --- a/specifyweb/frontend/js_src/lib/components/Leaflet/layers.ts +++ b/specifyweb/frontend/js_src/lib/components/Leaflet/layers.ts @@ -199,7 +199,7 @@ const layersPromise: Promise> = { headers: { Accept: 'text/plain' } }, { strict: false, expectedResponseCodes: [Http.OK, Http.NO_CONTENT] } ) - .then(({ data, status }) => + .then(async ({ data, status }) => status === Http.NO_CONTENT ? ajax>( cachableUrl(leafletLayersEndpoint), diff --git a/specifyweb/frontend/js_src/lib/components/Leaflet/localityRecordDataExtractor.ts b/specifyweb/frontend/js_src/lib/components/Leaflet/localityRecordDataExtractor.ts index c797488a9d9..9245f74cc93 100644 --- a/specifyweb/frontend/js_src/lib/components/Leaflet/localityRecordDataExtractor.ts +++ b/specifyweb/frontend/js_src/lib/components/Leaflet/localityRecordDataExtractor.ts @@ -17,6 +17,7 @@ import { treeRanksPromise, } from '../InitialContext/treeRanks'; import { hasTablePermission, hasTreeAccess } from '../Permissions/helpers'; +import { deflateLocalityData } from '../SpecifyNetwork/utils'; import { pathStartsWith } from '../WbPlanView/helpers'; import type { MappingPath } from '../WbPlanView/Mapper'; import { @@ -36,7 +37,6 @@ import { formatCoordinate, getLocalityData, } from './helpers'; -import { deflateLocalityData } from '../SpecifyNetwork/utils'; const splitMappingPath = ( mappingPath: MappingPath, diff --git a/specifyweb/frontend/js_src/lib/components/Preferences/CollectionDefinitions.tsx b/specifyweb/frontend/js_src/lib/components/Preferences/CollectionDefinitions.tsx index e84cca4429f..f2a12e78e3e 100644 --- a/specifyweb/frontend/js_src/lib/components/Preferences/CollectionDefinitions.tsx +++ b/specifyweb/frontend/js_src/lib/components/Preferences/CollectionDefinitions.tsx @@ -5,7 +5,8 @@ import { f } from '../../utils/functools'; import type { RA } from '../../utils/types'; import { ensure } from '../../utils/types'; import type { StatLayout } from '../Statistics/types'; -import { GenericPreferences, defineItem } from './types'; +import type { GenericPreferences } from './types'; +import { defineItem } from './types'; export const collectionPreferenceDefinitions = { statistics: { diff --git a/specifyweb/frontend/js_src/lib/components/Preferences/Editor.tsx b/specifyweb/frontend/js_src/lib/components/Preferences/Editor.tsx index b530c261058..ef95e189ebc 100644 --- a/specifyweb/frontend/js_src/lib/components/Preferences/Editor.tsx +++ b/specifyweb/frontend/js_src/lib/components/Preferences/Editor.tsx @@ -1,11 +1,11 @@ import React from 'react'; +import { useLiveState } from '../../hooks/useLiveState'; +import type { AppResourceTab } from '../AppResources/TabDefinitions'; import { PreferencesContent } from '../Preferences'; import { BasePreferences } from '../Preferences/BasePreferences'; import { userPreferenceDefinitions } from '../Preferences/UserDefinitions'; import { userPreferences } from '../Preferences/userPreferences'; -import { AppResourceTab } from '../AppResources/TabDefinitions'; -import { useLiveState } from '../../hooks/useLiveState'; export const UserPreferencesEditor: AppResourceTab = function ({ isReadOnly, diff --git a/specifyweb/frontend/js_src/lib/components/Preferences/Renderers.tsx b/specifyweb/frontend/js_src/lib/components/Preferences/Renderers.tsx index ef782a81ecc..c20f4f0a773 100644 --- a/specifyweb/frontend/js_src/lib/components/Preferences/Renderers.tsx +++ b/specifyweb/frontend/js_src/lib/components/Preferences/Renderers.tsx @@ -31,9 +31,9 @@ import { rawMenuItemsPromise } from '../Header/menuItemDefinitions'; import { useMenuItems, useUserTools } from '../Header/menuItemProcessing'; import { AttachmentPicker } from '../Molecules/AttachmentPicker'; import { AutoComplete } from '../Molecules/AutoComplete'; -import { userPreferences } from './userPreferences'; import { ListEdit } from '../Toolbar/QueryTablesEdit'; -import { PreferenceItem, PreferenceItemComponent } from './types'; +import type { PreferenceItem, PreferenceItemComponent } from './types'; +import { userPreferences } from './userPreferences'; export const ColorPickerPreferenceItem: PreferenceItemComponent = function ColorPickerPreferenceItem({ diff --git a/specifyweb/frontend/js_src/lib/components/QueryBuilder/AuditLogFormatter.tsx b/specifyweb/frontend/js_src/lib/components/QueryBuilder/AuditLogFormatter.tsx index 6b83c151873..63863bce893 100644 --- a/specifyweb/frontend/js_src/lib/components/QueryBuilder/AuditLogFormatter.tsx +++ b/specifyweb/frontend/js_src/lib/components/QueryBuilder/AuditLogFormatter.tsx @@ -75,7 +75,7 @@ export function getAuditRecordFormatter( Promise.all( resultRow .filter((_, index) => index !== queryIdField) - .map((value, index, row) => { + .map(async (value, index, row) => { if (value === null || value === '') return ''; const stringValue = value.toString(); if (fields[index]?.name === 'fieldName') { diff --git a/specifyweb/frontend/js_src/lib/components/QueryBuilder/Results.tsx b/specifyweb/frontend/js_src/lib/components/QueryBuilder/Results.tsx index 4fa61b5e4d0..153ed36cee9 100644 --- a/specifyweb/frontend/js_src/lib/components/QueryBuilder/Results.tsx +++ b/specifyweb/frontend/js_src/lib/components/QueryBuilder/Results.tsx @@ -102,7 +102,7 @@ export function QueryResults(props: Props): JSX.Element { async () => // Fetch all pick lists so that they are accessible synchronously later Promise.all( - fieldSpecs.map((fieldSpec) => + fieldSpecs.map(async (fieldSpec) => typeof fieldSpec.parser.pickListName === 'string' ? fetchPickList(fieldSpec.parser.pickListName) : undefined @@ -404,7 +404,7 @@ export function useFetchQueryResults({ // Prevent concurrent fetching in different places fetchersRef.current[fetchIndex] ??= fetchResults(fetchIndex) - .then((newResults) => { + .then(async (newResults) => { if ( process.env.NODE_ENV === 'development' && newResults.length > fetchSize diff --git a/specifyweb/frontend/js_src/lib/components/QueryBuilder/ResultsTable.tsx b/specifyweb/frontend/js_src/lib/components/QueryBuilder/ResultsTable.tsx index b4b8209957f..567eecd969e 100644 --- a/specifyweb/frontend/js_src/lib/components/QueryBuilder/ResultsTable.tsx +++ b/specifyweb/frontend/js_src/lib/components/QueryBuilder/ResultsTable.tsx @@ -100,7 +100,7 @@ function Row({ ); const [formattedValues] = useAsyncState( React.useCallback( - () => recordFormatter?.(result), + async () => recordFormatter?.(result), [result, recordFormatter] ), false diff --git a/specifyweb/frontend/js_src/lib/components/Router/OverlayRoutes.tsx b/specifyweb/frontend/js_src/lib/components/Router/OverlayRoutes.tsx index d742743aced..27f9f09001c 100644 --- a/specifyweb/frontend/js_src/lib/components/Router/OverlayRoutes.tsx +++ b/specifyweb/frontend/js_src/lib/components/Router/OverlayRoutes.tsx @@ -1,3 +1,5 @@ +import React from 'react'; + import { commonText } from '../../localization/common'; import { headerText } from '../../localization/header'; import { interactionsText } from '../../localization/interactions'; @@ -8,9 +10,8 @@ import { userText } from '../../localization/user'; import { welcomeText } from '../../localization/welcome'; import { wbText } from '../../localization/workbench'; import type { RA } from '../../utils/types'; -import type { EnhancedRoute } from './RouterUtils'; import { Redirect } from './Redirect'; -import React from 'react'; +import type { EnhancedRoute } from './RouterUtils'; /* eslint-disable @typescript-eslint/promise-function-async */ /** diff --git a/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/Overlay.tsx b/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/Overlay.tsx index 4ffe4cb8c31..b1642a17b4b 100644 --- a/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/Overlay.tsx +++ b/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/Overlay.tsx @@ -90,7 +90,7 @@ export function useMapData( ): BrokerData { const [speciesName] = useAsyncState( React.useCallback( - () => + async () => brokerData?.speciesName ?? (typeof taxonId === 'number' ? fetchResource('Taxon', taxonId).then( diff --git a/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/hooks.tsx b/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/hooks.tsx index 568d85e7842..76e7f880d5d 100644 --- a/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/hooks.tsx +++ b/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/hooks.tsx @@ -22,7 +22,7 @@ export function useSpecies( ): RA | undefined { return useAsyncState( React.useCallback( - () => (speciesName === undefined ? [] : fetchName(speciesName)), + async () => (speciesName === undefined ? [] : fetchName(speciesName)), [speciesName] ), false diff --git a/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/index.tsx b/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/index.tsx index 86c64c9308c..f9f1c0888f1 100644 --- a/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/index.tsx +++ b/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/index.tsx @@ -20,8 +20,8 @@ import type { CollectionObject, Taxon } from '../DataModel/types'; import { Dialog } from '../Molecules/Dialog'; import { TableIcon } from '../Molecules/TableIcon'; import { hasTablePermission } from '../Permissions/helpers'; -import { SpecifyNetworkOverlays } from './Overlay'; import { userPreferences } from '../Preferences/userPreferences'; +import { SpecifyNetworkOverlays } from './Overlay'; export const displaySpecifyNetwork = ( resource: SpecifyResource | undefined diff --git a/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/overlays.ts b/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/overlays.ts index 20224551a70..aa15e30d0c4 100644 --- a/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/overlays.ts +++ b/specifyweb/frontend/js_src/lib/components/SpecifyNetwork/overlays.ts @@ -108,7 +108,7 @@ export function useIdbLayers( scientificName: string | undefined ): BrokerOverlay | undefined { const [layers] = useAsyncState( - React.useCallback(() => { + React.useCallback(async () => { const idbScientificName = extractBrokerField(occurrence ?? [], 'idb', 'dwc:scientificName') ?? scientificName; diff --git a/specifyweb/frontend/js_src/lib/components/SpecifyNetworkCollection/Map.tsx b/specifyweb/frontend/js_src/lib/components/SpecifyNetworkCollection/Map.tsx index 0320160d7f6..44ba7de38fd 100644 --- a/specifyweb/frontend/js_src/lib/components/SpecifyNetworkCollection/Map.tsx +++ b/specifyweb/frontend/js_src/lib/components/SpecifyNetworkCollection/Map.tsx @@ -6,13 +6,13 @@ import { useAsyncState } from '../../hooks/useAsyncState'; import { useTriggerState } from '../../hooks/useTriggerState'; import { ajax } from '../../utils/ajax'; import type { IR } from '../../utils/types'; +import { getLayerPaneZindex } from '../Leaflet'; import type { LeafletInstance } from '../Leaflet/addOns'; import { LeafletMap } from '../Leaflet/Map'; import { loadingGif } from '../Molecules'; import { Range } from '../Molecules/Range'; import { formatUrl } from '../Router/queryString'; import { getGbifLayer } from '../SpecifyNetwork/overlays'; -import { getLayerPaneZindex } from '../Leaflet'; const rangeDefaults = [0, new Date().getFullYear()]; const debounceRate = 500; diff --git a/specifyweb/frontend/js_src/lib/components/Statistics/Pages.tsx b/specifyweb/frontend/js_src/lib/components/Statistics/Pages.tsx index 11a72c4c737..f4f53d3ceae 100644 --- a/specifyweb/frontend/js_src/lib/components/Statistics/Pages.tsx +++ b/specifyweb/frontend/js_src/lib/components/Statistics/Pages.tsx @@ -1,6 +1,6 @@ import { specifyNetworkText } from '../../localization/specifyNetwork'; +import type { IR } from '../../utils/types'; import { SpecifyNetworkCollection } from '../SpecifyNetworkCollection'; -import { IR } from '../../utils/types'; // FIXME: add these pages to the stats page side bar export const extraStatsPages: IR<() => JSX.Element | null> = { 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 0e7101bd1b7..7aa22c6671a 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 @@ -3,8 +3,8 @@ import { theories } from '../../../tests/utils'; import type { RA } from '../../../utils/types'; import type { AutoMapperResults } from '../autoMapper'; import { - AutoMapper as AutoMapperConstructor, type AutoMapperConstructorParameters, + AutoMapper as AutoMapperConstructor, circularTables, } from '../autoMapper'; diff --git a/specifyweb/frontend/js_src/lib/components/WorkBench/Template.tsx b/specifyweb/frontend/js_src/lib/components/WorkBench/Template.tsx index 74a1035d50e..b3a99c10351 100644 --- a/specifyweb/frontend/js_src/lib/components/WorkBench/Template.tsx +++ b/specifyweb/frontend/js_src/lib/components/WorkBench/Template.tsx @@ -171,8 +171,8 @@ function WbView({ {commonText.save()} From c02567134c37a21bd960d632512261cc33b4cede Mon Sep 17 00:00:00 2001 From: Caroline D <108160931+CarolineDenis@users.noreply.github.com> Date: Mon, 22 May 2023 13:55:56 -0700 Subject: [PATCH 7/7] Display PickListEditor in readOnly mode --- .../js_src/lib/components/FormCells/PickListEditor.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx b/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx index 55136019d35..170df029ea9 100644 --- a/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx +++ b/specifyweb/frontend/js_src/lib/components/FormCells/PickListEditor.tsx @@ -47,7 +47,8 @@ export function PickListEditor({ collection={collection} dialog={false} formType="form" - mode="edit" + // FEATURE: change to mode "edit" when #3125 is fixed + mode="view" relationship={relationship} sortField={undefined} onAdd={