@@ -429,17 +463,18 @@ import GenericMultiselect from "@/components/GenericMultiselect"
import { Treeselect, LOAD_CHILDREN_OPTIONS } from "@riophae/vue-treeselect"
import "@riophae/vue-treeselect/dist/vue-treeselect.css"
import RecipeSwitcher from "@/components/Buttons/RecipeSwitcher"
+import Multiselect from "vue-multiselect"
Vue.use(VueCookies)
Vue.use(BootstrapVue)
-let SEARCH_COOKIE_NAME = "search_settings1"
+let SEARCH_COOKIE_NAME = "search_settings2"
let UI_COOKIE_NAME = "ui_search_settings"
export default {
name: "RecipeSearchView",
mixins: [ResolveUrlMixin, ApiMixin, ToastMixin],
- components: { GenericMultiselect, RecipeCard, Treeselect, RecipeSwitcher },
+ components: { GenericMultiselect, RecipeCard, Treeselect, RecipeSwitcher, Multiselect },
data() {
return {
// this.Models and this.Actions inherited from ApiMixin
@@ -474,6 +509,8 @@ export default {
search_rating: undefined,
search_rating_gte: true,
search_units_or: true,
+ search_filter: undefined,
+ sort_order: [],
pagination_page: 1,
expert_mode: false,
keywords_fields: 1,
@@ -499,11 +536,11 @@ export default {
show_rating: true,
show_units: false,
show_filters: false,
+ show_sortby: false,
},
pagination_count: 0,
random_search: false,
debug: false,
- custom_filters: [],
}
},
computed: {
@@ -565,6 +602,35 @@ export default {
unitFields: function () {
return !this.expertMode ? 1 : this.search.units_fields
},
+ sortOptions: function () {
+ let sort_order = []
+ let x = 1
+ const field = [
+ [this.$t("search_rank"), "score"],
+ [this.$t("Name"), "name"],
+ [this.$t("date_cooked"), "lastcooked"],
+ [this.$t("Rating"), "rating"],
+ [this.$t("times_cooked"), "favorite"],
+ [this.$t("date_created"), "created_at"],
+ [this.$t("date_viewed"), "lastviewed"],
+ ]
+ field.forEach((f) => {
+ sort_order.push(
+ {
+ id: x,
+ text: `${f[0]} ↑`,
+ value: f[1],
+ },
+ {
+ id: x + 1,
+ text: `${f[0]} ↓`,
+ value: `-${f[1]}`,
+ }
+ )
+ x = x + 2
+ })
+ return sort_order
+ },
},
mounted() {
this.$nextTick(function () {
@@ -572,7 +638,7 @@ export default {
this.ui = Object.assign({}, this.ui, this.$cookies.get(UI_COOKIE_NAME))
}
if (this.ui.remember_search && this.$cookies.isKey(SEARCH_COOKIE_NAME)) {
- this.search = Object.assign({}, this.search, this.$cookies.get(SEARCH_COOKIE_NAME), `${this.ui.remember_hours}h`)
+ this.search = Object.assign({}, this.search, this.$cookies.get(SEARCH_COOKIE_NAME))
}
let urlParams = new URLSearchParams(window.location.search)
@@ -644,8 +710,8 @@ export default {
this.refreshData(false)
},
"ui.tree_select": function () {
- if (this.ui.tree_select && (!this.facets?.Keywords || !this.facets?.Foods)) {
- this.getFacets(this.facets?.hash)
+ if (this.ui.tree_select && (this.facets?.Keywords.length == 0 || this.facets?.Foods.length == 0) && this.facets?.cache_key) {
+ this.getFacets(this.facets?.cache_key)
}
},
"search.search_input": _debounce(function () {
@@ -656,6 +722,10 @@ export default {
"ui.page_size": _debounce(function () {
this.refreshData(false)
}, 300),
+ "search.search_filter": _debounce(function () {
+ // TODO clear existing filters
+ this.refreshData(false)
+ }, 300),
},
methods: {
// this.genericAPI inherited from ApiMixin
@@ -728,6 +798,8 @@ export default {
})
this.search.search_units = []
this.search.search_rating = undefined
+ this.search.search_filter = undefined
+ this.search.sort_order = undefined
this.search.pagination_page = 1
this.search.keywords_fields = 1
this.search.foods_fields = 1
@@ -792,6 +864,9 @@ export default {
}
},
buildParams: function (random) {
+ if (this.search.search_filter) {
+ return JSON.parse(this.search.search_filter.search)
+ }
this.random_search = random
let rating = this.search.search_rating
if (rating !== undefined && !this.search.search_rating_gte) {
@@ -811,9 +886,13 @@ export default {
page: this.search.pagination_page,
pageSize: this.ui.page_size,
}
+
+ let query = { sort_order: this.search.sort_order.map((x) => x.value) }
if (this.searchFiltered()) {
- params.options = { query: { last_viewed: this.ui.recently_viewed } }
+ query.last_viewed = this.ui.recently_viewed
}
+ params.options = { query: query }
+ console.log(params)
return params
},
searchFiltered: function (ignore_string = false) {
@@ -865,7 +944,6 @@ export default {
this.genericAPI(this.Models.CUSTOM_FILTER, this.Actions.CREATE, params)
.then((result) => {
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_CREATE)
- console.log("you saved: ", filtername, this.buildParams(false), result)
})
.catch((err) => {
console.log(err, Object.keys(err))
diff --git a/vue/src/components/Buttons/RecipeSwitcher.vue b/vue/src/components/Buttons/RecipeSwitcher.vue
index b6d8daf2..57a233c6 100644
--- a/vue/src/components/Buttons/RecipeSwitcher.vue
+++ b/vue/src/components/Buttons/RecipeSwitcher.vue
@@ -1,22 +1,25 @@
-
+
-
+
-
-
Planned
@@ -49,21 +56,24 @@
You have no pinned recipes!
-
Related
-
-
-
@@ -76,14 +86,14 @@
diff --git a/vue/src/components/Modals/ShoppingModal.vue b/vue/src/components/Modals/ShoppingModal.vue
index e2d29300..57256764 100644
--- a/vue/src/components/Modals/ShoppingModal.vue
+++ b/vue/src/components/Modals/ShoppingModal.vue
@@ -97,6 +97,7 @@ export default {
}
},
mounted() {
+ console.log("shopping modal")
this.recipe_servings = this.servings
},
computed: {
diff --git a/vue/src/components/RecipeContextMenu.vue b/vue/src/components/RecipeContextMenu.vue
index 1bd7531e..48d52069 100644
--- a/vue/src/components/RecipeContextMenu.vue
+++ b/vue/src/components/RecipeContextMenu.vue
@@ -100,7 +100,7 @@ export default {
return {
servings_value: 0,
recipe_share_link: undefined,
- modal_id: this.recipe.id + Math.round(Math.random() * 100000),
+ modal_id: undefined,
options: {
entryEditing: {
date: null,
@@ -200,6 +200,7 @@ export default {
navigator.share(shareData)
},
addToShopping() {
+ this.modal_id = this.recipe.id + Math.round(Math.random() * 100000)
this.$bvModal.show(`shopping_${this.modal_id}`)
},
},
diff --git a/vue/src/locales/en.json b/vue/src/locales/en.json
index b8e29701..eda97ba9 100644
--- a/vue/src/locales/en.json
+++ b/vue/src/locales/en.json
@@ -315,5 +315,14 @@
"left_handed": "Left-handed mode",
"left_handed_help": "Will optimize the UI for use with your left hand.",
"Custom Filter": "Custom Filter",
- "shared_with": "Shared With"
+ "shared_with": "Shared With",
+ "sort_by": "Sort By",
+ "asc": "Ascending",
+ "desc": "Descending",
+ "date_viewed": "Last Viewed",
+ "date_cooked": "Last Cooked",
+ "times_cooked": "Times Cooked",
+ "date_created": "Date Created",
+ "show_sortby": "Show Sort By",
+ "search_rank": "Search Rank"
}