diff --git a/client/components/planning-editor-standalone/field-definitions/category-field.ts b/client/components/planning-editor-standalone/field-definitions/category-field.ts deleted file mode 100644 index 5ad76bacf..000000000 --- a/client/components/planning-editor-standalone/field-definitions/category-field.ts +++ /dev/null @@ -1,38 +0,0 @@ -import {IDropdownConfigVocabulary, IAuthoringFieldV2, IVocabularyItem} from 'superdesk-api'; -import {superdeskApi} from '../../../superdeskApi'; -import {IFieldGetter} from '.'; - -export const getCategoriesField: IFieldGetter = () => ({ - fieldId: 'anpa_category', - getField: ({id, required}) => { - const fieldConfig: IDropdownConfigVocabulary = { - source: 'vocabulary', - vocabularyId: 'categories', - multiple: true, - required: required, - }; - - const field: IAuthoringFieldV2 = { - id: id, - name: superdeskApi.localization.gettext('Categories'), - fieldType: 'dropdown', - fieldConfig: fieldConfig, - }; - - return field; - }, - storageAdapter: { - storeValue: (item, operationalValue: Array) => { - const vocabulary = superdeskApi.entities.vocabulary.getAll().get('categories'); - const vocabularyItems = new Map( - vocabulary.items.map((item) => [item.qcode, item]), - ); - - return { - ...item, - anpa_category: operationalValue.map((qcode) => vocabularyItems.get(qcode)), - }; - }, - retrieveStoredValue: (item, fieldId) => (item[fieldId] ?? []).map(({qcode}) => qcode), - }, -}); diff --git a/client/components/planning-editor-standalone/field-definitions/index.ts b/client/components/planning-editor-standalone/field-definitions/index.ts index d331b38ce..def4aac08 100644 --- a/client/components/planning-editor-standalone/field-definitions/index.ts +++ b/client/components/planning-editor-standalone/field-definitions/index.ts @@ -11,9 +11,6 @@ import {getDateTimeField} from './date-time-config'; import {IFieldDefinitions, IFieldDefinition} from './interfaces'; import {getTextFieldConfig} from './text-field-config'; import {getPlaceField} from './place-field'; -import {getCategoriesField} from './category-field'; - -export type IFieldGetter = () => IFieldDefinition; export function getFieldDefinitions(): IFieldDefinitions { const {gettext} = superdeskApi.localization; @@ -66,8 +63,7 @@ export function getFieldDefinitions(): IFieldDefinitions { return field; }, }, - getPlaceField(), - getCategoriesField(), + getPlaceField(gettext), { fieldId: 'coverages', getField: ({id, required}) => { diff --git a/client/components/planning-editor-standalone/field-definitions/place-field.ts b/client/components/planning-editor-standalone/field-definitions/place-field.ts index 24b3c8037..17279189c 100644 --- a/client/components/planning-editor-standalone/field-definitions/place-field.ts +++ b/client/components/planning-editor-standalone/field-definitions/place-field.ts @@ -1,8 +1,7 @@ import {IDropdownConfigVocabulary, IAuthoringFieldV2, IVocabularyItem} from 'superdesk-api'; import {superdeskApi} from '../../../superdeskApi'; -import {IFieldGetter} from '.'; -export const getPlaceField: IFieldGetter = () => ({ +export const getPlaceField = (gettext: (val: string) => string) => ({ fieldId: 'place', getField: ({id, required}) => { const fieldConfig: IDropdownConfigVocabulary = { @@ -14,7 +13,7 @@ export const getPlaceField: IFieldGetter = () => ({ const field: IAuthoringFieldV2 = { id: id, - name: superdeskApi.localization.gettext('Place'), + name: gettext('Place'), fieldType: 'dropdown', fieldConfig: fieldConfig, }; diff --git a/client/components/planning-editor-standalone/profile-fields.ts b/client/components/planning-editor-standalone/profile-fields.ts index dc26ead20..8ba6b701b 100644 --- a/client/components/planning-editor-standalone/profile-fields.ts +++ b/client/components/planning-editor-standalone/profile-fields.ts @@ -1,3 +1,4 @@ +import {flatMap} from 'lodash'; import {planningApi} from '../../superdeskApi'; import {getEditorFormGroupsFromProfile} from '../../utils/contentProfiles'; @@ -13,18 +14,13 @@ interface ICustomVocabularyField extends IBaseField<'custom_vocabulary'> { type IFieldConverted = IBaseField<'normal'> | ICustomVocabularyField; -const FIELDS_TO_FILTER = [ - 'associated_event', -]; - /** * 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) - .filter((x) => !FIELDS_TO_FILTER.includes(x)); + const planningFieldIds = Object.values(planningGroups).flatMap((x) => x.fields); const convertedFieldIds: Array = []; for (const fieldId of planningFieldIds) { diff --git a/client/components/planning-editor-standalone/storage-adapter.ts b/client/components/planning-editor-standalone/storage-adapter.ts index e8118d10a..663746422 100644 --- a/client/components/planning-editor-standalone/storage-adapter.ts +++ b/client/components/planning-editor-standalone/storage-adapter.ts @@ -6,7 +6,7 @@ import { IStorageAdapter, } from 'superdesk-api'; import {superdeskApi} from '../../superdeskApi'; -import {getFieldDefinitions} from './field-definitions/index'; +import {getFieldDefinitions} from './profile'; export const storageAdapterPlanningItem: IStorageAdapter = { storeValue: (value, fieldId, item, config, fieldType) => {