Skip to content

Commit

Permalink
Changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc committed Dec 13, 2024
1 parent b204fa6 commit df8c709
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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<IAgenda>)
.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;
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -66,6 +65,7 @@ export function getFieldDefinitions(): IFieldDefinitions {
},
},
getPlaceField(),
getAgendasField(),
{
fieldId: 'coverages',
getField: ({id, required}) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down

0 comments on commit df8c709

Please sign in to comment.