mirror of
https://github.com/directus/directus.git
synced 2026-02-13 10:24:54 -05:00
Fix type errors
This commit is contained in:
@@ -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_')
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
@@ -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}`,
|
||||
};
|
||||
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
// }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user