Leaves attachments list component responsible for fetching.

This commit is contained in:
mateuswetah 2022-04-13 10:21:32 -03:00
parent 650e7c3227
commit 3880668464
3 changed files with 364 additions and 1917 deletions

2258
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,8 +4,8 @@
style="position: relative;"
class="table-container">
<b-loading
is-full-page="false"
:active="isLoading" />
:is-full-page="false"
:active.sync="isLoading" />
<div
v-if="attachments.length > 0"
class="table-wrapper">
@ -107,13 +107,14 @@
},
props: {
item: Object,
isLoading: Boolean,
shouldLoadAttachments: Boolean,
isEditable: Boolean,
},
data() {
return {
attachmentsPage: 1,
attachmentsPerPage: 12
attachmentsPerPage: 12,
isLoading: false
}
},
computed: {
@ -124,6 +125,11 @@
return this.getTotalAttachments();
}
},
watch: {
shouldLoadAttachments() {
this.loadAttachments();
}
},
created() {
// Get attachments
this.loadAttachments();
@ -159,7 +165,7 @@
return last > this.totalAttachments ? this.totalAttachments : last;
},
loadAttachments() {
this.$emit('isLoadingAttachments', true);
this.isLoading = true;
this.fetchAttachments({
page: this.attachmentsPage,
@ -169,11 +175,11 @@
thumbnailId: this.item.thumbnail_id
})
.then((response) => {
this.$emit('isLoadingAttachments', false);
this.isLoading = false;
this.totalAttachments = response.total;
})
.catch((error) => {
this.$emit('isLoadingAttachments', false);
this.isLoading = false;
this.$console.error(error);
})
},

View File

@ -275,9 +275,6 @@ export const deletePermanentlyAttachment = ( { commit }, attachmentId) => {
};
export const fetchAttachments = ({ commit }, { page, attachmentsPerPage, itemId, documentId, thumbnailId }) => {
commit('cleanAttachments');
commit('setTotalAttachments', null);
let endpoint = '/items/' + itemId + '/attachments?order=ASC&orderby=menu_order&perpage=' + attachmentsPerPage + '&paged=' + page;
if (documentId && !isNaN(documentId) && thumbnailId && !isNaN(thumbnailId))