From 5b7ec376374ec0cd7ccd15a874cd0304e61d9eca Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Mon, 13 Jul 2020 22:55:09 +0200 Subject: [PATCH] hotkeys, styling, step improvements --- .../templates/forms/edit_internal_recipe.html | 30 ++++++++++++++++--- cookbook/templates/recipe_view.html | 6 +++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/cookbook/templates/forms/edit_internal_recipe.html b/cookbook/templates/forms/edit_internal_recipe.html index 82fe8d84c..6685e665f 100644 --- a/cookbook/templates/forms/edit_internal_recipe.html +++ b/cookbook/templates/forms/edit_internal_recipe.html @@ -87,7 +87,7 @@
-
+

@@ -193,12 +193,14 @@ + v-if="!ingredient.no_amount" + :id="`amount_${step_index}_${index}`">

- + {% trans 'You can use markdown to format this field. See the docs here' %}
@@ -447,6 +449,24 @@ this.searchUnits('') this.searchFoods('') this.searchKeywords('') + + this._keyListener = function (e) { + if (e.code === "Space" && e.ctrlKey) { + e.preventDefault(); // present "Save Page" from getting triggered. + + for (el of e.path) { + if(el.id !== undefined && el.id.includes('id_card_step_')) { + let step = this.recipe.steps[el.id.replace('id_card_step_','')] + this.addIngredient(step) + } + } + } + }; + + document.addEventListener('keydown', this._keyListener.bind(this)); + }, + beforeDestroy() { + document.removeEventListener('keydown', this._keyListener); }, methods: { makeToast: function (title, message, variant = null) { @@ -543,6 +563,8 @@ 'no_amount': false }) this.sortIngredients(step) + this.$nextTick(() => document.getElementById(`amount_${this.recipe.steps.indexOf(step)}_${step.ingredients.length - 1}`).focus()) + }, removeIngredient: function (step, ingredient) { if (confirm('{% trans 'Are you sure that you want to delete this ingredient?' %}')) { diff --git a/cookbook/templates/recipe_view.html b/cookbook/templates/recipe_view.html index 9e53b12dd..9211051fa 100644 --- a/cookbook/templates/recipe_view.html +++ b/cookbook/templates/recipe_view.html @@ -107,7 +107,7 @@
-
+
@@ -216,6 +216,10 @@ {% endif %}
+
+

{% trans 'Instructions' %}

+
+
{% for s in recipe.steps.all %}