Skip to content

Commit

Permalink
Priority field (#2161)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc authored Dec 18, 2024
1 parent c34d535 commit b7d729b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -68,6 +69,7 @@ export function getFieldDefinitions(): IFieldDefinitions {
getPlaceField(),
getAgendasField(),
getCategoriesField(),
getPriorityField(),
{
fieldId: 'coverages',
getField: ({id, required}) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {IAuthoringFieldV2, IDropdownConfigManualSource} from 'superdesk-api';
import {IFieldDefinition} from './interfaces';
import {planningApi, superdeskApi} from '../../../superdeskApi';

export const getPriorityField = (): IFieldDefinition => {
const {gettext} = superdeskApi.localization;

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: options,
roundCorners: true,
type: 'text',
multiple: false,
required: required,
};

const field: IAuthoringFieldV2 = {
id: id,
name: gettext('Priority'),
fieldType: 'dropdown',
fieldConfig: fieldConfig,
};

return field;
},
};
};

0 comments on commit b7d729b

Please sign in to comment.