copy to new recipe
This commit is contained in:
parent
3db55cd82b
commit
501f56ffd5
@ -31,6 +31,9 @@
|
|||||||
{{ $t("Print") }}
|
{{ $t("Print") }}
|
||||||
</button>
|
</button>
|
||||||
</a>
|
</a>
|
||||||
|
<a href="javascript:void(0);">
|
||||||
|
<button class="dropdown-item" @click="copyToNew"><i class="fas fa-copy fa-fw"></i> {{ $t("copy_to_new") }}</button>
|
||||||
|
</a>
|
||||||
|
|
||||||
<a class="dropdown-item" :href="resolveDjangoUrl('view_export') + '?r=' + recipe.id" target="_blank" rel="noopener noreferrer"><i class="fas fa-file-export fa-fw"></i> {{ $t("Export") }}</a>
|
<a class="dropdown-item" :href="resolveDjangoUrl('view_export') + '?r=' + recipe.id" target="_blank" rel="noopener noreferrer"><i class="fas fa-file-export fa-fw"></i> {{ $t("Export") }}</a>
|
||||||
|
|
||||||
@ -202,6 +205,22 @@ export default {
|
|||||||
addToShopping() {
|
addToShopping() {
|
||||||
this.$bvModal.show(`shopping_${this.modal_id}`)
|
this.$bvModal.show(`shopping_${this.modal_id}`)
|
||||||
},
|
},
|
||||||
|
copyToNew: function () {
|
||||||
|
let recipename = window.prompt(this.$t("copy_to_new"), this.$t("recipe_name"))
|
||||||
|
let apiClient = new ApiApiFactory()
|
||||||
|
apiClient.retrieveRecipe(this.recipe.id).then((results) => {
|
||||||
|
apiClient
|
||||||
|
.createRecipe({ ...results.data, ...{ id: undefined, name: recipename } })
|
||||||
|
.then((newrecipe) => {
|
||||||
|
console.log(newrecipe.data, this.resolveDjangoUrl("view_recipe", newrecipe.data.id))
|
||||||
|
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_CREATE)
|
||||||
|
window.open(this.resolveDjangoUrl("view_recipe", newrecipe.data.id))
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
StandardToasts.makeStandardToast(StandardToasts.FAIL_CREATE)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -296,5 +296,7 @@
|
|||||||
"food_recipe_help": "Linking a recipe here will include the linked recipe in any other recipe that use this food",
|
"food_recipe_help": "Linking a recipe here will include the linked recipe in any other recipe that use this food",
|
||||||
"Foods": "Foods",
|
"Foods": "Foods",
|
||||||
"review_shopping": "Review shopping entries before saving",
|
"review_shopping": "Review shopping entries before saving",
|
||||||
"view_recipe": "View Recipe"
|
"view_recipe": "View Recipe",
|
||||||
|
"copy_to_new": "Copy To New Recipe",
|
||||||
|
"recipe_name": "Recipe Name"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user