Skip to content

Commit

Permalink
Agenda field port (#2155)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc authored Dec 12, 2024
1 parent d0cd58a commit 0c498a7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
3 changes: 1 addition & 2 deletions client/components/fields/editor/CustomVocabularies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {superdeskApi} from '../../../superdeskApi';
import {IEditorFieldProps, IProfileSchemaTypeList} from '../../../interfaces';
import {Row} from '../../UI/Form';
import {getVocabularyItemFieldTranslated} from '../../../utils/vocabularies';
import {arrayToTree} from 'superdesk-core/scripts/core/helpers/tree';
import {TreeSelect} from 'superdesk-ui-framework/react';

export interface ICustomVocabulariesProps extends IEditorFieldProps {
Expand Down Expand Up @@ -61,7 +60,7 @@ class CustomVocabulariesComponent extends React.PureComponent<IProps> {
value={(item.subject ?? []).filter((x) => x.scheme === cv._id)}
label={gettext(cv.display_name)}
required={required ?? schema?.required}
getOptions={() => arrayToTree(
getOptions={() => superdeskApi.utilities.arrayToTree(
cv.items.map((cvItem) => ({
...cvItem,
scheme: cv._id,
Expand Down
34 changes: 31 additions & 3 deletions client/components/planning-editor-standalone/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ import {
ICommonFieldConfig,
IContentProfileV2,
IDateTimeFieldConfig,
IDropdownConfigManualSource,
IDropdownConfigVocabulary,
IEditor3Config,
IVocabularyItem,
} from 'superdesk-api';
import {superdeskApi} from '../../superdeskApi';
import {planningApi, superdeskApi} from '../../superdeskApi';
import {
IAttachmentsFieldConfig,
} from '../../planning-extension/src/authoring-react-fields/planning-attachments/interfaces';
import {getCustomVocabularyFields} from './field-adapters/custom-vocabularies';
import {getPlanningProfileFields} from './profile-fields';
import {IAgenda} from 'interfaces';

function getTextFieldConfig(options: {id: string; label: string, required: boolean}): IAuthoringFieldV2 {
const editor3ConfigWithoutFormatting: IEditor3Config = {
Expand All @@ -25,7 +27,6 @@ function getTextFieldConfig(options: {id: string; label: string, required: boole
singleLine: true,
disallowedCharacters: [],
showStatistics: false,
width: 100,
};

const field: IAuthoringFieldV2 = {
Expand Down Expand Up @@ -172,7 +173,34 @@ export function getFieldDefinitions(): IFieldDefinitions {

return field;
},
}
},
{
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;
},
},
];

result.push(
Expand Down

0 comments on commit 0c498a7

Please sign in to comment.