Fix type errors

This commit is contained in:
rijkvanzanten
2020-07-31 16:47:04 -04:00
parent 72a9e7bef8
commit 3b2d7d71f4
9 changed files with 21 additions and 28 deletions

View File

@@ -17,7 +17,7 @@ export function useItem(collection: Ref<string>, primaryKey: Ref<string | number
const edits = ref({});
const isNew = computed(() => primaryKey.value === '+');
const isBatch = computed(() => typeof primaryKey.value === 'string' && primaryKey.value.includes(','));
const isSingle = computed(() => !!collectionInfo.value?.single);
const isSingle = computed(() => !!collectionInfo.value?.system?.single);
const endpoint = computed(() => {
return collection.value.startsWith('directus_')

View File

@@ -336,12 +336,10 @@ export default defineComponent({
});
const relatedCollection = computed(() => {
if (!relation.value) return null;
return collectionsStore.getCollection(relation.value.one_collection);
return collectionsStore.getCollection(relation.value.one_collection)!
});
const { collection } = toRefs(relatedCollection.value);
const { primaryKeyField: relatedPrimaryKeyField } = useCollection(collection as Ref<string>);
const { primaryKeyField: relatedPrimaryKeyField } = useCollection(relatedCollection.value.collection);
return { relation, relatedCollection, relatedPrimaryKeyField };
}
@@ -363,7 +361,7 @@ export default defineComponent({
function usePreview() {
const displayTemplate = computed(() => {
if (props.template !== null) return props.template;
return collectionInfo.value?.display_template;
return collectionInfo.value?.system?.display_template;
});
const requiredFields = computed(() => {

View File

@@ -138,8 +138,7 @@ export default defineComponent({
});
const relatedCollection = computed(() => {
if (!relation.value) return null;
return collectionsStore.getCollection(relation.value.many_collection);
return collectionsStore.getCollection(relation.value.many_collection)!;
});
const { primaryKeyField: relatedPrimaryKeyField } = useCollection(relatedCollection.value.collection);

View File

@@ -110,13 +110,10 @@ export default defineComponent({
});
const relatedCollection = computed(() => {
if (!relation.value) return null;
return collectionsStore.getCollection(relation.value.many_collection);
return collectionsStore.getCollection(relation.value.many_collection)!;
});
const { collection } = toRefs(relatedCollection.value);
const { primaryKeyField: relatedPrimaryKeyField } = useCollection(collection as Ref<string>);
const { primaryKeyField: relatedPrimaryKeyField } = useCollection(relatedCollection.value.collection);
return { relation, relatedCollection, relatedPrimaryKeyField };
}

View File

@@ -38,7 +38,7 @@ export default function useNavigation() {
const navItem: NavItem = {
collection: collection,
name: collectionInfo.name,
icon: collectionInfo.icon,
icon: collectionInfo.system?.icon || 'box',
to: `/collections/${collection}`,
};
@@ -57,7 +57,7 @@ export default function useNavigation() {
const navItem: NavItem = {
collection: collection.collection,
name: collection.name,
icon: collection.icon,
icon: collection.system?.icon || 'box',
to: `/collections/${collection.collection}`,
};

View File

@@ -26,7 +26,7 @@ export default defineComponent({
const isSingle = computed(() => {
const collectionInfo = collectionsStore.getCollection(props.collection);
return !!collectionInfo?.single === true;
return !!collectionInfo?.system?.single === true;
});
return { component, isSingle };

View File

@@ -178,8 +178,7 @@ export default defineComponent({
return sortBy(
collectionsStore.state.collections
.filter((collection) => collection.collection.startsWith('directus_') === false)
.filter((collection) => collection.system === null)
.map((collection) => ({ ...collection, system: { icon: 'block' }})),
.filter((collection) => collection.system === null),
'collection'
);
});

View File

@@ -1,6 +1,6 @@
<template>
<v-button
v-if="collection.managed === false && collection.collection.startsWith('directus_') === false"
v-if="collection.system === null && collection.collection.startsWith('directus_') === false"
x-small
outlined
class="manage"
@@ -95,15 +95,15 @@ export default defineComponent({
return { savingManaged, toggleManaged };
async function toggleManaged(on: boolean) {
savingManaged.value = true;
// savingManaged.value = true;
try {
await collectionsStore.updateCollection(props.collection.collection, {
managed: on,
});
} finally {
savingManaged.value = false;
}
// try {
// await collectionsStore.updateCollection(props.collection.collection, {
// managed: on,
// });
// } finally {
// savingManaged.value = false;
// }
}
}
},

View File

@@ -91,7 +91,7 @@ export const useCollectionsStore = createStore({
throw error;
}
},
getCollection(collectionKey: string) {
getCollection(collectionKey: string): Collection | null {
return this.state.collections.find((collection) => collection.collection === collectionKey) || null;
},
},