added option to pass recipe to recipe view

This commit is contained in:
vabene1111 2023-07-11 17:50:48 +02:00
parent a24628c771
commit 35704c69c7

View File

@ -149,7 +149,8 @@
<div class="row text-center d-print-none" style="margin-top: 3vh; margin-bottom: 3vh"
v-if="share_uid !== 'None' && !loading">
<div class="col col-md-12">
<import-tandoor></import-tandoor> <br/>
<import-tandoor></import-tandoor>
<br/>
<a :href="resolveDjangoUrl('view_report_share_abuse', share_uid)" class="mt-3">{{ $t("Report Abuse") }}</a>
</div>
</div>
@ -236,6 +237,7 @@ export default {
},
props: {
recipe_id: Number,
recipe_obj: {type: Object, default: null},
show_context_menu: {type: Boolean, default: true},
enable_keyword_links: {type: Boolean, default: true},
show_recipe_switcher: {type: Boolean, default: true},
@ -247,7 +249,14 @@ export default {
},
},
mounted() {
if (this.recipe_obj !== null) {
this.recipe = this.rootrecipe = this.recipe_obj
this.prepareView()
} else {
this.loadRecipe(this.recipe_id)
}
this.$i18n.locale = window.CUSTOM_LOCALE
this.requestWakeLock()
window.addEventListener('resize', this.handleResize);
@ -291,8 +300,13 @@ export default {
},
loadRecipe: function (recipe_id) {
apiLoadRecipe(recipe_id).then((recipe) => {
this.recipe = this.rootrecipe = recipe
this.prepareView()
})
},
prepareView: function () {
let total_time = 0
for (let step of recipe.steps) {
for (let step of this.recipe.steps) {
for (let ingredient of step.ingredients) {
this.$set(ingredient, "checked", false)
}
@ -307,16 +321,14 @@ export default {
}
if (recipe.image === null) this.printReady()
if (this.recipe.image === null) this.printReady()
this.recipe = this.rootrecipe = recipe
this.servings = this.servings_cache[this.rootrecipe.id] = recipe.servings
this.servings = this.servings_cache[this.rootrecipe.id] = this.recipe.servings
this.loading = false
setTimeout(() => {
this.handleResize()
}, 100)
})
},
updateStartTime: function (e) {
this.start_time = e