From b636151aacef304adc3c6536e92f9290fcef4982 Mon Sep 17 00:00:00 2001 From: Iwantexpresso Date: Thu, 18 Dec 2025 11:06:56 -0600 Subject: [PATCH 1/8] added check if min attribute is present then runs either save blocker text of html 5 validation to avoid both of them running --- .../lib/components/DataModel/businessRuleDefs.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts b/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts index b6a57e9ce67..6ec28630cfb 100644 --- a/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts +++ b/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts @@ -758,13 +758,24 @@ export const businessRuleDefs: MappedBusinessRuleDefs = { totalPrepLoaned += quantity; }); + // Check for min attribute on countAmt input field after rendering + const inputs = document.querySelectorAll( + `input[name="countAmt"]` + ); + const firstInput = inputs[0]; + const minValue= firstInput?.getAttribute('min'); + const hasMinAttribute = ( minValue !== null && minValue >= '0'); + // modified save blocker logic to consider min attribute and choose either the blocker for negative prepr or HTML min attribute to avoid conflict + if (totalPrep < 0) { + if (!hasMinAttribute) { setSaveBlockers( prep, prep.specifyTable.field.countAmt, [resourcesText.preparationIsNegative()], PREPARATION_NEGATIVE_KEY ); + } } else if (totalPrep < totalPrepLoaned) { setSaveBlockers( prep, From b8380534d996eb46008d8be5351b13fb2d5032aa Mon Sep 17 00:00:00 2001 From: Iwantexpresso Date: Thu, 18 Dec 2025 17:11:13 +0000 Subject: [PATCH 2/8] Lint code with ESLint and Prettier Triggered by b636151aacef304adc3c6536e92f9290fcef4982 on branch refs/heads/issue-7156 --- .../js_src/lib/components/DataModel/businessRuleDefs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts b/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts index 6ec28630cfb..1539ba341f6 100644 --- a/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts +++ b/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts @@ -765,7 +765,7 @@ export const businessRuleDefs: MappedBusinessRuleDefs = { const firstInput = inputs[0]; const minValue= firstInput?.getAttribute('min'); const hasMinAttribute = ( minValue !== null && minValue >= '0'); - // modified save blocker logic to consider min attribute and choose either the blocker for negative prepr or HTML min attribute to avoid conflict + // Modified save blocker logic to consider min attribute and choose either the blocker for negative prepr or HTML min attribute to avoid conflict if (totalPrep < 0) { if (!hasMinAttribute) { From 3b01971585e37f73a7446e17c2e6e3c04b95b268 Mon Sep 17 00:00:00 2001 From: Iwantexpresso <99292736+Iwantexpresso@users.noreply.github.com> Date: Thu, 18 Dec 2025 18:02:42 +0000 Subject: [PATCH 3/8] Lint code with ESLint and Prettier Triggered by 7f72143f046ce66f7afecf3e06b1eaf869a34dd7 on branch refs/heads/issue-7156 --- .../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 3a1a46d57cdeb561c1a0d5c7f436fc2dbeb0cb79 Mon Sep 17 00:00:00 2001 From: Iwantexpresso Date: Tue, 30 Dec 2025 12:34:00 -0600 Subject: [PATCH 4/8] removed previous flimsy implementation and added a more robust check within useValidation --- .../lib/components/DataModel/businessRuleDefs.ts | 11 ----------- .../frontend/js_src/lib/hooks/useValidation.tsx | 13 ++++++++++++- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts b/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts index 1539ba341f6..b6a57e9ce67 100644 --- a/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts +++ b/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts @@ -758,24 +758,13 @@ export const businessRuleDefs: MappedBusinessRuleDefs = { totalPrepLoaned += quantity; }); - // Check for min attribute on countAmt input field after rendering - const inputs = document.querySelectorAll( - `input[name="countAmt"]` - ); - const firstInput = inputs[0]; - const minValue= firstInput?.getAttribute('min'); - const hasMinAttribute = ( minValue !== null && minValue >= '0'); - // Modified save blocker logic to consider min attribute and choose either the blocker for negative prepr or HTML min attribute to avoid conflict - if (totalPrep < 0) { - if (!hasMinAttribute) { setSaveBlockers( prep, prep.specifyTable.field.countAmt, [resourcesText.preparationIsNegative()], PREPARATION_NEGATIVE_KEY ); - } } else if (totalPrep < totalPrepLoaned) { setSaveBlockers( prep, diff --git a/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx b/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx index 7d156f2fc8a..adcc19d5534 100644 --- a/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx +++ b/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx @@ -97,8 +97,19 @@ export function useValidation( // Do not steal focus when form rendering the form in the form editor if (isInFormEditor) return; + // Check for native validation errors for Negative Number fields Could be extended to other types as needed + const hasNativeErrors = + input.validity.rangeOverflow || + input.validity.rangeUnderflow || + input.validity.valueMissing; + // Empty string clears validation error - input.setCustomValidity(joined); + // now checks for custom validity and clears it to prevent concatenation of both validity messages + if (hasNativeErrors) { + input.setCustomValidity(''); + } else{ + input.setCustomValidity(joined); + } if ( type === 'focus' || From 09bf4aa044289a29002ffc518706709d56bb7877 Mon Sep 17 00:00:00 2001 From: Iwantexpresso Date: Tue, 30 Dec 2025 18:37:54 +0000 Subject: [PATCH 5/8] Lint code with ESLint and Prettier Triggered by 3a1a46d57cdeb561c1a0d5c7f436fc2dbeb0cb79 on branch refs/heads/issue-7156 --- .../frontend/js_src/lib/hooks/useValidation.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx b/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx index adcc19d5534..1644fc02f78 100644 --- a/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx +++ b/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx @@ -99,15 +99,17 @@ export function useValidation( // Check for native validation errors for Negative Number fields Could be extended to other types as needed const hasNativeErrors = - input.validity.rangeOverflow || - input.validity.rangeUnderflow || - input.validity.valueMissing; - - // Empty string clears validation error - // now checks for custom validity and clears it to prevent concatenation of both validity messages + input.validity.rangeOverflow || + input.validity.rangeUnderflow || + input.validity.valueMissing; + + /* + * Empty string clears validation error + * now checks for custom validity and clears it to prevent concatenation of both validity messages + */ if (hasNativeErrors) { input.setCustomValidity(''); - } else{ + } else { input.setCustomValidity(joined); } From 3d6993401a50188fbc4066bf6ece9f55f55661f0 Mon Sep 17 00:00:00 2001 From: Iwantexpresso <99292736+Iwantexpresso@users.noreply.github.com> Date: Tue, 30 Dec 2025 22:06:35 +0000 Subject: [PATCH 6/8] Lint code with ESLint and Prettier Triggered by b135731c8e7448cd6f95332c14e5f7ba13f511de on branch refs/heads/issue-7156 --- .../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, + * }, + * }, + */ ], }, { From d664be456ff99a48b0de963e007224c9953001c4 Mon Sep 17 00:00:00 2001 From: Iwantexpresso Date: Wed, 7 Jan 2026 12:48:34 -0600 Subject: [PATCH 7/8] used existing hasNativeErros functions instead of previous custom const --- .../frontend/js_src/lib/hooks/useValidation.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx b/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx index 1644fc02f78..979e10be57c 100644 --- a/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx +++ b/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx @@ -2,10 +2,11 @@ import React from 'react'; import { InFormEditorContext } from '../components/FormEditor/Context'; import type { Input } from '../components/Forms/validationHelpers'; -import { isInputTouched } from '../components/Forms/validationHelpers'; +import { hasNativeErrors, isInputTouched } from '../components/Forms/validationHelpers'; import { listen } from '../utils/events'; import type { RA } from '../utils/types'; + /** * An integration into native browser error reporting mechanism. * Can set an error message via prop or callback. @@ -97,17 +98,12 @@ export function useValidation( // Do not steal focus when form rendering the form in the form editor if (isInFormEditor) return; - // Check for native validation errors for Negative Number fields Could be extended to other types as needed - const hasNativeErrors = - input.validity.rangeOverflow || - input.validity.rangeUnderflow || - input.validity.valueMissing; - /* * Empty string clears validation error - * now checks for custom validity and clears it to prevent concatenation of both validity messages + * simple check for HTML validation, through hasNativeErrors and prevents from both Validators to be active simultaneously + * */ - if (hasNativeErrors) { + if (hasNativeErrors(input)) { input.setCustomValidity(''); } else { input.setCustomValidity(joined); From 1da5df406d078eb844994941990bf892c9799725 Mon Sep 17 00:00:00 2001 From: Iwantexpresso Date: Wed, 7 Jan 2026 13:13:46 -0600 Subject: [PATCH 8/8] comment and newline cleanup --- specifyweb/frontend/js_src/lib/hooks/useValidation.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx b/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx index 979e10be57c..522842a52c8 100644 --- a/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx +++ b/specifyweb/frontend/js_src/lib/hooks/useValidation.tsx @@ -6,7 +6,6 @@ import { hasNativeErrors, isInputTouched } from '../components/Forms/validationH import { listen } from '../utils/events'; import type { RA } from '../utils/types'; - /** * An integration into native browser error reporting mechanism. * Can set an error message via prop or callback. @@ -100,8 +99,7 @@ export function useValidation( /* * Empty string clears validation error - * simple check for HTML validation, through hasNativeErrors and prevents from both Validators to be active simultaneously - * + * simple check for HTML validation, through hasNativeErrors and prevents from both Validators to be active simultaneously */ if (hasNativeErrors(input)) { input.setCustomValidity('');