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

Improve documentation of generic fields #4651

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions scripts/apps/authoring-react/fields/attachments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ export const ATTACHMENTS_WIDGET_ID = 'attachments';
export function getAttachmentsField(): IAttachmentsField {
const field: IAttachmentsField = {
id: ATTACHMENTS_FIELD_ID,

/**
* Not generic due to:
* - having a hardcoded fieldId in a side-widget
*
* Could be made generic by getting rid of side-widget
* or changing side-widget to support multiple fields.
*/
generic: false,

label: gettext('Attachments (authoring-react)'),
editorComponent: Editor,
previewComponent: Preview,
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/authoring-react/fields/date/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function getDateField()
: ICustomFieldType<IDateValueOperational, IDateValueStorage, IDateFieldConfig, IDateUserPreferences> {
const field: ICustomFieldType<IDateValueOperational, IDateValueStorage, IDateFieldConfig, IDateUserPreferences> = {
id: DATE_FIELD_ID,
generic: true,
label: gettext('Date (authoring-react)'),
editorComponent: Editor,
previewComponent: Preview,
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/authoring-react/fields/dateline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function getDatelineField()
: DatelineFieldType {
const field: DatelineFieldType = {
id: DATELINE_FIELD_ID,
generic: true,
label: gettext('Dateline (authoring-react)'),
editorComponent: Editor,
previewComponent: Preview,
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/authoring-react/fields/dropdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const DROPDOWN_FIELD_ID = 'dropdown';
export function getDropdownField(): ICustomFieldType<IDropdownValue, IDropdownValue, IDropdownConfig, never> {
const field: ICustomFieldType<IDropdownValue, IDropdownValue, IDropdownConfig, never> = {
id: 'dropdown',
generic: true,
label: gettext('Dropdown (authoring-react)'),
editorComponent: Editor,
previewComponent: Preview,
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/authoring-react/fields/duration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function geDurationField()
: ICustomFieldType<IDurationValueOperational, IDurationValueStorage, IDurationFieldConfig, IDurationUserPreferences> {
const field: ReturnType<typeof geDurationField> = {
id: DURATION_FIELD_ID,
generic: true,
label: gettext('Duration (authoring-react)'),
editorComponent: Editor,
previewComponent: Preview,
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/authoring-react/fields/editor3/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export function getEditor3Field()
: ICustomFieldType<IEditor3ValueOperational, IEditor3ValueStorage, IEditor3Config, IUserPreferences> {
const field: ICustomFieldType<IEditor3ValueOperational, IEditor3ValueStorage, IEditor3Config, IUserPreferences> = {
id: EDITOR_3_FIELD_TYPE,
generic: true,
label: gettext('Editor3 (authoring-react)'),
editorComponent: Editor,
previewComponent: Preview,
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/authoring-react/fields/embed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function getEmbedField()
: ICustomFieldType<IEmbedValueOperational, IEmbedValueStorage, IEmbedConfig, IEmbedUserPreferences> {
const field: ReturnType<typeof getEmbedField> = {
id: 'embed',
generic: true,
label: gettext('Embed (authoring-react)'),
editorComponent: Editor,
previewComponent: Preview,
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/authoring-react/fields/linked-items/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const LINKED_ITEMS_FIELD_TYPE = 'linked-items';
export function getLinkedItemsField(): ILinkedItemsField {
const field: ILinkedItemsField = {
id: LINKED_ITEMS_FIELD_TYPE,
generic: true,
label: gettext('Linked items (authoring-react)'),
editorComponent: Editor,
previewComponent: Preview,
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/authoring-react/fields/media/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function getMediaField()
: ICustomFieldType<IMediaValueOperational, IMediaValueStorage, IMediaConfig, IMediaUserPreferences> {
const field: ReturnType<typeof getMediaField> = {
id: MEDIA_FIELD_ID,
generic: true,
label: gettext('Media (authoring-react)'),
editorComponent: Editor,
previewComponent: Preview,
Expand Down
11 changes: 11 additions & 0 deletions scripts/apps/authoring-react/fields/package-items/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ export const PACKAGE_ITEMS_FIELD_ID = 'package_items';
export function getArticlesInPackageField(): IPackageItemsField {
const field: IPackageItemsField = {
id: PACKAGE_ITEMS_FIELD_ID,

/**
* 'linked_items' is a very similar field, but generic.
* It appears this field type was implemented to save time in comparison to
* creating configuration options for linked_items.
*
* It looks though there would only be 1 config needed,
* so I think we should do the config and drop this one in the future.
*/
generic: false,

label: gettext('Package items (authoring-react)'),

editorComponent: Editor,
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/authoring-react/fields/tag-input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type TagInputFieldType = ICustomFieldType<
export function getTagInputField(): TagInputFieldType {
const field: TagInputFieldType = {
id: TAG_INPUT_FIELD_ID,
generic: true,
label: gettext('Tag-input (authoring-react)'),
editorComponent: Editor,
previewComponent: Preview,
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/authoring-react/fields/time/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function getTimeField()
: ICustomFieldType<ITimeValueOperational, ITimeValueStorage, ITimeFieldConfig, ITimeUserPreferences> {
const field: ICustomFieldType<ITimeValueOperational, ITimeValueStorage, ITimeFieldConfig, ITimeUserPreferences> = {
id: TIME_FIELD_ID,
generic: true,
label: gettext('Time (authoring-react)'),
editorComponent: Editor,
previewComponent: Preview,
Expand Down
1 change: 1 addition & 0 deletions scripts/apps/authoring-react/fields/urls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function getUrlsField()
: ICustomFieldType<IUrlsFieldValueOperational, IUrlsFieldValueStorage, IUrlsFieldConfig, IUrlsFieldUserPreferences> {
const field: ReturnType<typeof getUrlsField> = {
id: URL_FIELD_ID,
generic: true,
label: gettext('Urls (authoring-react)'),
editorComponent: Editor,
previewComponent: Preview,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class TestEditorComponent extends React.PureComponent<IEditorComponentProps<stri

const customField: ICustomFieldType<string, string, string, never> = {
id: 'test-custom-authoring-field',
generic: true,
label: 'Test Field',
editorComponent: TestEditorComponent,
previewComponent: () => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export function VocabularyEditController(

const fields = getFields();

$scope.customFieldTypes = Object.keys(fields).filter((id) => fields[id].private !== true).map((id) => ({
$scope.customFieldTypes = Object.keys(fields).filter((id) => fields[id].generic === true).map((id) => ({
id: id,
label: fields[id].label,
}));
Expand Down
7 changes: 5 additions & 2 deletions scripts/core/superdesk-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3663,9 +3663,12 @@ declare module 'superdesk-api' {
previewComponent: React.ComponentType<IPreviewComponentProps<IValueOperational, IConfig>>;

/**
* Allows for the field to be hidden from custom field type config
* Field types should be made generic when possible.
* Making field types generic means multiple fields of the same type can be enabled in the same editing view.
* Generic fields will be available for adding to content profile via user interface (settings).
*/
private?: boolean;
generic: boolean;

/**
* Must return `true` if not empty.
*/
Expand Down
Loading