From 086d67ffd683e0a2c0b3b2b9410def177b36021c Mon Sep 17 00:00:00 2001 From: Konstantin Markov Date: Thu, 12 Dec 2024 11:38:20 +0200 Subject: [PATCH] Small changes --- .../field-adapters/custom-vocabularies.ts | 6 +++--- .../{profile-converter.ts => profile-fields.ts} | 5 ++++- client/components/planning-editor-standalone/profile.ts | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) rename client/components/planning-editor-standalone/{profile-converter.ts => profile-fields.ts} (89%) diff --git a/client/components/planning-editor-standalone/field-adapters/custom-vocabularies.ts b/client/components/planning-editor-standalone/field-adapters/custom-vocabularies.ts index 053b94189..efe4e3622 100644 --- a/client/components/planning-editor-standalone/field-adapters/custom-vocabularies.ts +++ b/client/components/planning-editor-standalone/field-adapters/custom-vocabularies.ts @@ -1,10 +1,10 @@ import {IDropdownConfigVocabulary, IAuthoringFieldV2, ISubject, IVocabularyItem} from 'superdesk-api'; import {superdeskApi} from '../../../superdeskApi'; import {IFieldDefinition} from '../profile'; -import {getProfileFieldsConverted} from '../profile-converter'; +import {getPlanningProfileFields} from '../profile-fields'; export const getCustomVocabularyFields = () => { - const customVocabularyIds = getProfileFieldsConverted() + const customVocabularyIds = getPlanningProfileFields() .filter((x) => x.type === 'custom_vocabulary') .map(({vocabularyId}) => vocabularyId); const result: Array = []; @@ -37,7 +37,7 @@ export const getCustomVocabularyFields = () => { storageAdapter: { storeValue: (item, operationalValue: IVocabularyItem['qcode']) => { const vocabulary = allVocabularies.get(id); - const vocabItems = vocabulary.items.filter((x) => operationalValue?.includes(x.qcode)) ?? []; + const vocabItems = vocabulary.items.filter((x) => operationalValue.includes(x.qcode)) ?? []; // Subfield values const itemsToSubject: Array = vocabItems.map((x) => ({ diff --git a/client/components/planning-editor-standalone/profile-converter.ts b/client/components/planning-editor-standalone/profile-fields.ts similarity index 89% rename from client/components/planning-editor-standalone/profile-converter.ts rename to client/components/planning-editor-standalone/profile-fields.ts index 36c6ebba0..8ba6b701b 100644 --- a/client/components/planning-editor-standalone/profile-converter.ts +++ b/client/components/planning-editor-standalone/profile-fields.ts @@ -14,7 +14,10 @@ interface ICustomVocabularyField extends IBaseField<'custom_vocabulary'> { type IFieldConverted = IBaseField<'normal'> | ICustomVocabularyField; -export const getProfileFieldsConverted = (): Array => { +/** + * A function that handles planning profile field types so they can be used in authoring react. + */ +export const getPlanningProfileFields = (): Array => { const planningProfile = planningApi.contentProfiles.get('planning'); const planningGroups = getEditorFormGroupsFromProfile(planningProfile); const planningFieldIds = Object.values(planningGroups).flatMap((x) => x.fields); diff --git a/client/components/planning-editor-standalone/profile.ts b/client/components/planning-editor-standalone/profile.ts index 64bf448e4..2f91cf56e 100644 --- a/client/components/planning-editor-standalone/profile.ts +++ b/client/components/planning-editor-standalone/profile.ts @@ -14,7 +14,7 @@ import { IAttachmentsFieldConfig, } from '../../planning-extension/src/authoring-react-fields/planning-attachments/interfaces'; import {getCustomVocabularyFields} from './field-adapters/custom-vocabularies'; -import {getProfileFieldsConverted} from './profile-converter'; +import {getPlanningProfileFields} from './profile-fields'; import {IEventOrPlanningItem} from 'interfaces'; function getTextFieldConfig(options: {id: string; label: string, required: boolean}): IAuthoringFieldV2 { @@ -190,7 +190,7 @@ export function getFieldDefinitions(): IFieldDefinitions { } export function getProfile() { - const planningFieldIds = getProfileFieldsConverted(); + const planningFieldIds = getPlanningProfileFields(); const skipped = new Set(); const fieldDefinitions = getFieldDefinitions(); const profileV2: IContentProfileV2 = {