fix export sidebar's collection not updating (#12274)

This commit is contained in:
Azri Kahar
2022-03-21 21:14:40 +08:00
committed by GitHub
parent 93122a0131
commit 6b0c38ab77

View File

@@ -215,7 +215,7 @@ import { getRootPath } from '@/utils/get-root-path';
import { notify } from '@/utils/notify';
import readableMimeType from '@/utils/readable-mime-type';
import { Filter } from '@directus/shared/types';
import { computed, reactive, ref, watch } from 'vue';
import { computed, reactive, ref, toRefs, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useCollection } from '@directus/shared/composables';
import FolderPicker from '@/views/private/components/folder-picker/folder-picker.vue';
@@ -246,6 +246,8 @@ const emit = defineEmits(['refresh']);
const { t, n } = useI18n();
const { collection } = toRefs(props);
const fileInput = ref<HTMLInputElement | null>(null);
const file = ref<File | null>(null);
@@ -258,7 +260,7 @@ const fileExtension = computed(() => {
return readableMimeType(file.value.type, true);
});
const { primaryKeyField, fields, info: collectionInfo } = useCollection(props.collection);
const { primaryKeyField, fields, info: collectionInfo } = useCollection(collection);
const exportSettings = reactive({
limit: props.layoutQuery?.limit ?? 25,
@@ -294,7 +296,7 @@ const getItemCount = debounce(async () => {
try {
const count = await api
.get(getEndpoint(props.collection), {
.get(getEndpoint(collection.value), {
params: {
...exportSettings,
aggregate: {
@@ -382,7 +384,7 @@ function useUpload() {
formData.append('file', file);
try {
await api.post(`/utils/import/${props.collection}`, formData, {
await api.post(`/utils/import/${collection.value}`, formData, {
onUploadProgress: (progressEvent: ProgressEvent) => {
const percentCompleted = Math.floor((progressEvent.loaded * 100) / progressEvent.total);
progress.value = percentCompleted;
@@ -419,9 +421,9 @@ function startExport() {
}
function exportDataLocal() {
const endpoint = props.collection.startsWith('directus_')
? `${props.collection.substring(9)}`
: `items/${props.collection}`;
const endpoint = collection.value.startsWith('directus_')
? `${collection.value.substring(9)}`
: `items/${collection.value}`;
const url = getRootPath() + endpoint;
@@ -449,7 +451,7 @@ async function exportDataFiles() {
exporting.value = true;
try {
await api.post(`/utils/export/${props.collection}`, {
await api.post(`/utils/export/${collection.value}`, {
query: {
...exportSettings,
sort: [exportSettings.sort],