Leaves attachments list component responsible for fetching.
This commit is contained in:
parent
650e7c3227
commit
3880668464
File diff suppressed because it is too large
Load Diff
|
@ -4,8 +4,8 @@
|
||||||
style="position: relative;"
|
style="position: relative;"
|
||||||
class="table-container">
|
class="table-container">
|
||||||
<b-loading
|
<b-loading
|
||||||
is-full-page="false"
|
:is-full-page="false"
|
||||||
:active="isLoading" />
|
:active.sync="isLoading" />
|
||||||
<div
|
<div
|
||||||
v-if="attachments.length > 0"
|
v-if="attachments.length > 0"
|
||||||
class="table-wrapper">
|
class="table-wrapper">
|
||||||
|
@ -107,13 +107,14 @@
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
item: Object,
|
item: Object,
|
||||||
isLoading: Boolean,
|
shouldLoadAttachments: Boolean,
|
||||||
isEditable: Boolean,
|
isEditable: Boolean,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
attachmentsPage: 1,
|
attachmentsPage: 1,
|
||||||
attachmentsPerPage: 12
|
attachmentsPerPage: 12,
|
||||||
|
isLoading: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -124,6 +125,11 @@
|
||||||
return this.getTotalAttachments();
|
return this.getTotalAttachments();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
shouldLoadAttachments() {
|
||||||
|
this.loadAttachments();
|
||||||
|
}
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
// Get attachments
|
// Get attachments
|
||||||
this.loadAttachments();
|
this.loadAttachments();
|
||||||
|
@ -159,7 +165,7 @@
|
||||||
return last > this.totalAttachments ? this.totalAttachments : last;
|
return last > this.totalAttachments ? this.totalAttachments : last;
|
||||||
},
|
},
|
||||||
loadAttachments() {
|
loadAttachments() {
|
||||||
this.$emit('isLoadingAttachments', true);
|
this.isLoading = true;
|
||||||
|
|
||||||
this.fetchAttachments({
|
this.fetchAttachments({
|
||||||
page: this.attachmentsPage,
|
page: this.attachmentsPage,
|
||||||
|
@ -169,11 +175,11 @@
|
||||||
thumbnailId: this.item.thumbnail_id
|
thumbnailId: this.item.thumbnail_id
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.$emit('isLoadingAttachments', false);
|
this.isLoading = false;
|
||||||
this.totalAttachments = response.total;
|
this.totalAttachments = response.total;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$emit('isLoadingAttachments', false);
|
this.isLoading = false;
|
||||||
this.$console.error(error);
|
this.$console.error(error);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -275,9 +275,6 @@ export const deletePermanentlyAttachment = ( { commit }, attachmentId) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchAttachments = ({ commit }, { page, attachmentsPerPage, itemId, documentId, thumbnailId }) => {
|
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;
|
let endpoint = '/items/' + itemId + '/attachments?order=ASC&orderby=menu_order&perpage=' + attachmentsPerPage + '&paged=' + page;
|
||||||
|
|
||||||
if (documentId && !isNaN(documentId) && thumbnailId && !isNaN(thumbnailId))
|
if (documentId && !isNaN(documentId) && thumbnailId && !isNaN(thumbnailId))
|
||||||
|
|
Loading…
Reference in New Issue