mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Set special flags when configuring db-only fields (#15640)
Co-authored-by: ian <licitdev@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { HelperFunctions, State, StateUpdates } from '../types';
|
||||
import { getInterface } from '@/interfaces';
|
||||
import { set } from 'lodash';
|
||||
import { getSpecialForType } from '@/utils/get-special-for-type';
|
||||
|
||||
export function applyChanges(updates: StateUpdates, _state: State, helperFn: HelperFunctions) {
|
||||
const { hasChanged } = helperFn;
|
||||
@@ -13,22 +14,9 @@ export function applyChanges(updates: StateUpdates, _state: State, helperFn: Hel
|
||||
|
||||
function setSpecialForType(updates: StateUpdates) {
|
||||
const type = updates.field?.type;
|
||||
switch (type) {
|
||||
case 'json':
|
||||
case 'csv':
|
||||
case 'boolean':
|
||||
set(updates, 'field.meta.special', ['cast-' + type]);
|
||||
break;
|
||||
case 'uuid':
|
||||
case 'hash':
|
||||
case 'geometry':
|
||||
set(updates, 'field.meta.special', [type]);
|
||||
break;
|
||||
case undefined:
|
||||
break;
|
||||
default:
|
||||
set(updates, 'field.meta.special', null);
|
||||
}
|
||||
if (type === undefined) return;
|
||||
const special = getSpecialForType(type);
|
||||
set(updates, 'field.meta.special', special);
|
||||
}
|
||||
|
||||
function updateInterface(updates: StateUpdates, fn: HelperFunctions) {
|
||||
|
||||
@@ -152,6 +152,7 @@ import { getInterface } from '@/interfaces';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { getLocalTypeForField } from '@/utils/get-local-type';
|
||||
import { getSpecialForType } from '@/utils/get-special-for-type';
|
||||
import { notify } from '@/utils/notify';
|
||||
import { unexpectedError } from '@/utils/unexpected-error';
|
||||
import { Field } from '@directus/shared/types';
|
||||
@@ -309,7 +310,8 @@ export default defineComponent({
|
||||
|
||||
async function openFieldDetail() {
|
||||
if (!props.field.meta) {
|
||||
await fieldsStore.updateField(props.field.collection, props.field.field, { meta: {} });
|
||||
const special = getSpecialForType(props.field.type);
|
||||
await fieldsStore.updateField(props.field.collection, props.field.field, { meta: { special } });
|
||||
}
|
||||
|
||||
router.push(`/settings/data-model/${props.field.collection}/${props.field.field}`);
|
||||
|
||||
Reference in New Issue
Block a user