Skip to content

Commit

Permalink
Introuduce private custom field option (#4314)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc authored Aug 24, 2023
1 parent 7604ef1 commit af8cd7f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export function VocabularyEditController(

const fields = getFields();

$scope.customFieldTypes = Object.keys(fields).map((id) => ({
$scope.customFieldTypes = Object.keys(fields).filter((id) => fields[id].private !== true).map((id) => ({
id: id,
label: fields[id].label,
}));
Expand Down
4 changes: 4 additions & 0 deletions scripts/core/superdesk-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3359,6 +3359,10 @@ declare module 'superdesk-api' {
editorComponent: React.ComponentClass<IEditorComponentProps<IValueOperational, IConfig, IUserPreferences>>;
previewComponent: React.ComponentType<IPreviewComponentProps<IValueOperational, IConfig>>;

/**
* Allows for the field to be hidden from custom field type config
*/
private?: boolean;
/**
* Must return `true` if not empty.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ export type ISubitemsValueOperational = Array<ISubitem>;
export type ISubitemsValueStorage = ISubitemsValueOperational;
export type ISubitemsFieldConfig = never;
export type ISubitemsUserPreferences = never;
export type ISubItemsFieldType = ICustomFieldType<
ISubitemsValueOperational,
ISubitemsValueStorage,
ISubitemsFieldConfig,
ISubitemsUserPreferences
>;

export function getSubItemsField()
: ICustomFieldType<ISubitemsValueOperational, ISubitemsValueStorage, ISubitemsFieldConfig, ISubitemsUserPreferences> {
export function getSubItemsField(): ISubItemsFieldType {
const field: ReturnType<typeof getSubItemsField> = {
id: SUBITEMS_FIELD_TYPE,
label: gettext('Subitems'),
editorComponent: Editor,
previewComponent: Preview,

private: true,
hasValue: (valueOperational) => valueOperational != null && Object.keys(valueOperational).length > 0,
getEmptyValue: () => [],

Expand Down

0 comments on commit af8cd7f

Please sign in to comment.