Fixes taxonomy list always deleting permanently.

This commit is contained in:
Mateus Machado Luna 2018-07-10 17:02:10 -03:00
parent 48baf82ff0
commit 1f567ec1e8
3 changed files with 8 additions and 6 deletions

View File

@ -120,7 +120,7 @@
@click.prevent.stop="deleteOneTaxonomy(taxonomy.id)">
<b-icon
type="is-secondary"
icon="delete"/>
:icon="!isOnTrash ? 'delete' : 'delete-forever'"/>
</a>
</div>
</td>
@ -149,7 +149,8 @@
total: 0,
page: 1,
taxonomiesPerPage: 12,
taxonomies: Array
taxonomies: Array,
isOnTrash: false
},
watch: {
taxonomies() {
@ -188,7 +189,7 @@
title: this.$i18n.get('label_warning'),
message: this.$i18n.get('info_warning_taxonomy_delete'),
onConfirm: () => {
this.deleteTaxonomy(taxonomyId)
this.deleteTaxonomy({ taxonomyId: taxonomyId, isPermanently: this.isOnTrash })
.then(() => {
// this.$toast.open({
// duration: 3000,
@ -227,7 +228,7 @@
for (let i = 0; i < this.taxonomies.length; i++) {
if (this.selected[i]) {
this.deleteTaxonomy(this.taxonomies[i].id)
this.deleteTaxonomy({ taxonomyId: this.taxonomies[i].id, isPermanently: this.isOnTrash })
.then(() => {
// this.load();
// this.$toast.open({

View File

@ -37,6 +37,7 @@
<taxonomies-list
:is-loading="isLoading"
:total="total"
:is-on-trash="status == 'trash'"
:page="page"
:taxonomies-per-page="taxonomiesPerPage"
:taxonomies="taxonomies"/>

View File

@ -23,9 +23,9 @@ export const createTaxonomy = ({commit}, taxonomy) => {
});
};
export const deleteTaxonomy = ({ commit }, taxonomyId) => {
export const deleteTaxonomy = ({ commit }, { taxonomyId, isPermanently }) => {
return new Promise(( resolve, reject ) => {
axios.tainacan.delete(`/taxonomies/${taxonomyId}?permanently=1`)
axios.tainacan.delete(`/taxonomies/${taxonomyId}?permanently=` + (isPermanently ? '1' : '0'))
.then(res => {
commit('deleteTaxonomy', res.data);