fix display issues
This commit is contained in:
@ -123,7 +123,7 @@
|
|||||||
<div class="collapse" :id="'section-' + sectionID(x, i)" visible role="tabpanel" :class="{ show: x == 'false' }">
|
<div class="collapse" :id="'section-' + sectionID(x, i)" visible role="tabpanel" :class="{ show: x == 'false' }">
|
||||||
<!-- passing an array of values to the table grouped by Food -->
|
<!-- passing an array of values to the table grouped by Food -->
|
||||||
<transition-group name="slide-fade">
|
<transition-group name="slide-fade">
|
||||||
<div v-for="(entries, x) in Object.entries(s)" :key="x">
|
<div class="mx-4" v-for="(entries, x) in Object.entries(s)" :key="x">
|
||||||
<transition name="slide-fade" mode="out-in">
|
<transition name="slide-fade" mode="out-in">
|
||||||
<ShoppingLineItem
|
<ShoppingLineItem
|
||||||
:entries="entries[1]"
|
:entries="entries[1]"
|
||||||
@ -563,6 +563,26 @@
|
|||||||
</div>
|
</div>
|
||||||
</b-tab>
|
</b-tab>
|
||||||
</b-tabs>
|
</b-tabs>
|
||||||
|
|
||||||
|
<transition name="slided-fade">
|
||||||
|
<div class="row fixed-bottom p-2 b-1 border-top text-center d-flex d-md-none" style="background: rgba(255, 255, 255, 0.6)" v-if="current_tab === 0">
|
||||||
|
<div class="col-6">
|
||||||
|
<a class="btn btn-block btn-success shadow-none" @click="entrymode = !entrymode"
|
||||||
|
><i class="fas fa-cart-plus"></i>
|
||||||
|
{{ $t("New Entry") }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<b-dropdown id="dropdown-dropup" block dropup variant="primary" class="shadow-none">
|
||||||
|
<template #button-content> <i class="fas fa-download"></i> {{ $t("Export") }} </template>
|
||||||
|
<DownloadPDF dom="#shoppinglist" name="shopping.pdf" :label="$t('download_pdf')" icon="far fa-file-pdf" />
|
||||||
|
<DownloadCSV :items="csvData" :delim="settings.csv_delim" name="shopping.csv" :label="$t('download_csv')" icon="fas fa-file-csv" />
|
||||||
|
<CopyToClipboard :items="csvData" :settings="settings" :label="$t('copy_to_clipboard')" icon="fas fa-clipboard-list" />
|
||||||
|
<CopyToClipboard :items="csvData" :settings="settings" format="table" :label="$t('copy_markdown_table')" icon="fab fa-markdown" />
|
||||||
|
</b-dropdown>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
<b-popover target="id_filters_button" triggers="click" placement="bottomleft" :title="$t('Filters')">
|
<b-popover target="id_filters_button" triggers="click" placement="bottomleft" :title="$t('Filters')">
|
||||||
<div>
|
<div>
|
||||||
<b-form-group v-bind:label="$t('GroupBy')" label-for="popover-input-1" label-cols="6" class="mb-1">
|
<b-form-group v-bind:label="$t('GroupBy')" label-for="popover-input-1" label-cols="6" class="mb-1">
|
||||||
@ -643,25 +663,6 @@
|
|||||||
</ContextMenuItem>
|
</ContextMenuItem>
|
||||||
</template>
|
</template>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
<transition name="slided-fade">
|
|
||||||
<div class="row fixed-bottom p-2 b-1 border-top text-center d-flex d-md-none" style="background: rgba(255, 255, 255, 0.6)" v-if="current_tab === 0">
|
|
||||||
<div class="col-6">
|
|
||||||
<a class="btn btn-block btn-success shadow-none" @click="entrymode = !entrymode"
|
|
||||||
><i class="fas fa-cart-plus"></i>
|
|
||||||
{{ $t("New Entry") }}
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<b-dropdown id="dropdown-dropup" block dropup variant="primary" class="shadow-none">
|
|
||||||
<template #button-content> <i class="fas fa-download"></i> {{ $t("Export") }} </template>
|
|
||||||
<DownloadPDF dom="#shoppinglist" name="shopping.pdf" :label="$t('download_pdf')" icon="far fa-file-pdf" />
|
|
||||||
<DownloadCSV :items="csvData" :delim="settings.csv_delim" name="shopping.csv" :label="$t('download_csv')" icon="fas fa-file-csv" />
|
|
||||||
<CopyToClipboard :items="csvData" :settings="settings" :label="$t('copy_to_clipboard')" icon="fas fa-clipboard-list" />
|
|
||||||
<CopyToClipboard :items="csvData" :settings="settings" format="table" :label="$t('copy_markdown_table')" icon="fab fa-markdown" />
|
|
||||||
</b-dropdown>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</transition>
|
|
||||||
<shopping-modal v-if="new_recipe.id" :recipe="new_recipe" :servings="parseInt(add_recipe_servings)" :modal_id="new_recipe.id" @finish="finishShopping" :list_recipe="new_recipe.list_recipe" />
|
<shopping-modal v-if="new_recipe.id" :recipe="new_recipe" :servings="parseInt(add_recipe_servings)" :modal_id="new_recipe.id" @finish="finishShopping" :list_recipe="new_recipe.list_recipe" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -914,6 +915,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
console.log(screen.height)
|
||||||
this.getShoppingList()
|
this.getShoppingList()
|
||||||
this.getSupermarkets()
|
this.getSupermarkets()
|
||||||
this.getShoppingCategories()
|
this.getShoppingCategories()
|
||||||
@ -1102,7 +1104,6 @@ export default {
|
|||||||
if (!autosync) {
|
if (!autosync) {
|
||||||
if (results.data?.length) {
|
if (results.data?.length) {
|
||||||
this.items = results.data
|
this.items = results.data
|
||||||
console.log(this.items)
|
|
||||||
} else {
|
} else {
|
||||||
console.log("no data returned")
|
console.log("no data returned")
|
||||||
}
|
}
|
||||||
@ -1483,7 +1484,7 @@ export default {
|
|||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media screen and (max-width: 768px) {
|
||||||
#shoppinglist {
|
#shoppinglist {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -1494,6 +1495,17 @@ export default {
|
|||||||
padding-right: 8px !important;
|
padding-right: 8px !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@media screen and (min-height: 700px) and (max-width: 768px) {
|
||||||
|
#shoppinglist {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex-grow: 1;
|
||||||
|
overflow-y: scroll;
|
||||||
|
overflow-x: hidden;
|
||||||
|
height: 72vh;
|
||||||
|
padding-right: 8px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.settings-checkbox {
|
.settings-checkbox {
|
||||||
font-size: 0.3rem;
|
font-size: 0.3rem;
|
||||||
|
@ -117,7 +117,6 @@ export default {
|
|||||||
limit: this.limit,
|
limit: this.limit,
|
||||||
}
|
}
|
||||||
this.genericAPI(this.model, this.Actions.LIST, options).then((result) => {
|
this.genericAPI(this.model, this.Actions.LIST, options).then((result) => {
|
||||||
console.log(result)
|
|
||||||
this.objects = this.sticky_options.concat(result.data?.results ?? result.data)
|
this.objects = this.sticky_options.concat(result.data?.results ?? result.data)
|
||||||
if (this.nothingSelected && this.objects.length > 0) {
|
if (this.nothingSelected && this.objects.length > 0) {
|
||||||
this.objects.forEach((item) => {
|
this.objects.forEach((item) => {
|
||||||
|
@ -142,20 +142,12 @@ export default {
|
|||||||
this.shopping_list = result.data
|
this.shopping_list = result.data
|
||||||
|
|
||||||
if (this.add_shopping_mode) {
|
if (this.add_shopping_mode) {
|
||||||
console.log("add shopping mode", this.recipe_list, this.steps)
|
|
||||||
if (this.recipe_list) {
|
if (this.recipe_list) {
|
||||||
this.$emit(
|
this.$emit(
|
||||||
"starting-cart",
|
"starting-cart",
|
||||||
this.shopping_list.filter((x) => x.list_recipe === this.recipe_list).map((x) => x.ingredient)
|
this.shopping_list.filter((x) => x.list_recipe === this.recipe_list).map((x) => x.ingredient)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
console.log(
|
|
||||||
this.steps
|
|
||||||
.map((x) => x.ingredients)
|
|
||||||
.flat()
|
|
||||||
.filter((x) => x?.food?.food_onhand == false && x?.food?.ignore_shopping == false)
|
|
||||||
.map((x) => x.id)
|
|
||||||
)
|
|
||||||
this.$emit(
|
this.$emit(
|
||||||
"starting-cart",
|
"starting-cart",
|
||||||
this.steps
|
this.steps
|
||||||
|
@ -71,9 +71,7 @@ export default {
|
|||||||
image_placeholder: window.IMAGE_PLACEHOLDER,
|
image_placeholder: window.IMAGE_PLACEHOLDER,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {},
|
||||||
console.log(this.value)
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
entry: function () {
|
entry: function () {
|
||||||
return this.value.originalItem
|
return this.value.originalItem
|
||||||
|
@ -154,7 +154,6 @@ export default {
|
|||||||
.createMealPlan(entry)
|
.createMealPlan(entry)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
this.$bvModal.hide(`modal-meal-plan_${this.modal_id}`)
|
this.$bvModal.hide(`modal-meal-plan_${this.modal_id}`)
|
||||||
console.log(entry)
|
|
||||||
if (reviewshopping) {
|
if (reviewshopping) {
|
||||||
this.mealplan = result.data.id
|
this.mealplan = result.data.id
|
||||||
this.servings_value = result.data.servings
|
this.servings_value = result.data.servings
|
||||||
|
@ -1,334 +1,311 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="shopping_line_item">
|
<div id="shopping_line_item">
|
||||||
<b-row align-h="start">
|
|
||||||
<b-col cols="3" md="2" class="justify-content-start align-items-center d-flex d-md-none pr-0"
|
|
||||||
v-if="settings.left_handed">
|
|
||||||
<input type="checkbox" class="form-control form-control-sm checkbox-control-mobile" :checked="formatChecked"
|
|
||||||
@change="updateChecked"
|
|
||||||
:key="entries[0].id"/>
|
|
||||||
<b-button size="sm" @click="showDetails = !showDetails" class="d-inline-block d-md-none p-0" variant="link">
|
|
||||||
<div class="text-nowrap"><i class="fa fa-chevron-right rotate" :class="showDetails ? 'rotated' : ''"></i>
|
|
||||||
</div>
|
|
||||||
</b-button>
|
|
||||||
</b-col>
|
|
||||||
<b-col cols="1" class="align-items-center d-flex">
|
|
||||||
<div class="dropdown b-dropdown position-static inline-block" data-html2canvas-ignore="true"
|
|
||||||
@click.stop="$emit('open-context-menu', $event, entries)">
|
|
||||||
<button
|
|
||||||
aria-haspopup="true"
|
|
||||||
aria-expanded="false"
|
|
||||||
type="button"
|
|
||||||
:class="settings.left_handed ? 'dropdown-spacing' : ''"
|
|
||||||
class="btn dropdown-toggle btn-link text-decoration-none text-body pr-1 dropdown-toggle-no-caret">
|
|
||||||
<i class="fas fa-ellipsis-v fa-lg"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</b-col>
|
|
||||||
<b-col cols="1" class="justify-content-center align-items-center d-none d-md-flex">
|
|
||||||
<input type="checkbox" class="form-control form-control-sm checkbox-control" :checked="formatChecked"
|
|
||||||
@change="updateChecked"
|
|
||||||
:key="entries[0].id"/>
|
|
||||||
</b-col>
|
|
||||||
<b-col cols="8" md="9">
|
|
||||||
<b-row class="d-flex h-100">
|
|
||||||
<b-col cols="5" md="3" class="d-flex align-items-center" v-if="Object.entries(formatAmount).length == 1">
|
|
||||||
<strong class="mr-1">{{ Object.entries(formatAmount)[0][1] }}</strong> {{
|
|
||||||
Object.entries(formatAmount)[0][0]
|
|
||||||
}}
|
|
||||||
</b-col>
|
|
||||||
<b-col cols="5" md="3" class="d-flex flex-column" v-if="Object.entries(formatAmount).length != 1">
|
|
||||||
<div class="small" v-for="(x, i) in Object.entries(formatAmount)" :key="i">{{ x[1] }}  
|
|
||||||
{{ x[0] }}
|
|
||||||
</div>
|
|
||||||
</b-col>
|
|
||||||
|
|
||||||
<b-col cols="7" md="6" class="align-items-center d-flex pl-0 pr-0 pl-md-2 pr-md-2">
|
|
||||||
{{ formatFood }}
|
|
||||||
</b-col>
|
|
||||||
<b-col cols="3" data-html2canvas-ignore="true"
|
|
||||||
class="align-items-center d-none d-md-flex justify-content-end">
|
|
||||||
<b-button size="sm" @click="showDetails = !showDetails" class="p-0 mr-0 mr-md-2 p-md-2 text-decoration-none"
|
|
||||||
variant="link">
|
|
||||||
<div class="text-nowrap"><i class="fa fa-chevron-right rotate"
|
|
||||||
:class="showDetails ? 'rotated' : ''"></i> <span
|
|
||||||
class="d-none d-md-inline-block">{{ $t('Details') }}</span>
|
|
||||||
</div>
|
|
||||||
</b-button>
|
|
||||||
</b-col>
|
|
||||||
</b-row>
|
|
||||||
</b-col>
|
|
||||||
<b-col cols="3" md="2" class="justify-content-start align-items-center d-flex d-md-none"
|
|
||||||
v-if="!settings.left_handed">
|
|
||||||
<b-button size="sm" @click="showDetails = !showDetails" class="d-inline-block d-md-none p-0" variant="link">
|
|
||||||
<div class="text-nowrap"><i class="fa fa-chevron-right rotate" :class="showDetails ? 'rotated' : ''"></i>
|
|
||||||
</div>
|
|
||||||
</b-button>
|
|
||||||
<input type="checkbox" class="form-control form-control-sm checkbox-control-mobile" :checked="formatChecked"
|
|
||||||
@change="updateChecked"
|
|
||||||
:key="entries[0].id"/>
|
|
||||||
</b-col>
|
|
||||||
</b-row>
|
|
||||||
<b-row align-h="center" class="d-none d-md-flex">
|
|
||||||
<b-col cols="12">
|
|
||||||
<div class="small text-muted text-truncate">{{ formatHint }}</div>
|
|
||||||
</b-col>
|
|
||||||
</b-row>
|
|
||||||
<!-- detail rows -->
|
|
||||||
<div class="card no-body mb-1 pt-2 align-content-center shadow-sm" v-if="showDetails">
|
|
||||||
<div v-for="(e, x) in entries" :key="e.id">
|
|
||||||
<b-row class="small justify-content-around">
|
|
||||||
<b-col cols="auto" md="4" class="overflow-hidden text-nowrap">
|
|
||||||
<button
|
|
||||||
aria-haspopup="true"
|
|
||||||
aria-expanded="false"
|
|
||||||
type="button"
|
|
||||||
class="btn btn-link btn-sm m-0 p-0 pl-2"
|
|
||||||
style="text-overflow: ellipsis"
|
|
||||||
@click.stop="openRecipeCard($event, e)"
|
|
||||||
@mouseover="openRecipeCard($event, e)">
|
|
||||||
{{ formatOneRecipe(e) }}
|
|
||||||
</button>
|
|
||||||
</b-col>
|
|
||||||
<b-col cols="auto" md="4" class="text-muted">{{ formatOneMealPlan(e) }}</b-col>
|
|
||||||
<b-col cols="auto" md="4" class="text-muted text-right overflow-hidden text-nowrap pr-4">
|
|
||||||
{{ formatOneCreatedBy(e) }}
|
|
||||||
<div v-if="formatOneCompletedAt(e)">{{ formatOneCompletedAt(e) }}</div>
|
|
||||||
</b-col>
|
|
||||||
</b-row>
|
|
||||||
<b-row align-h="start">
|
<b-row align-h="start">
|
||||||
<b-col cols="3" md="2" class="justify-content-start align-items-center d-flex d-md-none pr-0"
|
<b-col cols="3" md="2" class="justify-content-start align-items-center d-flex d-md-none pr-0" v-if="settings.left_handed">
|
||||||
v-if="settings.left_handed">
|
<input type="checkbox" class="form-control form-control-sm checkbox-control-mobile" :checked="formatChecked" @change="updateChecked" :key="entries[0].id" />
|
||||||
<input type="checkbox" class="form-control form-control-sm checkbox-control-mobile"
|
<b-button size="sm" @click="showDetails = !showDetails" class="d-inline-block d-md-none p-0" variant="link">
|
||||||
:checked="formatChecked"
|
<div class="text-nowrap"><i class="fa fa-chevron-right rotate" :class="showDetails ? 'rotated' : ''"></i></div>
|
||||||
@change="updateChecked"
|
</b-button>
|
||||||
:key="entries[0].id"/>
|
</b-col>
|
||||||
</b-col>
|
<b-col cols="1" class="align-items-center d-flex">
|
||||||
<b-col cols="1" class="align-items-center d-flex">
|
<div class="dropdown b-dropdown position-static inline-block" data-html2canvas-ignore="true" @click.stop="$emit('open-context-menu', $event, entries)">
|
||||||
<div class="dropdown b-dropdown position-static inline-block" data-html2canvas-ignore="true"
|
<button
|
||||||
@click.stop="$emit('open-context-menu', $event, e)">
|
aria-haspopup="true"
|
||||||
<button
|
aria-expanded="false"
|
||||||
aria-haspopup="true"
|
type="button"
|
||||||
aria-expanded="false"
|
:class="settings.left_handed ? 'dropdown-spacing' : ''"
|
||||||
type="button"
|
class="btn dropdown-toggle btn-link text-decoration-none text-body pr-1 dropdown-toggle-no-caret"
|
||||||
:class="settings.left_handed ? 'dropdown-spacing' : ''"
|
>
|
||||||
class="btn dropdown-toggle btn-link text-decoration-none text-body pr-1 dropdown-toggle-no-caret">
|
<i class="fas fa-ellipsis-v fa-lg"></i>
|
||||||
<i class="fas fa-ellipsis-v fa-lg"></i>
|
</button>
|
||||||
</button>
|
</div>
|
||||||
</div>
|
</b-col>
|
||||||
</b-col>
|
<b-col cols="1" class="px-1 justify-content-center align-items-center d-none d-md-flex">
|
||||||
<b-col cols="1" class="justify-content-center align-items-center d-none d-md-flex">
|
<input type="checkbox" class="form-control form-control-sm checkbox-control" :checked="formatChecked" @change="updateChecked" :key="entries[0].id" />
|
||||||
<input type="checkbox" class="form-control form-control-sm checkbox-control" :checked="formatChecked"
|
</b-col>
|
||||||
@change="updateChecked"
|
<b-col cols="8" md="9">
|
||||||
:key="entries[0].id"/>
|
<b-row class="d-flex h-100">
|
||||||
</b-col>
|
<b-col cols="5" md="3" class="d-flex align-items-center" v-if="Object.entries(formatAmount).length == 1">
|
||||||
<b-col cols="8" md="9">
|
<strong class="mr-1">{{ Object.entries(formatAmount)[0][1] }}</strong> {{ Object.entries(formatAmount)[0][0] }}
|
||||||
<b-row class="d-flex align-items-center h-100">
|
</b-col>
|
||||||
<b-col cols="5" md="3" class="d-flex align-items-center">
|
<b-col cols="5" md="3" class="d-flex flex-column" v-if="Object.entries(formatAmount).length != 1">
|
||||||
<strong class="mr-1">{{ formatOneAmount(e) }}</strong> {{ formatOneUnit(e) }}
|
<div class="small" v-for="(x, i) in Object.entries(formatAmount)" :key="i">
|
||||||
</b-col>
|
{{ x[1] }}  
|
||||||
<b-col cols="7" md="6" class="align-items-center d-flex pl-0 pr-0 pl-md-2 pr-md-2">
|
{{ x[0] }}
|
||||||
{{ formatOneFood(e) }}
|
</div>
|
||||||
</b-col>
|
</b-col>
|
||||||
<b-col cols="12" class="d-flex d-md-none">
|
|
||||||
<div class="small text-muted text-truncate" v-for="(n, i) in formatOneNote(e)" :key="i">{{ n }}</div>
|
<b-col cols="7" md="6" class="align-items-center d-flex pl-0 pr-0 pl-md-2 pr-md-2">
|
||||||
</b-col>
|
{{ formatFood }}
|
||||||
</b-row>
|
</b-col>
|
||||||
</b-col>
|
<b-col cols="3" data-html2canvas-ignore="true" class="align-items-center d-none d-md-flex justify-content-end">
|
||||||
<b-col cols="3" md="2" class="justify-content-start align-items-center d-flex d-md-none"
|
<b-button size="sm" @click="showDetails = !showDetails" class="p-0 mr-0 mr-md-2 p-md-2 text-decoration-none" variant="link">
|
||||||
v-if="!settings.left_handed">
|
<div class="text-nowrap">
|
||||||
<input type="checkbox" class="form-control form-control-sm checkbox-control-mobile"
|
<i class="fa fa-chevron-right rotate" :class="showDetails ? 'rotated' : ''"></i> <span class="d-none d-md-inline-block">{{ $t("Details") }}</span>
|
||||||
:checked="formatChecked"
|
</div>
|
||||||
@change="updateChecked"
|
</b-button>
|
||||||
:key="entries[0].id"/>
|
</b-col>
|
||||||
</b-col>
|
</b-row>
|
||||||
|
</b-col>
|
||||||
|
<b-col cols="3" md="2" class="justify-content-start align-items-center d-flex d-md-none" v-if="!settings.left_handed">
|
||||||
|
<b-button size="sm" @click="showDetails = !showDetails" class="d-inline-block d-md-none p-0" variant="link">
|
||||||
|
<div class="text-nowrap"><i class="fa fa-chevron-right rotate" :class="showDetails ? 'rotated' : ''"></i></div>
|
||||||
|
</b-button>
|
||||||
|
<input type="checkbox" class="form-control form-control-sm checkbox-control-mobile" :checked="formatChecked" @change="updateChecked" :key="entries[0].id" />
|
||||||
|
</b-col>
|
||||||
</b-row>
|
</b-row>
|
||||||
<hr class="w-75" v-if="x !== entries.length -1"/>
|
<b-row align-h="center" class="d-none d-md-flex">
|
||||||
<div class="pb-4" v-if="x === entries.length -1"></div>
|
<b-col cols="12">
|
||||||
</div>
|
<div class="small text-muted text-truncate">{{ formatHint }}</div>
|
||||||
</div>
|
</b-col>
|
||||||
<hr class="m-1" v-if="!showDetails"/>
|
</b-row>
|
||||||
<ContextMenu ref="recipe_card" triggers="click, hover" :title="$t('Filters')" style="max-width: 300">
|
<!-- detail rows -->
|
||||||
<template #menu="{ contextData }" v-if="recipe">
|
<div class="card no-body mb-1 pt-2 align-content-center shadow-sm" v-if="showDetails">
|
||||||
<ContextMenuItem>
|
<div v-for="(e, x) in entries" :key="e.id">
|
||||||
<RecipeCard :recipe="contextData" :detail="false"></RecipeCard>
|
<b-row class="small justify-content-around">
|
||||||
</ContextMenuItem>
|
<b-col cols="auto" md="4" class="overflow-hidden text-nowrap">
|
||||||
<ContextMenuItem @click="$refs.menu.close()">
|
<button
|
||||||
<b-form-group label-cols="9" content-cols="3" class="text-nowrap m-0 mr-2">
|
aria-haspopup="true"
|
||||||
<template #label>
|
aria-expanded="false"
|
||||||
<a class="dropdown-item p-2" href="#"><i class="fas fa-pizza-slice"></i> {{ $t("Servings") }}</a>
|
type="button"
|
||||||
</template>
|
class="btn btn-link btn-sm m-0 p-0 pl-2"
|
||||||
<div @click.prevent.stop>
|
style="text-overflow: ellipsis"
|
||||||
<b-form-input class="mt-2" min="0" type="number" v-model="servings"></b-form-input>
|
@click.stop="openRecipeCard($event, e)"
|
||||||
|
@mouseover="openRecipeCard($event, e)"
|
||||||
|
>
|
||||||
|
{{ formatOneRecipe(e) }}
|
||||||
|
</button>
|
||||||
|
</b-col>
|
||||||
|
<b-col cols="auto" md="4" class="text-muted">{{ formatOneMealPlan(e) }}</b-col>
|
||||||
|
<b-col cols="auto" md="4" class="text-muted text-right overflow-hidden text-nowrap pr-4">
|
||||||
|
{{ formatOneCreatedBy(e) }}
|
||||||
|
<div v-if="formatOneCompletedAt(e)">{{ formatOneCompletedAt(e) }}</div>
|
||||||
|
</b-col>
|
||||||
|
</b-row>
|
||||||
|
<b-row align-h="start">
|
||||||
|
<b-col cols="3" md="2" class="justify-content-start align-items-center d-flex d-md-none pr-0" v-if="settings.left_handed">
|
||||||
|
<input type="checkbox" class="form-control form-control-sm checkbox-control-mobile" :checked="formatChecked" @change="updateChecked" :key="entries[0].id" />
|
||||||
|
</b-col>
|
||||||
|
<b-col cols="1" class="align-items-center d-flex">
|
||||||
|
<div class="dropdown b-dropdown position-static inline-block" data-html2canvas-ignore="true" @click.stop="$emit('open-context-menu', $event, e)">
|
||||||
|
<button
|
||||||
|
aria-haspopup="true"
|
||||||
|
aria-expanded="false"
|
||||||
|
type="button"
|
||||||
|
:class="settings.left_handed ? 'dropdown-spacing' : ''"
|
||||||
|
class="btn dropdown-toggle btn-link text-decoration-none text-body pr-1 dropdown-toggle-no-caret"
|
||||||
|
>
|
||||||
|
<i class="fas fa-ellipsis-v fa-lg"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</b-col>
|
||||||
|
<b-col cols="1" class="justify-content-center align-items-center d-none d-md-flex">
|
||||||
|
<input type="checkbox" class="form-control form-control-sm checkbox-control" :checked="formatChecked" @change="updateChecked" :key="entries[0].id" />
|
||||||
|
</b-col>
|
||||||
|
<b-col cols="8" md="9">
|
||||||
|
<b-row class="d-flex align-items-center h-100">
|
||||||
|
<b-col cols="5" md="3" class="d-flex align-items-center">
|
||||||
|
<strong class="mr-1">{{ formatOneAmount(e) }}</strong> {{ formatOneUnit(e) }}
|
||||||
|
</b-col>
|
||||||
|
<b-col cols="7" md="6" class="align-items-center d-flex pl-0 pr-0 pl-md-2 pr-md-2">
|
||||||
|
{{ formatOneFood(e) }}
|
||||||
|
</b-col>
|
||||||
|
<b-col cols="12" class="d-flex d-md-none">
|
||||||
|
<div class="small text-muted text-truncate" v-for="(n, i) in formatOneNote(e)" :key="i">{{ n }}</div>
|
||||||
|
</b-col>
|
||||||
|
</b-row>
|
||||||
|
</b-col>
|
||||||
|
<b-col cols="3" md="2" class="justify-content-start align-items-center d-flex d-md-none" v-if="!settings.left_handed">
|
||||||
|
<input type="checkbox" class="form-control form-control-sm checkbox-control-mobile" :checked="formatChecked" @change="updateChecked" :key="entries[0].id" />
|
||||||
|
</b-col>
|
||||||
|
</b-row>
|
||||||
|
<hr class="w-75" v-if="x !== entries.length - 1" />
|
||||||
|
<div class="pb-4" v-if="x === entries.length - 1"></div>
|
||||||
</div>
|
</div>
|
||||||
</b-form-group>
|
</div>
|
||||||
</ContextMenuItem>
|
<hr class="m-1" v-if="!showDetails" />
|
||||||
</template>
|
<ContextMenu ref="recipe_card" triggers="click, hover" :title="$t('Filters')" style="max-width: 300">
|
||||||
</ContextMenu>
|
<template #menu="{ contextData }" v-if="recipe">
|
||||||
</div>
|
<ContextMenuItem>
|
||||||
|
<RecipeCard :recipe="contextData" :detail="false"></RecipeCard>
|
||||||
|
</ContextMenuItem>
|
||||||
|
<ContextMenuItem @click="$refs.menu.close()">
|
||||||
|
<b-form-group label-cols="9" content-cols="3" class="text-nowrap m-0 mr-2">
|
||||||
|
<template #label>
|
||||||
|
<a class="dropdown-item p-2" href="#"><i class="fas fa-pizza-slice"></i> {{ $t("Servings") }}</a>
|
||||||
|
</template>
|
||||||
|
<div @click.prevent.stop>
|
||||||
|
<b-form-input class="mt-2" min="0" type="number" v-model="servings"></b-form-input>
|
||||||
|
</div>
|
||||||
|
</b-form-group>
|
||||||
|
</ContextMenuItem>
|
||||||
|
</template>
|
||||||
|
</ContextMenu>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Vue from "vue"
|
import Vue from "vue"
|
||||||
import {BootstrapVue} from "bootstrap-vue"
|
import { BootstrapVue } from "bootstrap-vue"
|
||||||
import "bootstrap-vue/dist/bootstrap-vue.css"
|
import "bootstrap-vue/dist/bootstrap-vue.css"
|
||||||
import ContextMenu from "@/components/ContextMenu/ContextMenu"
|
import ContextMenu from "@/components/ContextMenu/ContextMenu"
|
||||||
import ContextMenuItem from "@/components/ContextMenu/ContextMenuItem"
|
import ContextMenuItem from "@/components/ContextMenu/ContextMenuItem"
|
||||||
import {ApiMixin} from "@/utils/utils"
|
import { ApiMixin } from "@/utils/utils"
|
||||||
import RecipeCard from "./RecipeCard.vue"
|
import RecipeCard from "./RecipeCard.vue"
|
||||||
|
|
||||||
Vue.use(BootstrapVue)
|
Vue.use(BootstrapVue)
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// TODO ApiGenerator doesn't capture and share error information - would be nice to share error details when available
|
// TODO ApiGenerator doesn't capture and share error information - would be nice to share error details when available
|
||||||
// or i'm capturing it incorrectly
|
// or i'm capturing it incorrectly
|
||||||
name: "ShoppingLineItem",
|
name: "ShoppingLineItem",
|
||||||
mixins: [ApiMixin],
|
mixins: [ApiMixin],
|
||||||
components: {RecipeCard, ContextMenu, ContextMenuItem},
|
components: { RecipeCard, ContextMenu, ContextMenuItem },
|
||||||
props: {
|
props: {
|
||||||
entries: {
|
entries: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
},
|
||||||
|
settings: Object,
|
||||||
|
groupby: { type: String },
|
||||||
},
|
},
|
||||||
settings: Object,
|
data() {
|
||||||
groupby: {type: String},
|
return {
|
||||||
},
|
showDetails: false,
|
||||||
data() {
|
recipe: undefined,
|
||||||
return {
|
servings: 1,
|
||||||
showDetails: false,
|
|
||||||
recipe: undefined,
|
|
||||||
servings: 1,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
formatAmount: function () {
|
|
||||||
let amount = {}
|
|
||||||
this.entries.forEach((entry) => {
|
|
||||||
let unit = entry?.unit?.name ?? "----"
|
|
||||||
if (entry.amount) {
|
|
||||||
if (amount[unit]) {
|
|
||||||
amount[unit] += entry.amount
|
|
||||||
} else {
|
|
||||||
amount[unit] = entry.amount
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
for (const [k, v] of Object.entries(amount)) {
|
|
||||||
amount[k] = Math.round(v * 100 + Number.EPSILON) / 100 // javascript hack to force rounding at 2 places
|
|
||||||
}
|
|
||||||
return amount
|
|
||||||
},
|
},
|
||||||
formatCategory: function () {
|
computed: {
|
||||||
return this.formatOneCategory(this.entries[0]) || this.$t("Undefined")
|
formatAmount: function () {
|
||||||
},
|
let amount = {}
|
||||||
formatChecked: function () {
|
this.entries.forEach((entry) => {
|
||||||
return this.entries.map((x) => x.checked).every((x) => x === true)
|
let unit = entry?.unit?.name ?? "----"
|
||||||
},
|
if (entry.amount) {
|
||||||
formatHint: function () {
|
if (amount[unit]) {
|
||||||
if (this.groupby == "recipe") {
|
amount[unit] += entry.amount
|
||||||
return this.formatCategory
|
} else {
|
||||||
} else {
|
amount[unit] = entry.amount
|
||||||
return this.formatRecipe
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
formatFood: function () {
|
|
||||||
return this.formatOneFood(this.entries[0])
|
|
||||||
},
|
|
||||||
formatUnit: function () {
|
|
||||||
return this.formatOneUnit(this.entries[0])
|
|
||||||
},
|
|
||||||
formatRecipe: function () {
|
|
||||||
if (this.entries?.length == 1) {
|
|
||||||
return this.formatOneMealPlan(this.entries[0]) || ""
|
|
||||||
} else {
|
|
||||||
let mealplan_name = this.entries.filter((x) => x?.recipe_mealplan?.name)
|
|
||||||
// return [this.formatOneMealPlan(mealplan_name?.[0]), this.$t("CountMore", { count: this.entries?.length - 1 })].join(" ")
|
|
||||||
|
|
||||||
return mealplan_name
|
|
||||||
.map((x) => {
|
|
||||||
return this.formatOneMealPlan(x)
|
|
||||||
})
|
})
|
||||||
.join(" - ")
|
for (const [k, v] of Object.entries(amount)) {
|
||||||
}
|
amount[k] = Math.round(v * 100 + Number.EPSILON) / 100 // javascript hack to force rounding at 2 places
|
||||||
},
|
}
|
||||||
formatNotes: function () {
|
return amount
|
||||||
if (this.entries?.length == 1) {
|
},
|
||||||
return this.formatOneNote(this.entries[0]) || ""
|
formatCategory: function () {
|
||||||
}
|
return this.formatOneCategory(this.entries[0]) || this.$t("Undefined")
|
||||||
return ""
|
},
|
||||||
},
|
formatChecked: function () {
|
||||||
},
|
return this.entries.map((x) => x.checked).every((x) => x === true)
|
||||||
watch: {},
|
},
|
||||||
mounted() {
|
formatHint: function () {
|
||||||
this.servings = this.entries?.[0]?.recipe_mealplan?.servings ?? 0
|
if (this.groupby == "recipe") {
|
||||||
},
|
return this.formatCategory
|
||||||
methods: {
|
} else {
|
||||||
// this.genericAPI inherited from ApiMixin
|
return this.formatRecipe
|
||||||
|
}
|
||||||
|
},
|
||||||
|
formatFood: function () {
|
||||||
|
return this.formatOneFood(this.entries[0])
|
||||||
|
},
|
||||||
|
formatUnit: function () {
|
||||||
|
return this.formatOneUnit(this.entries[0])
|
||||||
|
},
|
||||||
|
formatRecipe: function () {
|
||||||
|
if (this.entries?.length == 1) {
|
||||||
|
return this.formatOneMealPlan(this.entries[0]) || ""
|
||||||
|
} else {
|
||||||
|
let mealplan_name = this.entries.filter((x) => x?.recipe_mealplan?.name)
|
||||||
|
// return [this.formatOneMealPlan(mealplan_name?.[0]), this.$t("CountMore", { count: this.entries?.length - 1 })].join(" ")
|
||||||
|
|
||||||
formatDate: function (datetime) {
|
return mealplan_name
|
||||||
if (!datetime) {
|
.map((x) => {
|
||||||
return
|
return this.formatOneMealPlan(x)
|
||||||
}
|
})
|
||||||
return Intl.DateTimeFormat(window.navigator.language, {
|
.join(" - ")
|
||||||
dateStyle: "short",
|
}
|
||||||
timeStyle: "short"
|
},
|
||||||
}).format(Date.parse(datetime))
|
formatNotes: function () {
|
||||||
|
if (this.entries?.length == 1) {
|
||||||
|
return this.formatOneNote(this.entries[0]) || ""
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
},
|
||||||
},
|
},
|
||||||
formatOneAmount: function (item) {
|
watch: {},
|
||||||
return item?.amount ?? 1
|
mounted() {
|
||||||
|
this.servings = this.entries?.[0]?.recipe_mealplan?.servings ?? 0
|
||||||
},
|
},
|
||||||
formatOneUnit: function (item) {
|
methods: {
|
||||||
return item?.unit?.name ?? ""
|
// this.genericAPI inherited from ApiMixin
|
||||||
|
|
||||||
|
formatDate: function (datetime) {
|
||||||
|
if (!datetime) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return Intl.DateTimeFormat(window.navigator.language, {
|
||||||
|
dateStyle: "short",
|
||||||
|
timeStyle: "short",
|
||||||
|
}).format(Date.parse(datetime))
|
||||||
|
},
|
||||||
|
formatOneAmount: function (item) {
|
||||||
|
return item?.amount ?? 1
|
||||||
|
},
|
||||||
|
formatOneUnit: function (item) {
|
||||||
|
return item?.unit?.name ?? ""
|
||||||
|
},
|
||||||
|
formatOneCategory: function (item) {
|
||||||
|
return item?.food?.supermarket_category?.name
|
||||||
|
},
|
||||||
|
formatOneCompletedAt: function (item) {
|
||||||
|
if (!item.completed_at) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return [this.$t("Completed"), "@", this.formatDate(item.completed_at)].join(" ")
|
||||||
|
},
|
||||||
|
formatOneFood: function (item) {
|
||||||
|
return item.food.name
|
||||||
|
},
|
||||||
|
formatOneDelayUntil: function (item) {
|
||||||
|
if (!item.delay_until || (item.delay_until && item.checked)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return [this.$t("DelayUntil"), "-", this.formatDate(item.delay_until)].join(" ")
|
||||||
|
},
|
||||||
|
formatOneMealPlan: function (item) {
|
||||||
|
return item?.recipe_mealplan?.name ?? ""
|
||||||
|
},
|
||||||
|
formatOneRecipe: function (item) {
|
||||||
|
return item?.recipe_mealplan?.recipe_name ?? ""
|
||||||
|
},
|
||||||
|
formatOneNote: function (item) {
|
||||||
|
if (!item) {
|
||||||
|
item = this.entries[0]
|
||||||
|
}
|
||||||
|
return [item?.recipe_mealplan?.mealplan_note, item?.ingredient_note].filter(String)
|
||||||
|
},
|
||||||
|
formatOneCreatedBy: function (item) {
|
||||||
|
return [this.$t("Added_by"), item?.created_by.username, "@", this.formatDate(item.created_at)].join(" ")
|
||||||
|
},
|
||||||
|
openRecipeCard: function (e, item) {
|
||||||
|
this.genericAPI(this.Models.RECIPE, this.Actions.FETCH, { id: item.recipe_mealplan.recipe }).then((result) => {
|
||||||
|
let recipe = result.data
|
||||||
|
recipe.steps = undefined
|
||||||
|
this.recipe = true
|
||||||
|
this.$refs.recipe_card.open(e, recipe)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
updateChecked: function (e, item) {
|
||||||
|
let update = undefined
|
||||||
|
if (!item) {
|
||||||
|
update = { entries: this.entries.map((x) => x.id), checked: !this.formatChecked }
|
||||||
|
} else {
|
||||||
|
update = { entries: [item], checked: !item.checked }
|
||||||
|
}
|
||||||
|
this.$emit("update-checkbox", update)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
formatOneCategory: function (item) {
|
|
||||||
return item?.food?.supermarket_category?.name
|
|
||||||
},
|
|
||||||
formatOneCompletedAt: function (item) {
|
|
||||||
if (!item.completed_at) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return [this.$t("Completed"), "@", this.formatDate(item.completed_at)].join(" ")
|
|
||||||
},
|
|
||||||
formatOneFood: function (item) {
|
|
||||||
return item.food.name
|
|
||||||
},
|
|
||||||
formatOneDelayUntil: function (item) {
|
|
||||||
if (!item.delay_until || (item.delay_until && item.checked)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return [this.$t("DelayUntil"), "-", this.formatDate(item.delay_until)].join(" ")
|
|
||||||
},
|
|
||||||
formatOneMealPlan: function (item) {
|
|
||||||
return item?.recipe_mealplan?.name ?? ""
|
|
||||||
},
|
|
||||||
formatOneRecipe: function (item) {
|
|
||||||
return item?.recipe_mealplan?.recipe_name ?? ""
|
|
||||||
},
|
|
||||||
formatOneNote: function (item) {
|
|
||||||
if (!item) {
|
|
||||||
item = this.entries[0]
|
|
||||||
}
|
|
||||||
return [item?.recipe_mealplan?.mealplan_note, item?.ingredient_note].filter(String)
|
|
||||||
},
|
|
||||||
formatOneCreatedBy: function (item) {
|
|
||||||
return [this.$t("Added_by"), item?.created_by.username, "@", this.formatDate(item.created_at)].join(" ")
|
|
||||||
},
|
|
||||||
openRecipeCard: function (e, item) {
|
|
||||||
this.genericAPI(this.Models.RECIPE, this.Actions.FETCH, {id: item.recipe_mealplan.recipe}).then((result) => {
|
|
||||||
let recipe = result.data
|
|
||||||
recipe.steps = undefined
|
|
||||||
this.recipe = true
|
|
||||||
this.$refs.recipe_card.open(e, recipe)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
updateChecked: function (e, item) {
|
|
||||||
let update = undefined
|
|
||||||
if (!item) {
|
|
||||||
update = {entries: this.entries.map((x) => x.id), checked: !this.formatChecked}
|
|
||||||
} else {
|
|
||||||
update = {entries: [item], checked: !item.checked}
|
|
||||||
}
|
|
||||||
this.$emit("update-checkbox", update)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -344,34 +321,34 @@ export default {
|
|||||||
/* border-bottom: 1px solid #000; /* …and with a border on the top */
|
/* border-bottom: 1px solid #000; /* …and with a border on the top */
|
||||||
/* } */
|
/* } */
|
||||||
.checkbox-control {
|
.checkbox-control {
|
||||||
font-size: 0.6rem
|
font-size: 0.6rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.checkbox-control-mobile {
|
.checkbox-control-mobile {
|
||||||
font-size: 1rem
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rotate {
|
.rotate {
|
||||||
-moz-transition: all 0.25s linear;
|
-moz-transition: all 0.25s linear;
|
||||||
-webkit-transition: all 0.25s linear;
|
-webkit-transition: all 0.25s linear;
|
||||||
transition: all 0.25s linear;
|
transition: all 0.25s linear;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rotated {
|
.rotated {
|
||||||
-moz-transform: rotate(90deg);
|
-moz-transform: rotate(90deg);
|
||||||
-webkit-transform: rotate(90deg);
|
-webkit-transform: rotate(90deg);
|
||||||
transform: rotate(90deg);
|
transform: rotate(90deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.unit-badge-lg {
|
.unit-badge-lg {
|
||||||
font-size: 1rem !important;
|
font-size: 1rem !important;
|
||||||
font-weight: 500 !important;
|
font-weight: 500 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.dropdown-spacing {
|
.dropdown-spacing {
|
||||||
padding-left: 0 !important;
|
padding-left: 0 !important;
|
||||||
padding-right: 0 !important;
|
padding-right: 0 !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Reference in New Issue
Block a user