removed case insensitive get_or_create for units

This commit is contained in:
smilerz
2022-02-17 12:49:41 -06:00
parent 1c18c8faac
commit 6b5a099ba0
3 changed files with 43 additions and 28 deletions

View File

@ -207,10 +207,24 @@ export default {
},
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) => {
let recipe = { ...results.data, ...{ id: undefined, name: recipename } }
recipe.steps = recipe.steps.map((step) => {
return {
...step,
...{
id: undefined,
ingredients: step.ingredients.map((ingredient) => {
return { ...ingredient, ...{ id: undefined } }
}),
},
}
})
console.log(recipe)
apiClient
.createRecipe({ ...results.data, ...{ id: undefined, name: recipename } })
.createRecipe(recipe)
.then((newrecipe) => {
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_CREATE)
window.open(this.resolveDjangoUrl("view_recipe", newrecipe.data.id))