Allow configuring presentation type fields

This commit is contained in:
rijkvanzanten
2020-08-19 12:34:24 -06:00
parent c32af74868
commit ef55b62503
3 changed files with 14 additions and 4 deletions

View File

@@ -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';

View File

@@ -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);
}
}

View File

@@ -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() {