Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc committed Dec 12, 2024
1 parent 5abbdc9 commit 086d67f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {IDropdownConfigVocabulary, IAuthoringFieldV2, ISubject, IVocabularyItem} from 'superdesk-api';
import {superdeskApi} from '../../../superdeskApi';
import {IFieldDefinition} from '../profile';
import {getProfileFieldsConverted} from '../profile-converter';
import {getPlanningProfileFields} from '../profile-fields';

export const getCustomVocabularyFields = () => {
const customVocabularyIds = getProfileFieldsConverted()
const customVocabularyIds = getPlanningProfileFields()
.filter((x) => x.type === 'custom_vocabulary')
.map(({vocabularyId}) => vocabularyId);
const result: Array<IFieldDefinition> = [];
Expand Down Expand Up @@ -37,7 +37,7 @@ export const getCustomVocabularyFields = () => {
storageAdapter: {
storeValue: (item, operationalValue: IVocabularyItem['qcode']) => {
const vocabulary = allVocabularies.get(id);
const vocabItems = vocabulary.items.filter((x) => operationalValue?.includes(x.qcode)) ?? [];
const vocabItems = vocabulary.items.filter((x) => operationalValue.includes(x.qcode)) ?? [];

// Subfield values
const itemsToSubject: Array<ISubject> = vocabItems.map((x) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ interface ICustomVocabularyField extends IBaseField<'custom_vocabulary'> {

type IFieldConverted = IBaseField<'normal'> | ICustomVocabularyField;

export const getProfileFieldsConverted = (): Array<IFieldConverted> => {
/**
* A function that handles planning profile field types so they can be used in authoring react.
*/
export const getPlanningProfileFields = (): Array<IFieldConverted> => {
const planningProfile = planningApi.contentProfiles.get('planning');
const planningGroups = getEditorFormGroupsFromProfile(planningProfile);
const planningFieldIds = Object.values(planningGroups).flatMap((x) => x.fields);
Expand Down
4 changes: 2 additions & 2 deletions client/components/planning-editor-standalone/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
IAttachmentsFieldConfig,
} from '../../planning-extension/src/authoring-react-fields/planning-attachments/interfaces';
import {getCustomVocabularyFields} from './field-adapters/custom-vocabularies';
import {getProfileFieldsConverted} from './profile-converter';
import {getPlanningProfileFields} from './profile-fields';
import {IEventOrPlanningItem} from 'interfaces';

function getTextFieldConfig(options: {id: string; label: string, required: boolean}): IAuthoringFieldV2 {
Expand Down Expand Up @@ -190,7 +190,7 @@ export function getFieldDefinitions(): IFieldDefinitions {
}

export function getProfile() {
const planningFieldIds = getProfileFieldsConverted();
const planningFieldIds = getPlanningProfileFields();
const skipped = new Set<string>();
const fieldDefinitions = getFieldDefinitions();
const profileV2: IContentProfileV2 = {
Expand Down

0 comments on commit 086d67f

Please sign in to comment.