Adds permanently delete button to items and collection list
This commit is contained in:
parent
925d27efd5
commit
edcc40d159
|
@ -169,7 +169,7 @@
|
||||||
@click.prevent.stop="deleteOneCollection(collection.id)">
|
@click.prevent.stop="deleteOneCollection(collection.id)">
|
||||||
<b-icon
|
<b-icon
|
||||||
type="is-secondary"
|
type="is-secondary"
|
||||||
icon="delete"/>
|
:icon="!isOnTrash ? 'delete' : 'delete-forever'"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -197,7 +197,8 @@ export default {
|
||||||
totalCollections: 0,
|
totalCollections: 0,
|
||||||
page: 1,
|
page: 1,
|
||||||
collectionsPerPage: 12,
|
collectionsPerPage: 12,
|
||||||
collections: Array
|
collections: Array,
|
||||||
|
isOnTrash: false
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
collections() {
|
collections() {
|
||||||
|
@ -229,9 +230,9 @@ export default {
|
||||||
},
|
},
|
||||||
deleteOneCollection(collectionId) {
|
deleteOneCollection(collectionId) {
|
||||||
this.$dialog.confirm({
|
this.$dialog.confirm({
|
||||||
message: this.$i18n.get('info_warning_collection_delete'),
|
message: this.isOnTrash ? this.$i18n.get('info_warning_collection_delete') : this.$i18n.get('info_warning_collection_trash'),
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
this.deleteCollection(collectionId)
|
this.deleteCollection({ collectionId: collectionId, isPermanently: this.isOnTrash })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// this.$toast.open({
|
// this.$toast.open({
|
||||||
// duration: 3000,
|
// duration: 3000,
|
||||||
|
@ -241,7 +242,7 @@ export default {
|
||||||
// queue: true
|
// queue: true
|
||||||
// });
|
// });
|
||||||
for (let i = 0; i < this.selectedCollections.length; i++) {
|
for (let i = 0; i < this.selectedCollections.length; i++) {
|
||||||
if (this.selectedCollections[i].id == this.collectionId)
|
if (this.selectedCollections[i].id == collectionId)
|
||||||
this.selectedCollections.splice(i, 1);
|
this.selectedCollections.splice(i, 1);
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
@ -258,12 +259,12 @@ export default {
|
||||||
},
|
},
|
||||||
deleteSelectedCollections() {
|
deleteSelectedCollections() {
|
||||||
this.$dialog.confirm({
|
this.$dialog.confirm({
|
||||||
message: this.$i18n.get('info_warning_selected_collections_delete'),
|
message: this.isOnTrash ? this.$i18n.get('info_warning_selected_collections_delete') : this.$i18n.get('info_warning_selected_collections_trash'),
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
|
|
||||||
for (let i = 0; i < this.collections.length; i++) {
|
for (let i = 0; i < this.collections.length; i++) {
|
||||||
if (this.selectedCollections[i]) {
|
if (this.selectedCollections[i]) {
|
||||||
this.deleteCollection(this.collections[i].id)
|
this.deleteCollection({ collectionId: this.collections[i].id, isPermanently: this.isOnTrash })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// this.loadCollections();
|
// this.loadCollections();
|
||||||
// this.$toast.open({
|
// this.$toast.open({
|
||||||
|
|
|
@ -161,7 +161,7 @@
|
||||||
@click.prevent.stop="deleteOneItem(item.id)">
|
@click.prevent.stop="deleteOneItem(item.id)">
|
||||||
<b-icon
|
<b-icon
|
||||||
type="is-secondary"
|
type="is-secondary"
|
||||||
icon="delete"/>
|
:icon="!isOnTrash ? 'delete' : 'delete-forever'"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -189,7 +189,8 @@ export default {
|
||||||
tableFields: Array,
|
tableFields: Array,
|
||||||
items: Array,
|
items: Array,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isOnTheme: false
|
isOnTheme: false,
|
||||||
|
isOnTrash: false
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.selectedItems = [];
|
this.selectedItems = [];
|
||||||
|
@ -221,9 +222,9 @@ export default {
|
||||||
},
|
},
|
||||||
deleteOneItem(itemId) {
|
deleteOneItem(itemId) {
|
||||||
this.$dialog.confirm({
|
this.$dialog.confirm({
|
||||||
message: this.$i18n.get('info_warning_item_delete'),
|
message: this.isOnTrash ? this.$i18n.get('info_warning_item_delete') : this.$i18n.get('info_warning_item_trash'),
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
this.deleteItem(itemId)
|
this.deleteItem({ itemId: itemId, isPermanently: this.isOnTrash })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// this.$toast.open({
|
// this.$toast.open({
|
||||||
// duration: 3000,
|
// duration: 3000,
|
||||||
|
@ -233,7 +234,7 @@ export default {
|
||||||
// queue: true
|
// queue: true
|
||||||
// });
|
// });
|
||||||
for (let i = 0; i < this.selectedItems.length; i++) {
|
for (let i = 0; i < this.selectedItems.length; i++) {
|
||||||
if (this.selectedItems[i].id == this.itemId)
|
if (this.selectedItems[i].id == itemId)
|
||||||
this.selectedItems.splice(i, 1);
|
this.selectedItems.splice(i, 1);
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
@ -251,12 +252,12 @@ export default {
|
||||||
},
|
},
|
||||||
deleteSelectedItems() {
|
deleteSelectedItems() {
|
||||||
this.$dialog.confirm({
|
this.$dialog.confirm({
|
||||||
message: this.$i18n.get('info_warning_selected_items_delete'),
|
message: this.isOnTrash ? this.$i18n.get('info_warning_selected_items_delete') : this.$i18n.get('info_warning_selected_items_trash'),
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
|
|
||||||
for (let i = 0; i < this.selectedItems.length; i++) {
|
for (let i = 0; i < this.selectedItems.length; i++) {
|
||||||
if (this.selectedItems[i]) {
|
if (this.selectedItems[i]) {
|
||||||
this.deleteItem(this.items[i].id)
|
this.deleteItem({ itemId: this.items[i].id, isPermanently: this.isOnTrash })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// this.$toast.open({
|
// this.$toast.open({
|
||||||
// duration: 3000,
|
// duration: 3000,
|
||||||
|
|
|
@ -50,7 +50,8 @@
|
||||||
:total-collections="totalCollections"
|
:total-collections="totalCollections"
|
||||||
:page="page"
|
:page="page"
|
||||||
:collections-per-page="collectionsPerPage"
|
:collections-per-page="collectionsPerPage"
|
||||||
:collections="collections"/>
|
:collections="collections"
|
||||||
|
:is-on-trash="status == 'trash'"/>
|
||||||
|
|
||||||
<!-- Empty state image -->
|
<!-- Empty state image -->
|
||||||
<div v-if="totalCollections <= 0 && !isLoading">
|
<div v-if="totalCollections <= 0 && !isLoading">
|
||||||
|
|
|
@ -117,7 +117,8 @@
|
||||||
:table-fields="tableFields"
|
:table-fields="tableFields"
|
||||||
:items="items"
|
:items="items"
|
||||||
:is-loading="isLoading"
|
:is-loading="isLoading"
|
||||||
:is-on-theme="isOnTheme"/>
|
:is-on-theme="isOnTheme"
|
||||||
|
:is-on-trash="status == 'trash'"/>
|
||||||
|
|
||||||
<tainacan-cards-list
|
<tainacan-cards-list
|
||||||
v-if="viewMode == 'cards' && !isLoadingItems && items.length > 0"
|
v-if="viewMode == 'cards' && !isLoadingItems && items.length > 0"
|
||||||
|
|
|
@ -237,11 +237,15 @@ return [
|
||||||
'info_collection_deleted' => __( 'Collection deleted.', 'tainacan' ),
|
'info_collection_deleted' => __( 'Collection deleted.', 'tainacan' ),
|
||||||
'info_item_deleted' => __( 'Item deleted.', 'tainacan' ),
|
'info_item_deleted' => __( 'Item deleted.', 'tainacan' ),
|
||||||
'info_category_deleted' => __( 'Taxonomy deleted', 'tainacan' ),
|
'info_category_deleted' => __( 'Taxonomy deleted', 'tainacan' ),
|
||||||
'info_warning_collection_delete' => __( 'Do you really want to delete this collection?', 'tainacan' ),
|
'info_warning_collection_delete' => __( 'Do you really want to permanently delete this collection?', 'tainacan' ),
|
||||||
'info_warning_item_delete' => __( 'Do you really want to delete this item?', 'tainacan' ),
|
'info_warning_collection_trash' => __( 'Do you really want to trash this collection?', 'tainacan' ),
|
||||||
|
'info_warning_item_delete' => __( 'Do you really want to permanently delete this item?', 'tainacan' ),
|
||||||
|
'info_warning_item_trash' => __( 'Do you really want to trash this item?', 'tainacan' ),
|
||||||
'info_warning_category_delete' => __( 'Do you really want to delete this taxonomy?', 'tainacan' ),
|
'info_warning_category_delete' => __( 'Do you really want to delete this taxonomy?', 'tainacan' ),
|
||||||
'info_warning_selected_collections_delete' => __( 'Do you really want to delete the selected collections?', 'tainacan' ),
|
'info_warning_selected_collections_delete' => __( 'Do you really want to permanently delete the selected collections?', 'tainacan' ),
|
||||||
'info_warning_selected_items_delete' => __( 'Do you really want to delete the selected items?', 'tainacan' ),
|
'info_warning_selected_collections_trash' => __( 'Do you really want to trash the selected collections?', 'tainacan' ),
|
||||||
|
'info_warning_selected_items_delete' => __( 'Do you really want to permanently delete the selected items?', 'tainacan' ),
|
||||||
|
'info_warning_selected_items_trash' => __( 'Do you really want to trash the selected items?', 'tainacan' ),
|
||||||
'info_warning_selected_categories_delete' => __( 'Do you really want to delete the selected categories?', 'tainacan' ),
|
'info_warning_selected_categories_delete' => __( 'Do you really want to delete the selected categories?', 'tainacan' ),
|
||||||
'info_warning_collection_related' => __( 'The metadata Collection related is required', 'tainacan' ),
|
'info_warning_collection_related' => __( 'The metadata Collection related is required', 'tainacan' ),
|
||||||
'info_warning_no_fields_found' => __( 'No metadata found in this collection', 'tainacan' ),
|
'info_warning_no_fields_found' => __( 'No metadata found in this collection', 'tainacan' ),
|
||||||
|
|
|
@ -35,11 +35,15 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deleteItem = ({ commit }, item_id ) => {
|
export const deleteItem = ({ commit }, { itemId, isPermanently }) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.tainacan.delete('/items/' + item_id)
|
let endpoint = '/items/' + itemId;
|
||||||
|
if (isPermanently)
|
||||||
|
endpoint = endpoint + '?permanently=1'
|
||||||
|
|
||||||
|
axios.tainacan.delete(endpoint)
|
||||||
.then( res => {
|
.then( res => {
|
||||||
commit('deleteItem', { id: item_id });
|
commit('deleteItem', { id: itemId });
|
||||||
resolve( res );
|
resolve( res );
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
reject( error );
|
reject( error );
|
||||||
|
@ -99,9 +103,13 @@ export const fetchCollectionName = ({ commit }, id) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deleteCollection = ({ commit }, id) => {
|
export const deleteCollection = ({ commit }, { collectionId, isPermanently }) => {
|
||||||
return new Promise((resolve, reject) =>{
|
return new Promise((resolve, reject) => {
|
||||||
axios.tainacan.delete('/collections/' + id)
|
let endpoint = '/collections/' + collectionId;
|
||||||
|
if (isPermanently)
|
||||||
|
endpoint = endpoint + '?permanently=true'
|
||||||
|
|
||||||
|
axios.tainacan.delete(endpoint)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let collection = res.data;
|
let collection = res.data;
|
||||||
commit('deleteCollection', collection);
|
commit('deleteCollection', collection);
|
||||||
|
|
Loading…
Reference in New Issue