mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-04 21:58:54 -05:00
Merge branch 'additional_fixes' into feature/custom_filters
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
<!-- add to shopping form -->
|
||||
|
||||
<b-row class="justify-content-md-center align-items-center pl-1 pr-1" v-if="entrymode">
|
||||
<b-col cols="12" md="3" v-if="!entry_mode_simple" class="d-none d-md-block mt-1">
|
||||
<b-col cols="12" md="3" v-if="!ui.entry_mode_simple" class="d-none d-md-block mt-1">
|
||||
<b-form-input
|
||||
size="lg"
|
||||
min="1"
|
||||
@@ -46,13 +46,13 @@
|
||||
style="font-size: 16px; border-radius: 5px !important; border: 1px solid #e8e8e8 !important"
|
||||
></b-form-input>
|
||||
</b-col>
|
||||
<b-col cols="12" md="4" v-if="!entry_mode_simple" class="mt-1">
|
||||
<b-col cols="12" md="4" v-if="!ui.entry_mode_simple" class="mt-1">
|
||||
<lookup-input :class_list="'mb-0'" :form="formUnit" :model="Models.UNIT" @change="new_item.unit = $event" :show_label="false" :clear="clear" />
|
||||
</b-col>
|
||||
<b-col cols="12" md="4" v-if="!entry_mode_simple" class="mt-1">
|
||||
<b-col cols="12" md="4" v-if="!ui.entry_mode_simple" class="mt-1">
|
||||
<lookup-input :class_list="'mb-0'" :form="formFood" :model="Models.FOOD" @change="new_item.food = $event" :show_label="false" :clear="clear" />
|
||||
</b-col>
|
||||
<b-col cols="12" md="11" v-if="entry_mode_simple" class="mt-1">
|
||||
<b-col cols="12" md="11" v-if="ui.entry_mode_simple" class="mt-1">
|
||||
<b-form-input size="lg" type="text" :placeholder="$t('QuickEntry')" v-model="new_item.ingredient" @keyup.enter="addItem"></b-form-input>
|
||||
</b-col>
|
||||
<b-col cols="12" md="1" class="d-none d-md-block mt-1">
|
||||
@@ -60,7 +60,7 @@
|
||||
<i class="btn fas fa-cart-plus fa-lg px-0 text-success" @click="addItem" />
|
||||
</b-button>
|
||||
</b-col>
|
||||
<b-col cols="12" md="3" v-if="!entry_mode_simple" class="d-block d-md-none mt-1">
|
||||
<b-col cols="12" md="3" v-if="!ui.entry_mode_simple" class="d-block d-md-none mt-1">
|
||||
<b-row>
|
||||
<b-col cols="9">
|
||||
<b-form-input
|
||||
@@ -82,10 +82,10 @@
|
||||
</b-row>
|
||||
|
||||
<b-row class="row justify-content-around mt-2" v-if="entrymode">
|
||||
<b-form-checkbox switch v-model="entry_mode_simple">
|
||||
<b-form-checkbox switch v-model="ui.entry_mode_simple">
|
||||
{{ $t("QuickEntry") }}
|
||||
</b-form-checkbox>
|
||||
<b-button variant="success" size="sm" class="d-flex d-md-none p-0" v-if="entry_mode_simple">
|
||||
<b-button variant="success" size="sm" class="d-flex d-md-none p-0" v-if="ui.entry_mode_simple">
|
||||
<i class="btn fas fa-cart-plus" @click="addItem" />
|
||||
</b-button>
|
||||
</b-row>
|
||||
@@ -156,9 +156,6 @@
|
||||
<b-input-group-prepend is-text>
|
||||
<input type="number" :min="1" v-model="add_recipe_servings" style="width: 3em" />
|
||||
</b-input-group-prepend>
|
||||
<!-- <b-input-group-prepend is-text>
|
||||
<b>{{ $t("Recipe") }}</b>
|
||||
</b-input-group-prepend> -->
|
||||
<generic-multiselect
|
||||
class="input-group-text m-0 p-0"
|
||||
@change="new_recipe = $event.val"
|
||||
@@ -589,16 +586,16 @@
|
||||
<b-form-select v-model="group_by" :options="group_by_choices" size="sm"></b-form-select>
|
||||
</b-form-group>
|
||||
<b-form-group v-bind:label="$t('Supermarket')" label-for="popover-input-2" label-cols="6" class="mb-1">
|
||||
<b-form-select v-model="selected_supermarket" :options="supermarkets" text-field="name" value-field="id" size="sm"></b-form-select>
|
||||
<b-form-select v-model="ui.selected_supermarket" :options="supermarkets" text-field="name" value-field="id" size="sm"></b-form-select>
|
||||
</b-form-group>
|
||||
<!-- TODO: shade filters red when they are actually filtering content -->
|
||||
<b-form-group v-bind:label="$t('ShowDelayed')" label-for="popover-input-3" content-cols="1" class="mb-1">
|
||||
<b-form-checkbox v-model="show_delay"></b-form-checkbox>
|
||||
</b-form-group>
|
||||
<b-form-group v-bind:label="$t('ShowUncategorizedFood')" label-for="popover-input-4" content-cols="1" class="mb-1" v-if="!selected_supermarket">
|
||||
<b-form-group v-bind:label="$t('ShowUncategorizedFood')" label-for="popover-input-4" content-cols="1" class="mb-1" v-if="!ui.selected_supermarket">
|
||||
<b-form-checkbox v-model="show_undefined_categories"></b-form-checkbox>
|
||||
</b-form-group>
|
||||
<b-form-group v-bind:label="$t('SupermarketCategoriesOnly')" label-for="popover-input-5" content-cols="1" class="mb-1" v-if="selected_supermarket">
|
||||
<b-form-group v-bind:label="$t('SupermarketCategoriesOnly')" label-for="popover-input-5" content-cols="1" class="mb-1" v-if="ui.selected_supermarket">
|
||||
<b-form-checkbox v-model="supermarket_categories_only"></b-form-checkbox>
|
||||
</b-form-group>
|
||||
</div>
|
||||
@@ -718,13 +715,15 @@ export default {
|
||||
group_by_choices: ["created_by", "category", "recipe"],
|
||||
supermarkets: [],
|
||||
shopping_categories: [],
|
||||
selected_supermarket: undefined,
|
||||
show_undefined_categories: true,
|
||||
supermarket_categories_only: false,
|
||||
shopcat: null,
|
||||
delay: 0,
|
||||
clear: Math.random(),
|
||||
entry_mode_simple: false,
|
||||
ui: {
|
||||
entry_mode_simple: false,
|
||||
selected_supermarket: undefined,
|
||||
},
|
||||
settings: {
|
||||
shopping_auto_sync: 0,
|
||||
default_delay: 4,
|
||||
@@ -773,14 +772,15 @@ export default {
|
||||
let shopping_list = this.items
|
||||
|
||||
// filter out list items that are delayed
|
||||
|
||||
if (!this.show_delay && shopping_list) {
|
||||
shopping_list = shopping_list.filter((x) => !x.delay_until || !Date.parse(x?.delay_until) < new Date(Date.now()))
|
||||
shopping_list = shopping_list.filter((x) => !x.delay_until || Date.parse(x?.delay_until) < new Date(Date.now()))
|
||||
}
|
||||
|
||||
// if a supermarket is selected and filtered to only supermarket categories filter out everything else
|
||||
if (this.selected_supermarket && this.supermarket_categories_only) {
|
||||
if (this.ui.selected_supermarket && this.supermarket_categories_only) {
|
||||
let shopping_categories = this.supermarkets // category IDs configured on supermarket
|
||||
.filter((x) => x.id === this.selected_supermarket)
|
||||
.filter((x) => x.id === this.ui.selected_supermarket)
|
||||
.map((x) => x.category_to_supermarket)
|
||||
.flat()
|
||||
.map((x) => x.category.id)
|
||||
@@ -791,12 +791,12 @@ export default {
|
||||
}
|
||||
|
||||
var groups = { false: {}, true: {} } // force unchecked to always be first
|
||||
if (this.selected_supermarket) {
|
||||
if (this.ui.selected_supermarket) {
|
||||
// TODO: make nulls_first a user setting
|
||||
groups.false[this.$t("Undefined")] = {}
|
||||
groups.true[this.$t("Undefined")] = {}
|
||||
let super_cats = this.supermarkets
|
||||
.filter((x) => x.id === this.selected_supermarket)
|
||||
.filter((x) => x.id === this.ui.selected_supermarket)
|
||||
.map((x) => x.category_to_supermarket)
|
||||
.flat()
|
||||
.map((x) => x.category.name)
|
||||
@@ -850,7 +850,7 @@ export default {
|
||||
return this.items.filter((x) => !x.delay_until || !Date.parse(x?.delay_until) > new Date(Date.now())).length < this.items.length
|
||||
},
|
||||
filterApplied() {
|
||||
return (this.itemsDelayed && !this.show_delay) || !this.show_undefined_categories || (this.supermarket_categories_only && this.selected_supermarket)
|
||||
return (this.itemsDelayed && !this.show_delay) || !this.show_undefined_categories || (this.supermarket_categories_only && this.ui.selected_supermarket)
|
||||
},
|
||||
Recipes() {
|
||||
// hiding recipes associated with shopping list items that are complete
|
||||
@@ -876,10 +876,13 @@ export default {
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
selected_supermarket(newVal, oldVal) {
|
||||
this.supermarket_categories_only = this.settings.filter_to_supermarket
|
||||
localStorage.setItem("shopping_v2_selected_supermarket", JSON.stringify(this.selected_supermarket))
|
||||
ui: {
|
||||
handler() {
|
||||
this.$cookies.set(SETTINGS_COOKIE_NAME, this.ui)
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
|
||||
new_recipe: {
|
||||
handler() {
|
||||
this.add_recipe_servings = this.new_recipe.servings
|
||||
@@ -910,8 +913,8 @@ export default {
|
||||
"settings.default_delay": function (newVal, oldVal) {
|
||||
this.delay = Number(newVal)
|
||||
},
|
||||
entry_mode_simple(newVal) {
|
||||
this.$cookies.set(SETTINGS_COOKIE_NAME, newVal)
|
||||
"ui.selected_supermarket": function (newVal, oldVal) {
|
||||
this.supermarket_categories_only = this.settings.filter_to_supermarket
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
@@ -928,15 +931,14 @@ export default {
|
||||
}
|
||||
this.$nextTick(function () {
|
||||
if (this.$cookies.isKey(SETTINGS_COOKIE_NAME)) {
|
||||
this.entry_mode_simple = this.$cookies.get(SETTINGS_COOKIE_NAME)
|
||||
this.ui = Object.assign({}, this.ui, this.$cookies.get(SETTINGS_COOKIE_NAME))
|
||||
}
|
||||
this.selected_supermarket = localStorage.getItem("shopping_v2_selected_supermarket") || undefined
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
// this.genericAPI inherited from ApiMixin
|
||||
addItem: function () {
|
||||
if (this.entry_mode_simple) {
|
||||
if (this.ui.entry_mode_simple) {
|
||||
if (this.new_item.ingredient !== "" && this.new_item.ingredient !== undefined) {
|
||||
this.genericPostAPI("api_ingredient_from_string", { text: this.new_item.ingredient }).then((result) => {
|
||||
let unit = null
|
||||
@@ -1003,7 +1005,7 @@ export default {
|
||||
})
|
||||
},
|
||||
resetFilters: function () {
|
||||
this.selected_supermarket = undefined
|
||||
this.ui.selected_supermarket = undefined
|
||||
this.supermarket_categories_only = this.settings.filter_to_supermarket
|
||||
this.show_undefined_categories = true
|
||||
this.group_by = "category"
|
||||
@@ -1090,7 +1092,7 @@ export default {
|
||||
},
|
||||
getShoppingList: function (autosync = false) {
|
||||
let params = {}
|
||||
params.supermarket = this.selected_supermarket
|
||||
params.supermarket = this.ui.selected_supermarket
|
||||
|
||||
params.options = { query: { recent: 1 } }
|
||||
if (autosync) {
|
||||
|
||||
Reference in New Issue
Block a user