Skip to content

Commit

Permalink
Merge pull request #4905 from specify/issue-4012
Browse files Browse the repository at this point in the history
Prevent from carrying preps in interaction during cloning
  • Loading branch information
CarolineDenis authored Jul 1, 2024
2 parents a991a42 + 6410fdc commit 080b32c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions specifyweb/frontend/js_src/lib/components/DataModel/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ import { f } from '../../utils/functools';
import type { DeepPartial, RA, RR } from '../../utils/types';
import { defined, filterArray } from '../../utils/types';
import { keysToLowerCase, removeKey } from '../../utils/utils';
import type { InteractionWithPreps } from '../Interactions/helpers';
import {
interactionPrepTables,
interactionsWithPrepTables,
} from '../Interactions/helpers';
import { userPreferences } from '../Preferences/userPreferences';
import { formatUrl } from '../Router/queryString';
import { relationshipIsToMany } from '../WbPlanView/mappingHelpers';
import { addMissingFields } from './addMissingFields';
import { getFieldsFromPath } from './businessRules';
import type {
AnyInteractionPreparation,
AnySchema,
SerializedRecord,
SerializedResource,
Expand Down Expand Up @@ -293,6 +299,22 @@ export const getUniqueFields = (table: SpecifyTable): RA<string> =>
...table.relationships
.filter(({ relatedTable }) => relatedTable.name.endsWith('Attachment'))
.map(({ name }) => name),
/*
* Interaction Preparations should be considered unique for each
* Interaction
* See https://github.com/specify/specify7/issues/4012
*/
...table.relationships
.filter(
({ relatedTable }) =>
interactionsWithPrepTables.includes(
table.name as InteractionWithPreps['tableName']
) &&
interactionPrepTables.includes(
relatedTable.name as AnyInteractionPreparation['tableName']
)
)
.map(({ name }) => name),
...filterArray(
uniqueFields.map((fieldName) => table.getField(fieldName)?.name)
),
Expand Down

0 comments on commit 080b32c

Please sign in to comment.