mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-06 22:58:19 -05:00
added ability to open ingredient editor from food/unit list
This commit is contained in:
@@ -88,7 +88,9 @@
|
||||
|
||||
</td>
|
||||
<td style="width: 5vw">
|
||||
<b-button :disabled="i.changed !== true" :variant="(i.changed !== true) ? 'primary' : 'success'" @click="updateIngredient(i)">
|
||||
<b-button :disabled="i.changed !== true"
|
||||
:variant="(i.changed !== true) ? 'primary' : 'success'"
|
||||
@click="updateIngredient(i)">
|
||||
<i class="fas fa-save"></i>
|
||||
</b-button>
|
||||
</td>
|
||||
@@ -137,6 +139,20 @@ export default {
|
||||
computed: {},
|
||||
mounted() {
|
||||
this.$i18n.locale = window.CUSTOM_LOCALE
|
||||
if (window.DEFAULT_FOOD !== -1) {
|
||||
this.food = {id: window.DEFAULT_FOOD}
|
||||
let apiClient = new ApiApiFactory()
|
||||
apiClient.retrieveFood(this.food.id).then(r => {
|
||||
this.food = r.data
|
||||
})
|
||||
}
|
||||
if (window.DEFAULT_UNIT !== -1) {
|
||||
this.unit = {id: window.DEFAULT_UNIT}
|
||||
let apiClient = new ApiApiFactory()
|
||||
apiClient.retrieveUnit(this.unit.id).then(r => {
|
||||
this.unit = r.data
|
||||
})
|
||||
}
|
||||
this.refreshList()
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -80,7 +80,7 @@ import {BootstrapVue} from "bootstrap-vue"
|
||||
|
||||
import "bootstrap-vue/dist/bootstrap-vue.css"
|
||||
|
||||
import {CardMixin, ApiMixin, getConfig} from "@/utils/utils"
|
||||
import {CardMixin, ApiMixin, getConfig, resolveDjangoUrl} from "@/utils/utils"
|
||||
import {StandardToasts, ToastMixin} from "@/utils/utils"
|
||||
|
||||
import GenericInfiniteCards from "@/components/GenericInfiniteCards"
|
||||
@@ -158,7 +158,6 @@ export default {
|
||||
let target = e?.target ?? undefined
|
||||
this.this_item = source
|
||||
this.this_target = target
|
||||
|
||||
switch (e.action) {
|
||||
case "delete":
|
||||
this.this_action = this.Actions.DELETE
|
||||
@@ -173,6 +172,16 @@ export default {
|
||||
this.this_action = this.Actions.UPDATE
|
||||
this.show_modal = true
|
||||
break
|
||||
case "ingredient-editor": {
|
||||
let url = resolveDjangoUrl("view_ingredient_editor")
|
||||
if (this.this_model === this.Models.FOOD) {
|
||||
window.location.href = url + '?food_id=' + e.source.id
|
||||
}
|
||||
if (this.this_model === this.Models.UNIT) {
|
||||
window.location.href = url + '?unit_id=' + e.source.id
|
||||
}
|
||||
break
|
||||
}
|
||||
case "move":
|
||||
if (target == null) {
|
||||
this.this_item = e.source
|
||||
|
||||
Reference in New Issue
Block a user