improve generic form delete
This commit is contained in:
parent
3159868ba4
commit
7ca7bd6111
@ -5,6 +5,9 @@
|
|||||||
<generic-multiselect @change="food = $event.val; refreshList()"
|
<generic-multiselect @change="food = $event.val; refreshList()"
|
||||||
:model="Models.FOOD"
|
:model="Models.FOOD"
|
||||||
:multiple="false"></generic-multiselect>
|
:multiple="false"></generic-multiselect>
|
||||||
|
<b-button @click="show_food_delete=true" :disabled="food === null"> <i class="fas fa-trash-alt"></i></b-button>
|
||||||
|
<generic-modal-form :model="Models.FOOD" :action="Actions.DELETE" :show="show_food_delete" :item1="food"
|
||||||
|
@finish-action="food = null; show_food_delete=false"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<generic-multiselect @change="unit = $event.val; refreshList()"
|
<generic-multiselect @change="unit = $event.val; refreshList()"
|
||||||
@ -16,11 +19,11 @@
|
|||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Amount</th>
|
<th>{{$t('Amount')}}</th>
|
||||||
<th>Unit</th>
|
<th>{{$t('Unit')}}</th>
|
||||||
<th>Food</th>
|
<th>{{$t('Food')}}</th>
|
||||||
<th>Note</th>
|
<th>{{$t('Note')}}</th>
|
||||||
<th>Save</th>
|
<th>{{$t('Save')}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tr v-for="i in ingredients" v-bind:key="i.id">
|
<tr v-for="i in ingredients" v-bind:key="i.id">
|
||||||
@ -68,18 +71,21 @@ import "bootstrap-vue/dist/bootstrap-vue.css"
|
|||||||
import {ApiMixin, StandardToasts} from "@/utils/utils"
|
import {ApiMixin, StandardToasts} from "@/utils/utils"
|
||||||
import {ApiApiFactory} from "@/utils/openapi/api";
|
import {ApiApiFactory} from "@/utils/openapi/api";
|
||||||
import GenericMultiselect from "@/components/GenericMultiselect";
|
import GenericMultiselect from "@/components/GenericMultiselect";
|
||||||
|
import GenericModalForm from "@/components/Modals/GenericModalForm";
|
||||||
|
|
||||||
Vue.use(BootstrapVue)
|
Vue.use(BootstrapVue)
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "IngredientEditorView",
|
name: "IngredientEditorView",
|
||||||
mixins: [ApiMixin],
|
mixins: [ApiMixin],
|
||||||
components: {GenericMultiselect},
|
components: {GenericMultiselect, GenericModalForm},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
ingredients: [],
|
ingredients: [],
|
||||||
food: null,
|
food: null,
|
||||||
unit: null,
|
unit: null,
|
||||||
|
show_food_delete: false,
|
||||||
|
show_unit_delete: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {},
|
computed: {},
|
||||||
|
@ -176,8 +176,11 @@ export default {
|
|||||||
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_DELETE)
|
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_DELETE)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err)
|
if (err.response.status === 403){
|
||||||
StandardToasts.makeStandardToast(StandardToasts.FAIL_DELETE)
|
StandardToasts.makeStandardToast(StandardToasts.FAIL_DELETE_PROTECTED)
|
||||||
|
}else {
|
||||||
|
StandardToasts.makeStandardToast(StandardToasts.FAIL_DELETE)
|
||||||
|
}
|
||||||
this.$emit("finish-action", "cancel")
|
this.$emit("finish-action", "cancel")
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"err_creating_resource": "There was an error creating a resource!",
|
"err_creating_resource": "There was an error creating a resource!",
|
||||||
"err_updating_resource": "There was an error updating a resource!",
|
"err_updating_resource": "There was an error updating a resource!",
|
||||||
"err_deleting_resource": "There was an error deleting a resource!",
|
"err_deleting_resource": "There was an error deleting a resource!",
|
||||||
|
"err_deleting_protected_resource": "The object you are trying to delete is still used and can't be deleted.",
|
||||||
"err_moving_resource": "There was an error moving a resource!",
|
"err_moving_resource": "There was an error moving a resource!",
|
||||||
"err_merging_resource": "There was an error merging a resource!",
|
"err_merging_resource": "There was an error merging a resource!",
|
||||||
"success_fetching_resource": "Successfully fetched a resource!",
|
"success_fetching_resource": "Successfully fetched a resource!",
|
||||||
@ -87,6 +88,7 @@
|
|||||||
"Note": "Note",
|
"Note": "Note",
|
||||||
"Success": "Success",
|
"Success": "Success",
|
||||||
"Failure": "Failure",
|
"Failure": "Failure",
|
||||||
|
"Protected": "Protected",
|
||||||
"Ingredients": "Ingredients",
|
"Ingredients": "Ingredients",
|
||||||
"Supermarket": "Supermarket",
|
"Supermarket": "Supermarket",
|
||||||
"Categories": "Categories",
|
"Categories": "Categories",
|
||||||
|
@ -46,6 +46,7 @@ export class StandardToasts {
|
|||||||
static FAIL_FETCH = "FAIL_FETCH"
|
static FAIL_FETCH = "FAIL_FETCH"
|
||||||
static FAIL_UPDATE = "FAIL_UPDATE"
|
static FAIL_UPDATE = "FAIL_UPDATE"
|
||||||
static FAIL_DELETE = "FAIL_DELETE"
|
static FAIL_DELETE = "FAIL_DELETE"
|
||||||
|
static FAIL_DELETE_PROTECTED = "FAIL_DELETE_PROTECTED"
|
||||||
static FAIL_MOVE = "FAIL_MOVE"
|
static FAIL_MOVE = "FAIL_MOVE"
|
||||||
static FAIL_MERGE = "FAIL_MERGE"
|
static FAIL_MERGE = "FAIL_MERGE"
|
||||||
|
|
||||||
@ -81,6 +82,9 @@ export class StandardToasts {
|
|||||||
case StandardToasts.FAIL_DELETE:
|
case StandardToasts.FAIL_DELETE:
|
||||||
makeToast(i18n.tc("Failure"), i18n.tc("err_deleting_resource"), "danger")
|
makeToast(i18n.tc("Failure"), i18n.tc("err_deleting_resource"), "danger")
|
||||||
break
|
break
|
||||||
|
case StandardToasts.FAIL_DELETE_PROTECTED:
|
||||||
|
makeToast(i18n.tc("Protected"), i18n.tc("err_deleting_protected_resource"), "danger")
|
||||||
|
break
|
||||||
case StandardToasts.FAIL_MOVE:
|
case StandardToasts.FAIL_MOVE:
|
||||||
makeToast(i18n.tc("Failure"), i18n.tc("err_moving_resource") + (err_details ? "\n" + err_details : ""), "danger")
|
makeToast(i18n.tc("Failure"), i18n.tc("err_moving_resource") + (err_details ? "\n" + err_details : ""), "danger")
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user