From 8728b0190db8e4322fb12e844aeae6e8c39fa5e4 Mon Sep 17 00:00:00 2001 From: Konstantin Markov Date: Tue, 17 Dec 2024 12:17:23 +0200 Subject: [PATCH 1/3] Priority field --- .../field-definitions/index.ts | 2 + .../field-definitions/priority-field.ts | 55 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 client/components/planning-editor-standalone/field-definitions/priority-field.ts diff --git a/client/components/planning-editor-standalone/field-definitions/index.ts b/client/components/planning-editor-standalone/field-definitions/index.ts index 9249ebc71..38c5d6734 100644 --- a/client/components/planning-editor-standalone/field-definitions/index.ts +++ b/client/components/planning-editor-standalone/field-definitions/index.ts @@ -13,6 +13,7 @@ import {getTextFieldConfig} from './text-field-config'; import {getPlaceField} from './place-field'; import {getCategoriesField} from './category-field'; import {getAgendasField} from './agendas-field'; +import {getPriorityField} from './priority-field'; export function getFieldDefinitions(): IFieldDefinitions { const {gettext} = superdeskApi.localization; @@ -68,6 +69,7 @@ export function getFieldDefinitions(): IFieldDefinitions { getPlaceField(), getAgendasField(), getCategoriesField(), + getPriorityField(), { fieldId: 'coverages', getField: ({id, required}) => { diff --git a/client/components/planning-editor-standalone/field-definitions/priority-field.ts b/client/components/planning-editor-standalone/field-definitions/priority-field.ts new file mode 100644 index 000000000..3c0bbea12 --- /dev/null +++ b/client/components/planning-editor-standalone/field-definitions/priority-field.ts @@ -0,0 +1,55 @@ +import {IAuthoringFieldV2, IDropdownConfigManualSource} from 'superdesk-api'; +import {IFieldDefinition} from './interfaces'; +import {superdeskApi} from '../../../superdeskApi'; + +export const getPriorityField = (): IFieldDefinition => { + const {gettext} = superdeskApi.localization; + + return { + fieldId: 'priority', + getField: ({id, required}) => { + const fieldConfig: IDropdownConfigManualSource = { + source: 'manual-entry', + options: [ + { + id: '1', + label: gettext('1'), + }, + { + id: '2', + label: gettext('2'), + }, + { + id: '3', + label: gettext('3'), + }, + { + id: '4', + label: gettext('4'), + }, + { + id: '5', + label: gettext('5'), + }, + { + id: '6', + label: gettext('6'), + }, + ], + roundCorners: true, + type: 'text', + multiple: false, + required: required, + }; + + const field: IAuthoringFieldV2 = { + id: id, + name: gettext('Priority'), + fieldType: 'dropdown', + fieldConfig: fieldConfig, + }; + + return field; + }, + }; +}; From 2fe4be96d0117b15ef312b75c40c0df434e7fad6 Mon Sep 17 00:00:00 2001 From: Konstantin Markov Date: Tue, 17 Dec 2024 12:17:28 +0200 Subject: [PATCH 2/3] Fix import --- .../field-adapters/custom-vocabularies.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e9e3f41c9..dd18dcd77 100644 --- a/client/components/planning-editor-standalone/field-adapters/custom-vocabularies.ts +++ b/client/components/planning-editor-standalone/field-adapters/custom-vocabularies.ts @@ -1,6 +1,6 @@ import {IDropdownConfigVocabulary, IAuthoringFieldV2, ISubject, IVocabularyItem} from 'superdesk-api'; import {superdeskApi} from '../../../superdeskApi'; -import {IFieldDefinition} from '../profile'; +import {IFieldDefinition} from '../field-definitions/interfaces'; import {getPlanningProfileFields} from '../profile-fields'; export const getCustomVocabularyFields = () => { From aeb8fc05cf14fe8d8bfd4cc8172b6161ffe01f67 Mon Sep 17 00:00:00 2001 From: Konstantin Markov Date: Wed, 18 Dec 2024 13:12:22 +0200 Subject: [PATCH 3/3] Change option source --- .../field-definitions/priority-field.ts | 34 ++++--------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/client/components/planning-editor-standalone/field-definitions/priority-field.ts b/client/components/planning-editor-standalone/field-definitions/priority-field.ts index 3c0bbea12..8c943ab3e 100644 --- a/client/components/planning-editor-standalone/field-definitions/priority-field.ts +++ b/client/components/planning-editor-standalone/field-definitions/priority-field.ts @@ -1,6 +1,6 @@ import {IAuthoringFieldV2, IDropdownConfigManualSource} from 'superdesk-api'; import {IFieldDefinition} from './interfaces'; -import {superdeskApi} from '../../../superdeskApi'; +import {planningApi, superdeskApi} from '../../../superdeskApi'; export const getPriorityField = (): IFieldDefinition => { const {gettext} = superdeskApi.localization; @@ -8,34 +8,14 @@ export const getPriorityField = (): IFieldDefinition => { return { fieldId: 'priority', getField: ({id, required}) => { + const options = planningApi.redux.store.getState().vocabularies.priority.map((x) => ({ + id: x.qcode, + label: x.name, + })); + const fieldConfig: IDropdownConfigManualSource = { source: 'manual-entry', - options: [ - { - id: '1', - label: gettext('1'), - }, - { - id: '2', - label: gettext('2'), - }, - { - id: '3', - label: gettext('3'), - }, - { - id: '4', - label: gettext('4'), - }, - { - id: '5', - label: gettext('5'), - }, - { - id: '6', - label: gettext('6'), - }, - ], + options: options, roundCorners: true, type: 'text', multiple: false,