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 }">
|
||||
<input class="form-control"
|
||||
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>
|
||||
|
||||
@ -455,12 +456,12 @@
|
||||
</a>
|
||||
</div>
|
||||
<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') }}
|
||||
</button>
|
||||
</div>
|
||||
<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') }}
|
||||
</button>
|
||||
</div>
|
||||
@ -537,28 +538,14 @@ export default {
|
||||
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
|
||||
},
|
||||
created() {
|
||||
window.addEventListener('keydown', this.keyboardListener);
|
||||
window.addEventListener('beforeunload', this.warnPageLeave)
|
||||
},
|
||||
beforeUnmount() {
|
||||
document.removeEventListener('keydown', this._keyListener);
|
||||
window.removeEventListener('keydown', this.keyboardListener);
|
||||
},
|
||||
watch: {
|
||||
recipe: {
|
||||
@ -569,8 +556,25 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
test: function (event) {
|
||||
console.log(event)
|
||||
keyboardListener: function (e) {
|
||||
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) {
|
||||
if (this.recipe_changed) {
|
||||
@ -674,7 +678,6 @@ export default {
|
||||
})
|
||||
this.sortIngredients(step)
|
||||
this.$nextTick(() => document.getElementById(`amount_${this.recipe.steps.indexOf(step)}_${step.ingredients.length - 1}`).focus())
|
||||
|
||||
},
|
||||
removeIngredient: function (step, ingredient) {
|
||||
if (confirm(this.$t('confirm_delete', {object: this.$t('Ingredient')}))) {
|
||||
@ -826,7 +829,7 @@ export default {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
textarea:not(.form-control) {
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
|
@ -9,13 +9,11 @@
|
||||
"success_deleting_resource": "Successfully deleted a resource!",
|
||||
"step_time_minutes": "Step time in minutes",
|
||||
"confirm_delete": "Are you sure you want to delete this {object}?",
|
||||
|
||||
"import_running": "Import running, please wait!",
|
||||
"all_fields_optional": "All fields are optional and can be left empty.",
|
||||
"convert_internal": "Convert to internal recipe",
|
||||
"show_only_internal": "Show only internal recipes",
|
||||
"show_split_screen": "Split View",
|
||||
|
||||
"Log_Recipe_Cooking": "Log Recipe Cooking",
|
||||
"External_Recipe_Image": "External Recipe Image",
|
||||
"Add_to_Shopping": "Add to Shopping",
|
||||
@ -27,7 +25,6 @@
|
||||
"Hide_as_header": "Hide as header",
|
||||
"Copy_template_reference": "Copy template reference",
|
||||
"Save_and_View": "Save & View",
|
||||
|
||||
"Manage_Books": "Manage Books",
|
||||
"Meal_Plan": "Meal Plan",
|
||||
"Select_Book": "Select Book",
|
||||
@ -57,7 +54,6 @@
|
||||
"Enable_Amount": "Enable Amount",
|
||||
"Disable_Amount": "Disable Amount",
|
||||
"Add_Step": "Add Step",
|
||||
|
||||
"Keywords": "Keywords",
|
||||
"Books": "Books",
|
||||
"Proteins": "Proteins",
|
||||
@ -150,6 +146,8 @@
|
||||
"and_up": "& Up",
|
||||
"Instructions": "Instructions",
|
||||
"Unrated": "Unrated",
|
||||
"Key_Ctrl": "Ctrl",
|
||||
"Key_Shift": "Shift",
|
||||
"Time": "Time",
|
||||
"Text": "Text"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user