diff --git a/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts b/specifyweb/frontend/js_src/lib/components/DataModel/businessRuleDefs.ts index b6a57e9ce67..1539ba341f6 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, 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