diff --git a/cookbook/helper/recipe_url_import.py b/cookbook/helper/recipe_url_import.py index 3a39b403f..307e5f603 100644 --- a/cookbook/helper/recipe_url_import.py +++ b/cookbook/helper/recipe_url_import.py @@ -33,7 +33,7 @@ def get_from_scraper(scrape, request): except Exception: description = '' - recipe_json['description'] = parse_description(description) + recipe_json['description'] = parse_description(description)[:512] recipe_json['internal'] = True try: diff --git a/vue/src/apps/ImportView/ImportView.vue b/vue/src/apps/ImportView/ImportView.vue index c0d7b8d65..83e6bc321 100644 --- a/vue/src/apps/ImportView/ImportView.vue +++ b/vue/src/apps/ImportView/ImportView.vue @@ -11,70 +11,127 @@
-
Website
- - - - - - - + + + Website + + + + + + + + + + - Clear recent imports - + Clear recent imports + + + + -
Options
- -
-
- Images + + + Additional Options + + + -
-
- +
+
+ +
-
-
-
- Click the image you want to import for this - recipe +
+
+ Click the image you want to import for this + recipe +
+
+ +
-
- + +
+
+ + + + + {{ + k.label + }} + + + + + +
+
+ + + + {{ + k.label + }} + + + + +
-
+ Steps +
+
+ Split + + {{ s.instruction }} + + +
- Keywords -
    -
  • {{ k.label }}
  • -
- unused -
    -
  • {{ - k.label - }} -
  • -
- Steps -
    -
  • {{ s }}
  • -
-
-
+
+ + + + + + + + Import + + + + + + Import & View + Import & Edit + Import & start new import + + + + + -
Import
- Import @@ -109,6 +166,7 @@ import 'bootstrap-vue/dist/bootstrap-vue.css' import {resolveDjangoUrl, ResolveUrlMixin, StandardToasts, ToastMixin} from "@/utils/utils"; import axios from "axios"; import {ApiApiFactory} from "@/utils/openapi/api"; +import draggable from "vuedraggable"; Vue.use(BootstrapVue) @@ -118,7 +176,9 @@ export default { ResolveUrlMixin, ToastMixin, ], - components: {}, + components: { + draggable + }, data() { return { LS_IMPORT_RECENT: 'import_recent_urls', //TODO use central helper to manage all local storage keys (and maybe even access) @@ -146,9 +206,9 @@ export default { */ importRecipe: function () { let apiFactory = new ApiApiFactory() - apiFactory.createRecipe(this.recipe_json).then(response => { + apiFactory.createRecipe(this.recipe_json).then(response => { // save recipe let recipe = response.data - apiFactory.imageRecipe(response.data.id, undefined, this.recipe_json.image).then(response => { + apiFactory.imageRecipe(response.data.id, undefined, this.recipe_json.image).then(response => { // save recipe image StandardToasts.makeStandardToast(StandardToasts.SUCCESS_CREATE) window.location = resolveDjangoUrl('edit_recipe', recipe.id) }).catch(e => { @@ -209,6 +269,25 @@ export default { StandardToasts.makeStandardToast(StandardToasts.FAIL_FETCH, err.response.data.msg) }) }, + /** + * Splits the steps of a given recipe at the split character (e.g. \n or \n\n) + * @param split_character: character to split steps at + */ + splitSteps: function (split_character) { + let steps = [] + this.recipe_json.steps.forEach(step => { + step.instruction.split(split_character).forEach(part => { + steps.push({'instruction': part, 'ingredients': []}) + }) + }) + this.recipe_json.steps.forEach(step => { + if (step.ingredients.length > 0) { + console.log('found ingredients', step.ingredients) + steps[0].ingredients = steps[0].ingredients.concat(step.ingredients) + } + }) + this.recipe_json.steps = steps + }, /** * Clear list of recently imported recipe urls */