Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agenda field port #2155

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 32 additions & 2 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 Down Expand Up @@ -172,7 +174,35 @@ 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,
width: 100,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

width is being overwritten at the bottom so better leave it out

};

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

return field;
},
},
];

result.push(
Expand Down
Loading