mirror of
https://github.com/directus/directus.git
synced 2026-01-29 00:27:59 -05:00
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:
@@ -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'],
|
||||
}));
|
||||
|
||||
@@ -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'],
|
||||
}));
|
||||
|
||||
@@ -7,5 +7,5 @@ export default defineDisplay(({ i18n }) => ({
|
||||
icon: 'star',
|
||||
handler: DisplayRating,
|
||||
options: null,
|
||||
types: ['integer'],
|
||||
types: ['integer', 'decimal'],
|
||||
}));
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('checkboxes'),
|
||||
icon: 'radio_button_checked',
|
||||
component: InterfaceCheckboxes,
|
||||
types: ['array'],
|
||||
options: [
|
||||
{
|
||||
field: 'choices',
|
||||
|
||||
@@ -15,6 +15,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('code'),
|
||||
icon: 'code',
|
||||
component: InterfaceCode,
|
||||
types: ['string', 'json', 'array'],
|
||||
options: [
|
||||
{
|
||||
field: 'template',
|
||||
|
||||
@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('collections'),
|
||||
icon: 'featured_play_list',
|
||||
component: InterfaceCollections,
|
||||
types: ['string'],
|
||||
options: [
|
||||
{
|
||||
field: 'includeSystem',
|
||||
|
||||
@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('color'),
|
||||
icon: 'palette',
|
||||
component: InterfaceColor,
|
||||
types: ['string'],
|
||||
options: [
|
||||
{
|
||||
field: 'presets',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -8,6 +8,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
component: InterfaceDivider,
|
||||
hideLabel: true,
|
||||
hideLoader: true,
|
||||
types: ['alias'],
|
||||
options: [
|
||||
{
|
||||
field: 'color',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('dropdown'),
|
||||
icon: 'arrow_drop_down_circle',
|
||||
component: InterfaceDropdown,
|
||||
types: ['string'],
|
||||
options: [
|
||||
{
|
||||
field: 'choices',
|
||||
|
||||
@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('file'),
|
||||
icon: 'note_add',
|
||||
component: InterfaceFile,
|
||||
types: ['file'],
|
||||
options: [],
|
||||
}));
|
||||
|
||||
@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('files'),
|
||||
icon: 'note_add',
|
||||
component: InterfaceFiles,
|
||||
types: ['files'],
|
||||
options: [],
|
||||
}));
|
||||
|
||||
@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('hash'),
|
||||
icon: 'text_fields',
|
||||
component: InterfaceHash,
|
||||
types: ['string'],
|
||||
options: [
|
||||
{
|
||||
field: 'placeholder',
|
||||
|
||||
@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('icon'),
|
||||
icon: 'insert_emoticon',
|
||||
component: InterfaceIcon,
|
||||
types: ['string'],
|
||||
options: [],
|
||||
}));
|
||||
|
||||
@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('image'),
|
||||
icon: 'insert_photo',
|
||||
component: InterfaceImage,
|
||||
types: ['file'],
|
||||
options: [],
|
||||
}));
|
||||
|
||||
@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('many_to_many'),
|
||||
icon: 'note_add',
|
||||
component: InterfaceManyToMany,
|
||||
types: ['m2m'],
|
||||
options: [],
|
||||
}));
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -8,6 +8,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
component: InterfaceNotice,
|
||||
hideLabel: true,
|
||||
hideLoader: true,
|
||||
types: ['alias'],
|
||||
options: [
|
||||
{
|
||||
field: 'color',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('one_to_many'),
|
||||
icon: 'arrow_right_alt',
|
||||
component: InterfaceOneToMany,
|
||||
types: ['o2m'],
|
||||
options: [],
|
||||
}));
|
||||
|
||||
@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('radio_buttons'),
|
||||
icon: 'radio_button_checked',
|
||||
component: InterfaceRadioButtons,
|
||||
types: ['string'],
|
||||
options: [
|
||||
{
|
||||
field: 'choices',
|
||||
|
||||
@@ -5,7 +5,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
id: 'repeater',
|
||||
name: i18n.t('repeater'),
|
||||
icon: 'replay',
|
||||
types: ['json'],
|
||||
component: InterfaceRepeater,
|
||||
types: ['json'],
|
||||
options: [],
|
||||
}));
|
||||
|
||||
@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('slider'),
|
||||
icon: 'linear_scale',
|
||||
component: InterfaceSlider,
|
||||
types: ['integer', 'decimal'],
|
||||
options: [
|
||||
{
|
||||
field: 'minValue',
|
||||
|
||||
@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('slug'),
|
||||
icon: 'link',
|
||||
component: InterfaceSlug,
|
||||
types: ['string'],
|
||||
options: [],
|
||||
}));
|
||||
|
||||
@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('status'),
|
||||
icon: 'bubble_chart',
|
||||
component: InterfaceStatus,
|
||||
types: ['status'],
|
||||
options: [
|
||||
{
|
||||
field: 'status_mapping',
|
||||
|
||||
@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('tags'),
|
||||
icon: 'local_offer',
|
||||
component: InterfaceTags,
|
||||
types: ['array'],
|
||||
options: [
|
||||
{
|
||||
field: 'placeholder',
|
||||
|
||||
@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('text_input'),
|
||||
icon: 'text_fields',
|
||||
component: InterfaceTextInput,
|
||||
types: ['string'],
|
||||
options: [
|
||||
{
|
||||
field: 'placeholder',
|
||||
|
||||
@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('textarea'),
|
||||
icon: 'text_fields',
|
||||
component: InterfaceTextarea,
|
||||
types: ['string'],
|
||||
options: [
|
||||
{
|
||||
field: 'placeholder',
|
||||
|
||||
@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('toggle'),
|
||||
icon: 'check_box',
|
||||
component: InterfaceToggle,
|
||||
types: ['boolean'],
|
||||
options: [
|
||||
{
|
||||
field: 'iconOff',
|
||||
|
||||
@@ -5,7 +5,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
id: 'translations',
|
||||
name: i18n.t('translations'),
|
||||
icon: 'replay',
|
||||
types: ['o2m'],
|
||||
types: ['translation'],
|
||||
component: InterfaceTranslations,
|
||||
options: [],
|
||||
}));
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -6,5 +6,6 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('user'),
|
||||
icon: 'person',
|
||||
component: InterfaceUser,
|
||||
types: ['user', 'user_created', 'user_updated'],
|
||||
options: [],
|
||||
}));
|
||||
|
||||
@@ -6,6 +6,7 @@ export default defineInterface(({ i18n }) => ({
|
||||
name: i18n.t('wysiwyg'),
|
||||
icon: 'format_quote',
|
||||
component: InterfaceWYSIWYG,
|
||||
types: ['string'],
|
||||
options: [
|
||||
{
|
||||
field: 'toolbar',
|
||||
|
||||
Reference in New Issue
Block a user