-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
216 additions
and
32 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
client/components/planning-editor-standalone/field-adapters/custom-vocabularies.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
client/components/planning-editor-standalone/field-definitions/subject.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { | ||
IAuthoringFieldV2, | ||
ISubjectCode, | ||
IDropdownConfigManualSource, | ||
} from 'superdesk-api'; | ||
import {gettext} from 'core/utils'; | ||
import {IFieldDefinition} from './interfaces'; | ||
import {planningApi} from '../../../superdeskApi'; | ||
|
||
export function getSubjectField(): IFieldDefinition { | ||
return { | ||
fieldId: 'subject', | ||
getField: ({id, required}) => { | ||
const fieldConfig: IDropdownConfigManualSource = { | ||
source: 'manual-entry', | ||
options: (planningApi.redux.store.getState().subjects ?? []) | ||
.map((x) => ({id: x.qcode, label: x.name, parent: x.parent})), | ||
roundCorners: true, | ||
type: 'text', | ||
canSelectBranchWithChildren: true, | ||
multiple: true, | ||
required: required, | ||
}; | ||
|
||
const fieldV2: IAuthoringFieldV2 = { | ||
id: 'subject', | ||
name: gettext('Subject'), | ||
fieldType: 'dropdown', | ||
fieldConfig: fieldConfig, | ||
}; | ||
|
||
return fieldV2; | ||
}, | ||
storageAdapter: { | ||
retrieveStoredValue: (item) => { | ||
return (item.subject ?? []).map(({qcode}) => qcode); | ||
}, | ||
storeValue: (item, operationalValue: Array<ISubjectCode['qcode']>) => { | ||
const subjectsFull: Array<ISubjectCode> = (planningApi.redux.store.getState().subjects ?? []) | ||
.filter((x) => operationalValue.includes(x.qcode)); | ||
|
||
return { | ||
...item, | ||
subject: subjectsFull, | ||
}; | ||
}, | ||
} | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters