recipe edit view hotkeys and small tweaks
This commit is contained in:
parent
b151356bce
commit
1c661c9baf
@ -339,7 +339,8 @@
|
|||||||
v-bind:class="{ 'col-lg-4 col-md-6': !ingredient.is_header, 'col-lg-12 col-md-12': ingredient.is_header }">
|
v-bind:class="{ 'col-lg-4 col-md-6': !ingredient.is_header, 'col-lg-12 col-md-12': ingredient.is_header }">
|
||||||
<input class="form-control"
|
<input class="form-control"
|
||||||
v-model="ingredient.note"
|
v-model="ingredient.note"
|
||||||
v-bind:placeholder="$t('Note')">
|
v-bind:placeholder="$t('Note')"
|
||||||
|
v-on:keydown.tab="event => {if(step.ingredients.indexOf(ingredient) === (step.ingredients.length -1)){event.preventDefault();addIngredient(step)}}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -455,12 +456,12 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 col-6">
|
<div class="col-md-3 col-6">
|
||||||
<button type="button" @click="updateRecipe(false)"
|
<button type="button" @click="updateRecipe(false)" v-b-tooltip.hover :title="`${$t('Key_Ctrl')} + S`"
|
||||||
class="btn btn-sm btn-block btn-info shadow-none">{{ $t('Save') }}
|
class="btn btn-sm btn-block btn-info shadow-none">{{ $t('Save') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 col-6">
|
<div class="col-md-3 col-6">
|
||||||
<button type="button" @click="updateRecipe(true)"
|
<button type="button" @click="updateRecipe(true)" v-b-tooltip.hover :title="`${$t('Key_Ctrl')} + ${$t('Key_Shift')} + S`"
|
||||||
class="btn btn-sm btn-block btn-success shadow-none">{{ $t('Save_and_View') }}
|
class="btn btn-sm btn-block btn-success shadow-none">{{ $t('Save_and_View') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -537,28 +538,14 @@ export default {
|
|||||||
this.searchRecipes('')
|
this.searchRecipes('')
|
||||||
|
|
||||||
|
|
||||||
//TODO find out what this did and fix it
|
|
||||||
// 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));
|
|
||||||
|
|
||||||
this.$i18n.locale = window.CUSTOM_LOCALE
|
this.$i18n.locale = window.CUSTOM_LOCALE
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
window.addEventListener('keydown', this.keyboardListener);
|
||||||
window.addEventListener('beforeunload', this.warnPageLeave)
|
window.addEventListener('beforeunload', this.warnPageLeave)
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
document.removeEventListener('keydown', this._keyListener);
|
window.removeEventListener('keydown', this.keyboardListener);
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
recipe: {
|
recipe: {
|
||||||
@ -569,8 +556,25 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
test: function (event) {
|
keyboardListener: function (e) {
|
||||||
console.log(event)
|
if (e.code === "Space" && e.ctrlKey) {
|
||||||
|
e.preventDefault(); // present "Save Page" from getting triggered.
|
||||||
|
|
||||||
|
for (let 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (e.code === "KeyS" && e.ctrlKey && !e.shiftKey) {
|
||||||
|
e.preventDefault();
|
||||||
|
this.updateRecipe(false)
|
||||||
|
}
|
||||||
|
if (e.code === "KeyS" && e.ctrlKey && e.shiftKey) {
|
||||||
|
e.preventDefault();
|
||||||
|
this.updateRecipe(true)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
warnPageLeave: function (event) {
|
warnPageLeave: function (event) {
|
||||||
if (this.recipe_changed) {
|
if (this.recipe_changed) {
|
||||||
@ -674,7 +678,6 @@ export default {
|
|||||||
})
|
})
|
||||||
this.sortIngredients(step)
|
this.sortIngredients(step)
|
||||||
this.$nextTick(() => document.getElementById(`amount_${this.recipe.steps.indexOf(step)}_${step.ingredients.length - 1}`).focus())
|
this.$nextTick(() => document.getElementById(`amount_${this.recipe.steps.indexOf(step)}_${step.ingredients.length - 1}`).focus())
|
||||||
|
|
||||||
},
|
},
|
||||||
removeIngredient: function (step, ingredient) {
|
removeIngredient: function (step, ingredient) {
|
||||||
if (confirm(this.$t('confirm_delete', {object: this.$t('Ingredient')}))) {
|
if (confirm(this.$t('confirm_delete', {object: this.$t('Ingredient')}))) {
|
||||||
@ -826,7 +829,7 @@ export default {
|
|||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
textarea {
|
textarea:not(.form-control) {
|
||||||
border: 0 !important;
|
border: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,13 +9,11 @@
|
|||||||
"success_deleting_resource": "Successfully deleted a resource!",
|
"success_deleting_resource": "Successfully deleted a resource!",
|
||||||
"step_time_minutes": "Step time in minutes",
|
"step_time_minutes": "Step time in minutes",
|
||||||
"confirm_delete": "Are you sure you want to delete this {object}?",
|
"confirm_delete": "Are you sure you want to delete this {object}?",
|
||||||
|
|
||||||
"import_running": "Import running, please wait!",
|
"import_running": "Import running, please wait!",
|
||||||
"all_fields_optional": "All fields are optional and can be left empty.",
|
"all_fields_optional": "All fields are optional and can be left empty.",
|
||||||
"convert_internal": "Convert to internal recipe",
|
"convert_internal": "Convert to internal recipe",
|
||||||
"show_only_internal": "Show only internal recipes",
|
"show_only_internal": "Show only internal recipes",
|
||||||
"show_split_screen": "Split View",
|
"show_split_screen": "Split View",
|
||||||
|
|
||||||
"Log_Recipe_Cooking": "Log Recipe Cooking",
|
"Log_Recipe_Cooking": "Log Recipe Cooking",
|
||||||
"External_Recipe_Image": "External Recipe Image",
|
"External_Recipe_Image": "External Recipe Image",
|
||||||
"Add_to_Shopping": "Add to Shopping",
|
"Add_to_Shopping": "Add to Shopping",
|
||||||
@ -27,7 +25,6 @@
|
|||||||
"Hide_as_header": "Hide as header",
|
"Hide_as_header": "Hide as header",
|
||||||
"Copy_template_reference": "Copy template reference",
|
"Copy_template_reference": "Copy template reference",
|
||||||
"Save_and_View": "Save & View",
|
"Save_and_View": "Save & View",
|
||||||
|
|
||||||
"Manage_Books": "Manage Books",
|
"Manage_Books": "Manage Books",
|
||||||
"Meal_Plan": "Meal Plan",
|
"Meal_Plan": "Meal Plan",
|
||||||
"Select_Book": "Select Book",
|
"Select_Book": "Select Book",
|
||||||
@ -57,7 +54,6 @@
|
|||||||
"Enable_Amount": "Enable Amount",
|
"Enable_Amount": "Enable Amount",
|
||||||
"Disable_Amount": "Disable Amount",
|
"Disable_Amount": "Disable Amount",
|
||||||
"Add_Step": "Add Step",
|
"Add_Step": "Add Step",
|
||||||
|
|
||||||
"Keywords": "Keywords",
|
"Keywords": "Keywords",
|
||||||
"Books": "Books",
|
"Books": "Books",
|
||||||
"Proteins": "Proteins",
|
"Proteins": "Proteins",
|
||||||
@ -150,6 +146,8 @@
|
|||||||
"and_up": "& Up",
|
"and_up": "& Up",
|
||||||
"Instructions": "Instructions",
|
"Instructions": "Instructions",
|
||||||
"Unrated": "Unrated",
|
"Unrated": "Unrated",
|
||||||
|
"Key_Ctrl": "Ctrl",
|
||||||
|
"Key_Shift": "Shift",
|
||||||
"Time": "Time",
|
"Time": "Time",
|
||||||
"Text": "Text"
|
"Text": "Text"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user