superdesk/superdesk-client-core

View on GitHub
scripts/apps/authoring-react/fields/time/index.tsx

Summary

Maintainability
A
1 hr
Test Coverage
import {
    ICustomFieldType,
    ITimeValueOperational,
    ITimeValueStorage,
    ITimeFieldConfig,
    ITimeUserPreferences,
} from 'superdesk-api';
import {gettext} from 'core/utils';
import {Editor} from './editor';
import {Preview} from './preview';
import {Difference} from './difference';

export const TIME_FIELD_ID = 'time';

export function getTimeField()
: ICustomFieldType<ITimeValueOperational, ITimeValueStorage, ITimeFieldConfig, ITimeUserPreferences> {
    const field: ICustomFieldType<ITimeValueOperational, ITimeValueStorage, ITimeFieldConfig, ITimeUserPreferences> = {
        id: TIME_FIELD_ID,
        label: gettext('Time (authoring-react)'),
        editorComponent: Editor,
        previewComponent: Preview,

        hasValue: (valueOperational) => valueOperational != null,
        getEmptyValue: () => null,

        differenceComponent: Difference,
        configComponent: null,
    };

    return field;
}