Hides thumbnail from attachments list as well as document.
This commit is contained in:
parent
8d8c487f45
commit
e85d25f54b
|
@ -1296,7 +1296,13 @@ export default {
|
|||
})
|
||||
.then(() => {
|
||||
this.isLoadingAttachments = true;
|
||||
this.fetchAttachments({ page: 1, attachmentsPerPage: 24, itemId: this.itemId, documentId: this.item.document })
|
||||
this.fetchAttachments({
|
||||
page: 1,
|
||||
attachmentsPerPage: 24,
|
||||
itemId: this.itemId,
|
||||
documentId: this.item.document,
|
||||
thumbnailId: this.item.thumbnail_id
|
||||
})
|
||||
.then(() => this.isLoadingAttachments = false)
|
||||
.catch(() => this.isLoadingAttachments = false);
|
||||
})
|
||||
|
@ -1335,7 +1341,13 @@ export default {
|
|||
.then(() => {
|
||||
this.isLoadingAttachments = true;
|
||||
|
||||
this.fetchAttachments({ page: 1, attachmentsPerPage: 24, itemId: this.itemId, documentId: this.item.document })
|
||||
this.fetchAttachments({
|
||||
page: 1,
|
||||
attachmentsPerPage: 24,
|
||||
itemId: this.itemId,
|
||||
documentId: this.item.document,
|
||||
thumbnailId: this.item.thumbnail_id
|
||||
})
|
||||
.then(() => this.isLoadingAttachments = false)
|
||||
.catch(() => this.isLoadingAttachments = false);
|
||||
})
|
||||
|
@ -1361,6 +1373,7 @@ export default {
|
|||
this.isLoading = true;
|
||||
this.form.document_type = 'attachment';
|
||||
this.form.document = file.id + '';
|
||||
|
||||
this.updateItemDocument({ item_id: this.itemId, document: this.form.document, document_type: this.form.document_type })
|
||||
.then((item) => {
|
||||
this.isLoading = false;
|
||||
|
@ -1414,10 +1427,17 @@ export default {
|
|||
nonce: this.item.nonces ? this.item.nonces['update-post_' + this.item.id] : null,
|
||||
relatedPostId: this.itemId,
|
||||
document: this.item.document_type == 'attachment' ? this.item.document : null,
|
||||
thumbnailId: this.item.thumbnail_id ? this.item.thumbnail_id : null,
|
||||
onSave: () => {
|
||||
// Fetch current existing attachments
|
||||
this.isLoadingAttachments = true;
|
||||
this.fetchAttachments({ page: 1, attachmentsPerPage: 24, itemId: this.itemId, documentId: this.item.document })
|
||||
this.fetchAttachments({
|
||||
page: 1,
|
||||
attachmentsPerPage: 24,
|
||||
itemId: this.itemId,
|
||||
documentId: this.item.document,
|
||||
thumbnailId: this.item.thumbnail_id
|
||||
})
|
||||
.then(() => this.isLoadingAttachments = false)
|
||||
.catch(() => this.isLoadingAttachments = false);
|
||||
}
|
||||
|
@ -1523,7 +1543,12 @@ export default {
|
|||
this.setLastUpdated(this.item.modification_date);
|
||||
|
||||
// Fetch current existing attachments now that item.document
|
||||
this.fetchAttachments({ page: 1, attachmentsPerPage: 24, itemId: this.itemId, documentId: this.item.document });
|
||||
this.fetchAttachments({
|
||||
page: 1,
|
||||
attachmentsPerPage: 24,
|
||||
itemId: this.itemId,
|
||||
documentId: this.item.document,
|
||||
thumbnailId: this.item.thumbnail_id });
|
||||
|
||||
// Initializes Media Frames now that itemId and item.document exists
|
||||
this.initializeMediaFrames();
|
||||
|
|
|
@ -165,7 +165,8 @@
|
|||
page: this.attachmentsPage,
|
||||
attachmentsPerPage: this.attachmentsPerPage,
|
||||
itemId: this.item.id,
|
||||
documentId: this.item.document
|
||||
documentId: this.item.document,
|
||||
thumbnailId: this.item.thumbnail_id
|
||||
})
|
||||
.then((response) => {
|
||||
this.isLoading = false;
|
||||
|
|
|
@ -250,14 +250,18 @@ export const deletePermanentlyAttachment = ( { commit }, attachmentId) => {
|
|||
});
|
||||
};
|
||||
|
||||
export const fetchAttachments = ({ commit }, { page, attachmentsPerPage, itemId, documentId }) => {
|
||||
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))
|
||||
if (documentId && !isNaN(documentId) && thumbnailId && !isNaN(thumbnailId))
|
||||
endpoint += '&exclude=' + documentId + ',' + thumbnailId;
|
||||
else if (documentId && !isNaN(documentId))
|
||||
endpoint += '&exclude=' + documentId;
|
||||
else if (thumbnailId && !isNaN(thumbnailId))
|
||||
endpoint += '&exclude=' + thumbnailId;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.tainacan.get(endpoint)
|
||||
|
|
|
@ -76,10 +76,13 @@ export default {
|
|||
|
||||
this.frame.$el.addClass( 'tainacan-item-attachments-modal' );
|
||||
this.frame.$el['tainacan-document-id'] = this.params.document;
|
||||
this.frame.$el['tainacan-thumbnail-id'] = this.params.thumbnailId;
|
||||
|
||||
wp.media.view.Attachment.Library = wp.media.view.Attachment.Library.extend({
|
||||
className: function() {
|
||||
return 'attachment ' + ((this.controller.$el['tainacan-document-id'] && (this.model.get('id') == this.controller.$el['tainacan-document-id'])) ? 'tainacan-document-attachment' : '');
|
||||
return 'attachment ' +
|
||||
((this.controller.$el['tainacan-document-id'] && (this.model.get('id') == this.controller.$el['tainacan-document-id'])) ? 'tainacan-document-attachment ' : ' ') +
|
||||
((this.controller.$el['tainacan-thumbnail-id'] && (this.model.get('id') == this.controller.$el['tainacan-thumbnail-id'])) ? 'tainacan-thumbnail-attachment ' : ' ');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -202,7 +202,8 @@
|
|||
.tainacan-header-image-modal,
|
||||
.tainacan-thumbnail-modal,
|
||||
.tainacan-item-attachments-modal {
|
||||
.tainacan-document-attachment {
|
||||
.tainacan-document-attachment,
|
||||
.tainacan-thumbnail-attachment {
|
||||
display: none;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue