Add types to interfaces & displays (#716)

* Add types to interfaces

* Update display types to match interfaces

* Update i/d to use strings
This commit is contained in:
Rijk van Zanten
2020-06-12 14:20:08 -04:00
committed by GitHub
parent ca49e3fd7a
commit 4e8a7de004
36 changed files with 71 additions and 8 deletions

View File

@@ -7,5 +7,5 @@ export default defineDisplay(({ i18n }) => ({
icon: 'query_builder',
handler: DisplayDateTime,
options: [],
types: ['datetime', 'date', 'time'],
types: ['datetime', 'datetime_created', 'datetime_updated', 'date', 'time'],
}));

View File

@@ -4,9 +4,9 @@ import DisplayFile from './file.vue';
export default defineDisplay(({ i18n }) => ({
id: 'file',
name: i18n.t('file'),
types: ['file'],
icon: 'insert_photo',
handler: DisplayFile,
types: ['file'],
options: [],
fields: ['data', 'type', 'title'],
}));

View File

@@ -7,5 +7,5 @@ export default defineDisplay(({ i18n }) => ({
icon: 'star',
handler: DisplayRating,
options: null,
types: ['integer'],
types: ['integer', 'decimal'],
}));

View File

@@ -1,6 +1,7 @@
import VueI18n from 'vue-i18n';
import { Component } from 'vue';
import { Field } from '@/stores/fields/types';
import { Type } from '@/interfaces/types';
export type DisplayHandlerFunctionContext = {
type: string;
@@ -28,7 +29,7 @@ export type DisplayConfig = {
handler: DisplayHandlerFunction | Component;
options: null | Partial<Field>[] | Component;
types: string[];
types: Type[];
fields?: string[] | DisplayFieldsFunction;
};

View File

@@ -4,7 +4,7 @@ import DisplayUser from './user.vue';
export default defineDisplay(({ i18n }) => ({
id: 'user',
name: i18n.t('user'),
types: ['user', 'owner', 'user_modified'],
types: ['user', 'user_created', 'user_updated'],
icon: 'person',
handler: DisplayUser,
options: [

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('checkboxes'),
icon: 'radio_button_checked',
component: InterfaceCheckboxes,
types: ['array'],
options: [
{
field: 'choices',

View File

@@ -15,6 +15,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('code'),
icon: 'code',
component: InterfaceCode,
types: ['string', 'json', 'array'],
options: [
{
field: 'template',

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('collections'),
icon: 'featured_play_list',
component: InterfaceCollections,
types: ['string'],
options: [
{
field: 'includeSystem',

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('color'),
icon: 'palette',
component: InterfaceColor,
types: ['string'],
options: [
{
field: 'presets',

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('datetime'),
icon: 'today',
component: InterfaceDateTime,
types: ['datetime', 'datetime_created', 'datetime_updated', 'date', 'time'],
options: [
{
field: 'includeSeconds',

View File

@@ -8,6 +8,7 @@ export default defineInterface(({ i18n }) => ({
component: InterfaceDivider,
hideLabel: true,
hideLoader: true,
types: ['alias'],
options: [
{
field: 'color',

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('dropdown_multiple'),
icon: 'arrow_drop_down_circle',
component: InterfaceDropdownMultiselect,
types: ['array'],
options: [
{
field: 'choices',

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('dropdown'),
icon: 'arrow_drop_down_circle',
component: InterfaceDropdown,
types: ['string'],
options: [
{
field: 'choices',

View File

@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('file'),
icon: 'note_add',
component: InterfaceFile,
types: ['file'],
options: [],
}));

View File

@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('files'),
icon: 'note_add',
component: InterfaceFiles,
types: ['files'],
options: [],
}));

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('hash'),
icon: 'text_fields',
component: InterfaceHash,
types: ['string'],
options: [
{
field: 'placeholder',

View File

@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('icon'),
icon: 'insert_emoticon',
component: InterfaceIcon,
types: ['string'],
options: [],
}));

View File

@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('image'),
icon: 'insert_photo',
component: InterfaceImage,
types: ['file'],
options: [],
}));

View File

@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('many_to_many'),
icon: 'note_add',
component: InterfaceManyToMany,
types: ['m2m'],
options: [],
}));

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('many_to_one'),
icon: 'arrow_right_alt',
component: InterfaceManyToOne,
types: ['m2o'],
options: [
{
field: 'template',

View File

@@ -8,6 +8,7 @@ export default defineInterface(({ i18n }) => ({
component: InterfaceNotice,
hideLabel: true,
hideLoader: true,
types: ['alias'],
options: [
{
field: 'color',

View File

@@ -1,5 +1,4 @@
import InterfaceNumeric from './numeric.vue';
import { defineInterface } from '@/interfaces/define';
export default defineInterface(({ i18n }) => ({
@@ -7,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('numeric'),
icon: 'dialpad',
component: InterfaceNumeric,
types: ['integer', 'decimal'],
options: [
{
field: 'placeholder',

View File

@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('one_to_many'),
icon: 'arrow_right_alt',
component: InterfaceOneToMany,
types: ['o2m'],
options: [],
}));

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('radio_buttons'),
icon: 'radio_button_checked',
component: InterfaceRadioButtons,
types: ['string'],
options: [
{
field: 'choices',

View File

@@ -5,7 +5,7 @@ export default defineInterface(({ i18n }) => ({
id: 'repeater',
name: i18n.t('repeater'),
icon: 'replay',
types: ['json'],
component: InterfaceRepeater,
types: ['json'],
options: [],
}));

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('slider'),
icon: 'linear_scale',
component: InterfaceSlider,
types: ['integer', 'decimal'],
options: [
{
field: 'minValue',

View File

@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('slug'),
icon: 'link',
component: InterfaceSlug,
types: ['string'],
options: [],
}));

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('status'),
icon: 'bubble_chart',
component: InterfaceStatus,
types: ['status'],
options: [
{
field: 'status_mapping',

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('tags'),
icon: 'local_offer',
component: InterfaceTags,
types: ['array'],
options: [
{
field: 'placeholder',

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('text_input'),
icon: 'text_fields',
component: InterfaceTextInput,
types: ['string'],
options: [
{
field: 'placeholder',

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('textarea'),
icon: 'text_fields',
component: InterfaceTextarea,
types: ['string'],
options: [
{
field: 'placeholder',

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('toggle'),
icon: 'check_box',
component: InterfaceToggle,
types: ['boolean'],
options: [
{
field: 'iconOff',

View File

@@ -5,7 +5,7 @@ export default defineInterface(({ i18n }) => ({
id: 'translations',
name: i18n.t('translations'),
icon: 'replay',
types: ['o2m'],
types: ['translation'],
component: InterfaceTranslations,
options: [],
}));

View File

@@ -2,12 +2,47 @@ import VueI18n from 'vue-i18n';
import { Component } from 'vue';
import { Field } from '@/stores/fields/types';
const types = [
'alias',
'array',
'boolean',
'binary',
'datetime',
'date',
'time',
'file',
'files',
'hash',
'group',
'integer',
'decimal',
'json',
'lang',
'm2o',
'o2m',
'm2m',
'slug',
'sort',
'status',
'string',
'translation',
'uuid',
'datetime_created',
'datetime_updated',
'user_created',
'user_updated',
'user',
] as const;
export type Type = typeof types[number];
export type InterfaceConfig = {
id: string;
icon: string;
name: string | VueI18n.TranslateResult;
component: Component;
options: Partial<Field>[] | Component;
types: Type[];
hideLabel?: boolean;
hideLoader?: boolean;
};

View File

@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('user'),
icon: 'person',
component: InterfaceUser,
types: ['user', 'user_created', 'user_updated'],
options: [],
}));

View File

@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
name: i18n.t('wysiwyg'),
icon: 'format_quote',
component: InterfaceWYSIWYG,
types: ['string'],
options: [
{
field: 'toolbar',