diff --git a/client/components/planning-editor-standalone/field-definitions/agendas-field.ts b/client/components/planning-editor-standalone/field-definitions/agendas-field.ts new file mode 100644 index 000000000..9281f7017 --- /dev/null +++ b/client/components/planning-editor-standalone/field-definitions/agendas-field.ts @@ -0,0 +1,33 @@ +import {IAgenda} from 'interfaces'; +import {IDropdownConfigManualSource, IAuthoringFieldV2} from 'superdesk-api'; +import {planningApi} from 'superdeskApi'; +import {gettext} from 'utils'; +import {IFieldDefinition} from './interfaces'; + +export const getAgendasField = (): IFieldDefinition => ({ + fieldId: 'agendas', + getField: ({id, required}) => { + const fieldConfig: IDropdownConfigManualSource = { + source: 'manual-entry', + options: ((planningApi.redux.store.getState().agenda.agendas ?? []) as Array) + .filter((item) => item.is_enabled) + .map((item) => ({ + id: item._id, + label: item.name, + })), + roundCorners: true, + type: 'text', + multiple: true, + required: required, + }; + + const field: IAuthoringFieldV2 = { + id: id, + name: gettext('Agendas'), + fieldType: 'dropdown', + fieldConfig: fieldConfig, + }; + + return field; + }, +}); diff --git a/client/components/planning-editor-standalone/field-definitions/index.ts b/client/components/planning-editor-standalone/field-definitions/index.ts index 6d16d5b5b..b71d36fe6 100644 --- a/client/components/planning-editor-standalone/field-definitions/index.ts +++ b/client/components/planning-editor-standalone/field-definitions/index.ts @@ -11,8 +11,7 @@ import {getDateTimeField} from './date-time-config'; import {IFieldDefinitions, IFieldDefinition} from './interfaces'; import {getTextFieldConfig} from './text-field-config'; import {getPlaceField} from './place-field'; - -export type IFieldGetter = () => IFieldDefinition; +import {getAgendasField} from './agendas-field'; export function getFieldDefinitions(): IFieldDefinitions { const {gettext} = superdeskApi.localization; @@ -66,6 +65,7 @@ export function getFieldDefinitions(): IFieldDefinitions { }, }, getPlaceField(), + getAgendasField(), { 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..28df5ef8a 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,8 @@ import {IDropdownConfigVocabulary, IAuthoringFieldV2, IVocabularyItem} from 'superdesk-api'; import {superdeskApi} from '../../../superdeskApi'; -import {IFieldGetter} from '.'; +import {IFieldDefinition} from './interfaces'; -export const getPlaceField: IFieldGetter = () => ({ +export const getPlaceField = (): IFieldDefinition => ({ fieldId: 'place', getField: ({id, required}) => { const fieldConfig: IDropdownConfigVocabulary = {