From 92d2be4f6eb296a10a95df3a4fc9cb53821afd82 Mon Sep 17 00:00:00 2001 From: Siarhei Karol Date: Fri, 22 Nov 2024 15:27:33 +0300 Subject: [PATCH] delete redundant module --- .../EditSection/drawComponentHOC.tsx | 159 ------------------ 1 file changed, 159 deletions(-) delete mode 100644 src/components/EditSection/drawComponentHOC.tsx diff --git a/src/components/EditSection/drawComponentHOC.tsx b/src/components/EditSection/drawComponentHOC.tsx deleted file mode 100644 index 415a9b5e..00000000 --- a/src/components/EditSection/drawComponentHOC.tsx +++ /dev/null @@ -1,159 +0,0 @@ -import { SetterOrUpdater } from 'recoil'; -import { FormattedMessage } from 'react-intl'; -import { GROUP_COMPLEX_CUTOFF_LEVEL } from '@common/constants/bibframe.constants'; -import { AdvancedFieldType } from '@common/constants/uiControls.constants'; -import { EDIT_ALT_DISPLAY_LABELS } from '@common/constants/uiElements.constants'; -import { findParentEntryByProperty } from '@common/helpers/schema.helper'; -import { Button, ButtonType } from '@components/Button'; -import { ComplexLookupField } from '@components/ComplexLookupField'; -import { DropdownField } from '@components/DropdownField'; -import { FieldWithMetadataAndControls } from '@components/FieldWithMetadataAndControls'; -import { LiteralField } from '@components/LiteralField'; -import { SimpleLookupField } from '@components/SimpleLookupField'; - -export type IDrawComponent = { - schema: Map; - entry: SchemaEntry; - disabledFields?: Schema; - level?: number; - isCompact?: boolean; -}; - -type DrawComponentProps = { - selectedEntriesService: ISelectedEntriesService; - selectedEntries: string[]; - setSelectedEntries: SetterOrUpdater; - userValues: UserValues; - collapsedEntries: Set; - collapsibleEntries: Set; - onChange: (uuid: string, contents: UserValueContents[]) => void; - handleGroupsCollapseExpand: VoidFunction; -} - -export const drawComponentHOC = - ({ - selectedEntriesService, - selectedEntries, - setSelectedEntries, - userValues, - collapsedEntries, - collapsibleEntries, - onChange, - handleGroupsCollapseExpand, - }: DrawComponentProps) => - ({ schema, entry, disabledFields, level = 0, isCompact = false }: IDrawComponent) => { - const { uuid, displayName = '', type, children, constraints } = entry; - const isDisabled = !!disabledFields?.get(uuid); - const displayNameWithAltValue = EDIT_ALT_DISPLAY_LABELS[displayName] || displayName; - const selectedUserValue = userValues[uuid]; - - if (type === AdvancedFieldType.block) { - return ( - - {displayNameWithAltValue} - {!!collapsibleEntries.size && ( - - )} - - ); - } - - if ( - (type === AdvancedFieldType.group || type === AdvancedFieldType.groupComplex) && - level < GROUP_COMPLEX_CUTOFF_LEVEL - ) { - const isComplexGroup = type === AdvancedFieldType.groupComplex; - - return ( - - {!isComplexGroup && {displayNameWithAltValue}} - - ); - } - - if (type === AdvancedFieldType.literal) { - return ( - - - - ); - } - - if (type === AdvancedFieldType.dropdown && children) { - const options = children - .map(id => schema.get(id)) - .map(entry => ({ - label: entry?.displayName ?? '', - value: entry?.uri ?? '', // TBD - uri: entry?.uri ?? '', - id: entry?.uuid, - })); - - const selectedOption = options?.find(({ id }) => id && selectedEntries.includes(id)); - - const handleChange = (option: any) => { - selectedEntriesService.addNew(selectedOption?.id, option.id); - - setSelectedEntries(selectedEntriesService.get()); - }; - - return ( - - - - ); - } - - if (type === AdvancedFieldType.simple) { - const blockEntry = findParentEntryByProperty({ - schema, - path: entry.path, - key: 'type', - value: AdvancedFieldType.block, - }); - - return ( - - - - ); - } - - if (type === AdvancedFieldType.complex) { - return ( - - - - ); - } - - return null; - };