Skip to content

Commit

Permalink
Revert "Categories field implementation"
Browse files Browse the repository at this point in the history
This reverts commit a5b7c74.
  • Loading branch information
thecalcc committed Dec 12, 2024
1 parent a5b7c74 commit ca97a80
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 53 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import {getDateTimeField} from './date-time-config';
import {IFieldDefinitions, IFieldDefinition} from './interfaces';
import {getTextFieldConfig} from './text-field-config';
import {getPlaceField} from './place-field';
import {getCategoriesField} from './category-field';

export type IFieldGetter = () => IFieldDefinition;

export function getFieldDefinitions(): IFieldDefinitions {
const {gettext} = superdeskApi.localization;
Expand Down Expand Up @@ -66,8 +63,7 @@ export function getFieldDefinitions(): IFieldDefinitions {
return field;
},
},
getPlaceField(),
getCategoriesField(),
getPlaceField(gettext),
{
fieldId: 'coverages',
getField: ({id, required}) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {IDropdownConfigVocabulary, IAuthoringFieldV2, IVocabularyItem} from 'superdesk-api';
import {superdeskApi} from '../../../superdeskApi';
import {IFieldGetter} from '.';

export const getPlaceField: IFieldGetter = () => ({
export const getPlaceField = (gettext: (val: string) => string) => ({
fieldId: 'place',
getField: ({id, required}) => {
const fieldConfig: IDropdownConfigVocabulary = {
Expand All @@ -14,7 +13,7 @@ export const getPlaceField: IFieldGetter = () => ({

const field: IAuthoringFieldV2 = {
id: id,
name: superdeskApi.localization.gettext('Place'),
name: gettext('Place'),
fieldType: 'dropdown',
fieldConfig: fieldConfig,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {flatMap} from 'lodash';
import {planningApi} from '../../superdeskApi';
import {getEditorFormGroupsFromProfile} from '../../utils/contentProfiles';

Expand All @@ -13,18 +14,13 @@ interface ICustomVocabularyField extends IBaseField<'custom_vocabulary'> {

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

const FIELDS_TO_FILTER = [
'associated_event',
];

/**
* 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)
.filter((x) => !FIELDS_TO_FILTER.includes(x));
const planningFieldIds = Object.values(planningGroups).flatMap((x) => x.fields);
const convertedFieldIds: Array<IFieldConverted> = [];

for (const fieldId of planningFieldIds) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
IStorageAdapter,
} from 'superdesk-api';
import {superdeskApi} from '../../superdeskApi';
import {getFieldDefinitions} from './field-definitions/index';
import {getFieldDefinitions} from './profile';

export const storageAdapterPlanningItem: IStorageAdapter<IPlanningItem> = {
storeValue: (value, fieldId, item, config, fieldType) => {
Expand Down

0 comments on commit ca97a80

Please sign in to comment.