recipe view enhancements
This commit is contained in:
@ -22,10 +22,10 @@ def search_recipes(request, queryset, params):
|
|||||||
search_last_viewed = int(params.get('last_viewed', 0))
|
search_last_viewed = int(params.get('last_viewed', 0))
|
||||||
|
|
||||||
if search_last_viewed > 0:
|
if search_last_viewed > 0:
|
||||||
last_viewed_recipes = ViewLog.objects.filter(created_by=request.user, space=request.space).order_by(
|
last_viewed_recipes = ViewLog.objects.filter(created_by=request.user, space=request.space).values_list('recipe__pk', flat=True).distinct()
|
||||||
'-created_at').values('recipe').distinct().all()[:search_last_viewed]
|
# TODO filter by created by in last two weeks and re add limit to recipe selection (after reversing the order)
|
||||||
|
# Distinct does not work with order by
|
||||||
return queryset.filter(pk__in=last_viewed_recipes)
|
return queryset.filter(pk__in=list(set(last_viewed_recipes)))
|
||||||
|
|
||||||
if settings.DATABASES['default']['ENGINE'] in ['django.db.backends.postgresql_psycopg2',
|
if settings.DATABASES['default']['ENGINE'] in ['django.db.backends.postgresql_psycopg2',
|
||||||
'django.db.backends.postgresql']:
|
'django.db.backends.postgresql']:
|
||||||
|
@ -51,8 +51,46 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<button id="id_settings_button" class="btn btn-primary"><i class="fas fa-cog"></i></button>
|
||||||
|
<b-popover
|
||||||
|
target="id_settings_button"
|
||||||
|
triggers="click"
|
||||||
|
placement="bottom"
|
||||||
|
:title="$t('Settings')">
|
||||||
|
<div>
|
||||||
|
<b-form-group
|
||||||
|
v-bind:label="$t('Recently_Viewed')"
|
||||||
|
label-for="popover-input-1"
|
||||||
|
label-cols="3"
|
||||||
|
class="mb-1">
|
||||||
|
<b-form-input
|
||||||
|
type="number"
|
||||||
|
v-model="settings.recently_viewed"
|
||||||
|
id="popover-input-1"
|
||||||
|
size="sm"
|
||||||
|
></b-form-input>
|
||||||
|
</b-form-group>
|
||||||
|
<b-form-group
|
||||||
|
v-bind:label="$t('Meal_Plan')"
|
||||||
|
label-for="popover-input-2"
|
||||||
|
label-cols="3"
|
||||||
|
class="mb-1">
|
||||||
|
<b-form-checkbox
|
||||||
|
switch
|
||||||
|
v-model="settings.show_meal_plan"
|
||||||
|
id="popover-input-2"
|
||||||
|
size="sm"
|
||||||
|
></b-form-checkbox>
|
||||||
|
</b-form-group>
|
||||||
|
</div>
|
||||||
|
<div class="row" style="margin-top: 1vh">
|
||||||
|
<div class="col-12" style="text-align: right">
|
||||||
|
<b-button size="sm" variant="secondary" style="margin-right:8px">Cancel
|
||||||
|
</b-button>
|
||||||
|
<b-button size="sm" variant="primary">Ok</b-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</b-popover>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@ -224,23 +262,33 @@ export default {
|
|||||||
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.$cookies.isKey('search_settings')) {
|
this.$nextTick(function () {
|
||||||
console.log('loaded cookie settings')
|
if (this.$cookies.isKey('search_settings')) {
|
||||||
this.settings = this.$cookies.get("search_settings")
|
console.log('loaded cookie settings', this.$cookies.get("search_settings"))
|
||||||
}
|
this.settings = this.$cookies.get("search_settings")
|
||||||
|
}
|
||||||
|
|
||||||
|
this.loadMealPlan()
|
||||||
|
this.loadRecentlyViewed()
|
||||||
|
})
|
||||||
|
|
||||||
this.refreshData()
|
this.refreshData()
|
||||||
|
|
||||||
this.loadSpecialData()
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
settings: {
|
settings: {
|
||||||
handler(val) {
|
handler() {
|
||||||
console.log('saved cookie settings', val)
|
|
||||||
this.$cookies.set("search_settings", this.settings, -1)
|
this.$cookies.set("search_settings", this.settings, -1)
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
}
|
},
|
||||||
|
'settings.show_meal_plan': function () {
|
||||||
|
console.log('Test')
|
||||||
|
this.loadMealPlan()
|
||||||
|
},
|
||||||
|
'settings.recently_viewed': function () {
|
||||||
|
console.log('RV')
|
||||||
|
this.loadRecentlyViewed()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
refreshData: function () {
|
refreshData: function () {
|
||||||
@ -271,21 +319,33 @@ export default {
|
|||||||
this.pagination_count = result.data.count
|
this.pagination_count = result.data.count
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
loadSpecialData: function () {
|
loadMealPlan: function () {
|
||||||
let apiClient = new ApiApiFactory()
|
let apiClient = new ApiApiFactory()
|
||||||
|
|
||||||
apiClient.listMealPlans({
|
if (this.settings.show_meal_plan) {
|
||||||
query: {
|
apiClient.listMealPlans({
|
||||||
from_date: moment().format('YYYY-MM-DD'),
|
query: {
|
||||||
to_date: moment().format('YYYY-MM-DD')
|
from_date: moment().format('YYYY-MM-DD'),
|
||||||
}
|
to_date: moment().format('YYYY-MM-DD')
|
||||||
}).then(result => {
|
}
|
||||||
this.meal_plans = result.data
|
}).then(result => {
|
||||||
})
|
this.meal_plans = result.data
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.meal_plans = []
|
||||||
|
}
|
||||||
|
|
||||||
apiClient.listRecipes({query: {last_viewed: 5}}).then(result => {
|
|
||||||
this.last_viewed_recipes = result.data.results
|
},
|
||||||
})
|
loadRecentlyViewed: function () {
|
||||||
|
let apiClient = new ApiApiFactory()
|
||||||
|
if (this.settings.recently_viewed > 0) {
|
||||||
|
apiClient.listRecipes({query: {last_viewed: this.settings.recently_viewed}}).then(result => {
|
||||||
|
this.last_viewed_recipes = result.data.results
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.last_viewed_recipes = []
|
||||||
|
}
|
||||||
},
|
},
|
||||||
genericSelectChanged: function (obj) {
|
genericSelectChanged: function (obj) {
|
||||||
this[obj.var] = obj.val
|
this[obj.var] = obj.val
|
||||||
|
@ -3,12 +3,17 @@
|
|||||||
"all_fields_optional": "All fields are optional and can be left empty.",
|
"all_fields_optional": "All fields are optional and can be left empty.",
|
||||||
"convert_internal": "Convert to internal recipe",
|
"convert_internal": "Convert to internal recipe",
|
||||||
"show_only_internal": "Show only internal recipes",
|
"show_only_internal": "Show only internal recipes",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Log_Recipe_Cooking": "Log Recipe Cooking",
|
"Log_Recipe_Cooking": "Log Recipe Cooking",
|
||||||
"External_Recipe_Image": "External Recipe Image",
|
"External_Recipe_Image": "External Recipe Image",
|
||||||
"Add_to_Book": "Add to Book",
|
"Add_to_Book": "Add to Book",
|
||||||
"Add_to_Shopping": "Add to Shopping",
|
"Add_to_Shopping": "Add to Shopping",
|
||||||
"Add_to_Plan": "Add to Plan",
|
"Add_to_Plan": "Add to Plan",
|
||||||
"Step_start_time": "Step start time",
|
"Step_start_time": "Step start time",
|
||||||
|
|
||||||
|
"Meal_Plan": "Meal Plan",
|
||||||
"Select_Book": "Select Book",
|
"Select_Book": "Select Book",
|
||||||
"Recipe_Image": "Recipe Image",
|
"Recipe_Image": "Recipe Image",
|
||||||
"Import_finished": "Import finished",
|
"Import_finished": "Import finished",
|
||||||
@ -18,6 +23,7 @@
|
|||||||
"Url_Import": "Url Import",
|
"Url_Import": "Url Import",
|
||||||
"Reset_Search": "Reset Search",
|
"Reset_Search": "Reset Search",
|
||||||
"Recently_Viewed": "Recently Viewed",
|
"Recently_Viewed": "Recently Viewed",
|
||||||
|
|
||||||
"Keywords": "Keywords",
|
"Keywords": "Keywords",
|
||||||
"Books": "Books",
|
"Books": "Books",
|
||||||
"Proteins": "Proteins",
|
"Proteins": "Proteins",
|
||||||
|
@ -1 +1 @@
|
|||||||
{"status":"done","chunks":{"recipe_search_view":["js/chunk-vendors.js","js/recipe_search_view.js","recipe_search_view.84ec50602e1246c3fe35.hot-update.js"],"recipe_view":["js/chunk-vendors.js","js/recipe_view.js"],"offline_view":["js/chunk-vendors.js","js/offline_view.js"],"import_response_view":["js/chunk-vendors.js","js/import_response_view.js"]},"publicPath":"http://localhost:8080/","assets":{"js/chunk-vendors.js":{"name":"js/chunk-vendors.js","path":"js\\chunk-vendors.js","publicPath":"http://localhost:8080/js/chunk-vendors.js"},"js/import_response_view.js":{"name":"js/import_response_view.js","path":"js\\import_response_view.js","publicPath":"http://localhost:8080/js/import_response_view.js"},"js/offline_view.js":{"name":"js/offline_view.js","path":"js\\offline_view.js","publicPath":"http://localhost:8080/js/offline_view.js"},"js/recipe_search_view.js":{"name":"js/recipe_search_view.js","path":"js\\recipe_search_view.js","publicPath":"http://localhost:8080/js/recipe_search_view.js"},"js/recipe_view.js":{"name":"js/recipe_view.js","path":"js\\recipe_view.js","publicPath":"http://localhost:8080/js/recipe_view.js"},"recipe_search_view.84ec50602e1246c3fe35.hot-update.js":{"name":"recipe_search_view.84ec50602e1246c3fe35.hot-update.js","path":"recipe_search_view.84ec50602e1246c3fe35.hot-update.js","publicPath":"http://localhost:8080/recipe_search_view.84ec50602e1246c3fe35.hot-update.js"},"84ec50602e1246c3fe35.hot-update.json":{"name":"84ec50602e1246c3fe35.hot-update.json","path":"84ec50602e1246c3fe35.hot-update.json","publicPath":"http://localhost:8080/84ec50602e1246c3fe35.hot-update.json"},"recipe_search_view.html":{"name":"recipe_search_view.html","path":"recipe_search_view.html","publicPath":"http://localhost:8080/recipe_search_view.html"},"recipe_view.html":{"name":"recipe_view.html","path":"recipe_view.html","publicPath":"http://localhost:8080/recipe_view.html"},"offline_view.html":{"name":"offline_view.html","path":"offline_view.html","publicPath":"http://localhost:8080/offline_view.html"},"import_response_view.html":{"name":"import_response_view.html","path":"import_response_view.html","publicPath":"http://localhost:8080/import_response_view.html"},"manifest.json":{"name":"manifest.json","path":"manifest.json","publicPath":"http://localhost:8080/manifest.json"}}}
|
{"status":"done","chunks":{"recipe_search_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/recipe_search_view.js"],"recipe_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/recipe_view.js"],"offline_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/offline_view.js"],"import_response_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/import_response_view.js"]},"assets":{"../../templates/sw.js":{"name":"../../templates/sw.js","path":"..\\..\\templates\\sw.js"},"css/chunk-vendors.css":{"name":"css/chunk-vendors.css","path":"css\\chunk-vendors.css"},"js/chunk-vendors.js":{"name":"js/chunk-vendors.js","path":"js\\chunk-vendors.js"},"js/import_response_view.js":{"name":"js/import_response_view.js","path":"js\\import_response_view.js"},"js/offline_view.js":{"name":"js/offline_view.js","path":"js\\offline_view.js"},"js/recipe_search_view.js":{"name":"js/recipe_search_view.js","path":"js\\recipe_search_view.js"},"js/recipe_view.js":{"name":"js/recipe_view.js","path":"js\\recipe_view.js"},"recipe_search_view.html":{"name":"recipe_search_view.html","path":"recipe_search_view.html"},"recipe_view.html":{"name":"recipe_view.html","path":"recipe_view.html"},"offline_view.html":{"name":"offline_view.html","path":"offline_view.html"},"import_response_view.html":{"name":"import_response_view.html","path":"import_response_view.html"},"manifest.json":{"name":"manifest.json","path":"manifest.json"}}}
|
Reference in New Issue
Block a user