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