added ability to open ingredient editor from food/unit list

This commit is contained in:
vabene1111
2022-04-17 22:43:33 +02:00
parent d50fb69ce9
commit f0d59a8c9c
7 changed files with 53 additions and 5 deletions

View File

@@ -6,7 +6,10 @@
</template>
<b-dropdown-item v-on:click="$emit('item-action', 'edit')" v-if="show_edit"> <i class="fas fa-pencil-alt fa-fw"></i> {{ $t("Edit") }} </b-dropdown-item>
<b-dropdown-item v-on:click="$emit('item-action', 'delete')" v-if="show_delete"> <i class="fas fa-trash-alt fa-fw"></i> {{ $t("Delete") }} </b-dropdown-item>
<b-dropdown-item v-on:click="$emit('item-action', 'ingredient-editor')" v-if="show_ingredient_editor"> <i class="fas fa-th-list fa-dw"></i> {{ $t("Ingredient Editor") }} </b-dropdown-item>
<b-dropdown-item v-on:click="$emit('item-action', 'add-shopping')" v-if="show_shopping">
<i class="fas fa-cart-plus fa-fw"></i> {{ $t("Add_to_Shopping") }}
</b-dropdown-item>
@@ -24,8 +27,11 @@
</template>
<script>
import {ResolveUrlMixin} from "@/utils/utils";
export default {
name: "GenericContextMenu",
mixins: [ResolveUrlMixin],
props: {
show_edit: { type: Boolean, default: true },
show_delete: { type: Boolean, default: true },
@@ -33,6 +39,7 @@ export default {
show_merge: { type: Boolean, default: false },
show_shopping: { type: Boolean, default: false },
show_onhand: { type: Boolean, default: false },
show_ingredient_editor: { type: Boolean, default: false },
},
}
</script>

View File

@@ -61,6 +61,7 @@
:show_move="useMove"
:show_shopping="useShopping"
:show_onhand="useOnhand"
:show_ingredient_editor="useIngredientEditor"
@item-action="$emit('item-action', { action: $event, source: item })"
>
</generic-context-menu>
@@ -132,11 +133,12 @@ import GenericOrderedPill from "@/components/GenericOrderedPill"
import RecipeCard from "@/components/RecipeCard"
import { mixin as clickaway } from "vue-clickaway"
import { createPopper } from "@popperjs/core"
import {ApiMixin} from "@/utils/utils";
export default {
name: "GenericHorizontalCard",
components: { GenericContextMenu, RecipeCard, Badges, GenericPill, GenericOrderedPill },
mixins: [clickaway],
mixins: [clickaway, ApiMixin],
props: {
item: { type: Object },
model: { type: Object },
@@ -186,6 +188,9 @@ export default {
useDrag: function () {
return this.useMove || this.useMerge
},
useIngredientEditor: function (){
return (this.model === this.Models.FOOD || this.model === this.Models.UNIT)
},
itemTags: function () {
return this.model?.tags ?? []
},