mirror of
https://github.com/directus/directus.git
synced 2026-02-11 01:55:13 -05:00
Allow configuring presentation type fields
This commit is contained in:
@@ -40,13 +40,13 @@ export default defineComponent({
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
setup(props) {
|
||||
const availableInterfaces = computed(() =>
|
||||
interfaces.filter((inter) => {
|
||||
const matchesType = inter.types.includes(state.fieldData?.type || 'alias');
|
||||
let matchesRelation = false;
|
||||
|
||||
if (props.type === 'standard') {
|
||||
if (props.type === 'standard' || props.type === 'presentation') {
|
||||
matchesRelation = inter.relationship === null || inter.relationship === undefined;
|
||||
} else if (props.type === 'file') {
|
||||
matchesRelation = inter.relationship === 'm2o';
|
||||
|
||||
@@ -104,7 +104,7 @@ export default defineComponent({
|
||||
const localType = computed(() => {
|
||||
if (props.field === '+') return props.type;
|
||||
|
||||
let type: 'standard' | 'file' | 'files' | 'o2m' | 'm2m' | 'm2o' = 'standard';
|
||||
let type: 'standard' | 'file' | 'files' | 'o2m' | 'm2m' | 'm2o' | 'presentation' = 'standard';
|
||||
type = getLocalTypeForField(props.collection, props.field);
|
||||
|
||||
return type;
|
||||
@@ -195,6 +195,10 @@ export default defineComponent({
|
||||
);
|
||||
}
|
||||
|
||||
if (localType.value === 'presentation') {
|
||||
return isEmpty(state.fieldData.field);
|
||||
}
|
||||
|
||||
return isEmpty(state.fieldData.field) || isEmpty(state.fieldData.type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export { state, initLocalStore, clearLocalStore };
|
||||
function initLocalStore(
|
||||
collection: string,
|
||||
field: string,
|
||||
type: 'standard' | 'file' | 'files' | 'm2o' | 'o2m' | 'm2m'
|
||||
type: 'standard' | 'file' | 'files' | 'm2o' | 'o2m' | 'm2m' | 'presentation'
|
||||
) {
|
||||
state = reactive<any>({
|
||||
fieldData: {
|
||||
@@ -223,6 +223,12 @@ function initLocalStore(
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (type === 'presentation') {
|
||||
delete state.fieldData.schema;
|
||||
delete state.fieldData.type;
|
||||
state.fieldData.meta.special = 'alias';
|
||||
}
|
||||
}
|
||||
|
||||
function clearLocalStore() {
|
||||
|
||||
Reference in New Issue
Block a user