mirror of
https://github.com/directus/directus.git
synced 2026-02-17 11:31:23 -05:00
Finalize interface names (#5521)
* Rename button-links->presentation-links * Rename checkboxes->select-multiple-checkbox * Rename code->input-code * Rename checkboxes files * Rename color->select-color * Rename divider->presentation-divider * Rename dropdown-multiselect->select-multiple-dropdown * Rename hash->input-hash * Rename icon->select-icon * Rename image->file-image * Rename m2a-builder->list-m2a * Rename many-to-many->list-m2m * Rename many-to-one->select-dropdown-m2o * Rename markdown->input-rich-text-md * Rename notice->presentation-notice * Rename one-to-many->list-o2m * Rename radio-buttons->select-radio * Rename repeater->list * Rename text-input->input * Rename textarea->input-multiline * Rename toggle->boolean * Rename tree-view->list-o2m-tree-view * Rename wysiwyg->input-rich-text-html * Use correct interfaces in system defaults * Rename collection->system-collection * Rename collections->system-collections * Rename display-template->system-display-template * Rename field->system-field * Rename interface->system-interface * Rename interface-options->system-interface-options * Rename scope->interface-scope * Rename tfa-setup->system-mfa-setup * Fix oversights * Remove old todo * Some more tweaks * Add migration, fix dropdown name in system use * Merge numeric + input * Replace dropdown->select-dropdown in app use * Merge slug->input, user->select-dropdown-m2o * Fix type issue * Fix seeder field name
This commit is contained in:
76
app/src/interfaces/input-code/index.ts
Normal file
76
app/src/interfaces/input-code/index.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { defineInterface } from '@/interfaces/define';
|
||||
import CodeMirror from 'codemirror';
|
||||
import 'codemirror/mode/meta';
|
||||
import InterfaceCode from './input-code.vue';
|
||||
|
||||
const choicesMap = CodeMirror.modeInfo.reduce((acc: Record<string, string>, choice) => {
|
||||
if (['JSON', 'JSON-LD'].includes(choice.name)) {
|
||||
acc['JSON'] = 'JSON';
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (choice.mode == null || choice.mode == 'null') {
|
||||
choice.mode = 'plaintext';
|
||||
}
|
||||
|
||||
if (choice.mode in acc) {
|
||||
acc[choice.mode] += ' / ' + choice.name;
|
||||
} else {
|
||||
acc[choice.mode] = choice.name;
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const choices = Object.entries(choicesMap).map(([key, value]) => ({
|
||||
text: value,
|
||||
value: key,
|
||||
}));
|
||||
|
||||
export default defineInterface({
|
||||
id: 'input-code',
|
||||
name: '$t:interfaces.input-code.code',
|
||||
description: '$t:interfaces.input-code.description',
|
||||
icon: 'code',
|
||||
component: InterfaceCode,
|
||||
types: ['string', 'json', 'text'],
|
||||
options: [
|
||||
{
|
||||
field: 'language',
|
||||
name: '$t:language',
|
||||
type: 'string',
|
||||
meta: {
|
||||
width: 'half',
|
||||
interface: 'select-dropdown',
|
||||
options: { choices },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'lineNumber',
|
||||
name: '$t:interfaces.input-code.line_number',
|
||||
type: 'boolean',
|
||||
meta: {
|
||||
width: 'half',
|
||||
interface: 'boolean',
|
||||
},
|
||||
schema: {
|
||||
default_value: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'template',
|
||||
name: '$t:template',
|
||||
type: 'text',
|
||||
meta: {
|
||||
width: 'full',
|
||||
interface: 'input-code',
|
||||
options: {
|
||||
placeholder: '$t:interfaces.input-code.placeholder',
|
||||
},
|
||||
},
|
||||
schema: {
|
||||
default_value: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user