mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
mobile ingredient edit improvements
This commit is contained in:
@@ -146,30 +146,30 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
<v-dialog
|
<v-bottom-sheet v-model="dialogIngredientEditor">
|
||||||
v-model="dialogIngredientEditor"
|
<v-card v-if="editingIngredientIndex >= 0">
|
||||||
:max-width="(mobile) ? '100vw': '75vw'"
|
|
||||||
:fullscreen="mobile">
|
|
||||||
<v-card>
|
|
||||||
<v-closable-card-title :title="$t('Ingredient Editor')" v-model="dialogIngredientEditor"></v-closable-card-title>
|
<v-closable-card-title :title="$t('Ingredient Editor')" v-model="dialogIngredientEditor"></v-closable-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-form>
|
<v-form>
|
||||||
<v-number-input v-model="step.ingredients[editingIngredientIndex].amount" inset control-variant="stacked" :label="$t('Amount')"
|
<v-number-input v-model="step.ingredients[editingIngredientIndex].amount" inset control-variant="stacked" autofocus :label="$t('Amount')"
|
||||||
:min="0"></v-number-input>
|
:min="0"></v-number-input>
|
||||||
<model-select model="Unit" v-model="step.ingredients[editingIngredientIndex].unit" :label="$t('Unit')"></model-select>
|
<model-select model="Unit" v-model="step.ingredients[editingIngredientIndex].unit" :label="$t('Unit')"></model-select>
|
||||||
<model-select model="Food" v-model="step.ingredients[editingIngredientIndex].food" :label="$t('Food')"></model-select>
|
<model-select model="Food" v-model="step.ingredients[editingIngredientIndex].food" :label="$t('Food')"></model-select>
|
||||||
<v-text-field :label="$t('Note')" v-model="step.ingredients[editingIngredientIndex].note" ></v-text-field>
|
<v-text-field :label="$t('Note')" v-model="step.ingredients[editingIngredientIndex].note"></v-text-field>
|
||||||
</v-form>
|
</v-form>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-btn @click="dialogIngredientEditor = false">{{ $t('Close') }}</v-btn>
|
<v-btn @click="dialogIngredientEditor = false; deleteIngredientAtIndex(editingIngredientIndex); editingIngredientIndex = -1" color="delete" prepend-icon="$delete">
|
||||||
|
{{ $t('Delete') }}
|
||||||
|
</v-btn>
|
||||||
|
<v-btn @click="dialogIngredientEditor = false" color="save" prepend-icon="$save">{{ $t('Save') }}</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-bottom-sheet>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {nextTick, ref} from 'vue'
|
import {nextTick, ref, useTemplateRef} from 'vue'
|
||||||
import {ApiApi, Ingredient, ParsedIngredient, Step} from "@/openapi";
|
import {ApiApi, Ingredient, ParsedIngredient, Step} from "@/openapi";
|
||||||
import StepMarkdownEditor from "@/components/inputs/StepMarkdownEditor.vue";
|
import StepMarkdownEditor from "@/components/inputs/StepMarkdownEditor.vue";
|
||||||
import {VNumberInput} from 'vuetify/labs/VNumberInput'
|
import {VNumberInput} from 'vuetify/labs/VNumberInput'
|
||||||
@@ -178,6 +178,7 @@ import {useDisplay} from "vuetify";
|
|||||||
import {VueDraggable} from "vue-draggable-plus";
|
import {VueDraggable} from "vue-draggable-plus";
|
||||||
import VClosableCardTitle from "@/components/dialogs/VClosableCardTitle.vue";
|
import VClosableCardTitle from "@/components/dialogs/VClosableCardTitle.vue";
|
||||||
import IngredientString from "@/components/display/IngredientString.vue";
|
import IngredientString from "@/components/display/IngredientString.vue";
|
||||||
|
import numberInput from "../../../../vue/src/components/Modals/NumberInput.vue";
|
||||||
|
|
||||||
const emit = defineEmits(['delete'])
|
const emit = defineEmits(['delete'])
|
||||||
|
|
||||||
@@ -197,8 +198,9 @@ const dialogMarkdownEditor = ref(false)
|
|||||||
const dialogIngredientEditor = ref(false)
|
const dialogIngredientEditor = ref(false)
|
||||||
const dialogIngredientParser = ref(false)
|
const dialogIngredientParser = ref(false)
|
||||||
|
|
||||||
const editingIngredientIndex = ref({} as Ingredient)
|
const editingIngredientIndex = ref(Number)
|
||||||
const ingredientTextInput = ref("")
|
const ingredientTextInput = ref("")
|
||||||
|
const ingredientDialogAmountRef = useTemplateRef('ref_input_amount_dialog')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sort function called by draggable when ingredient table is sorted
|
* sort function called by draggable when ingredient table is sorted
|
||||||
@@ -253,9 +255,23 @@ function handleIngredientNoteTab(event: KeyboardEvent, index: number) {
|
|||||||
function insertAndFocusIngredient() {
|
function insertAndFocusIngredient() {
|
||||||
step.value.ingredients.push({} as Ingredient)
|
step.value.ingredients.push({} as Ingredient)
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
document.getElementById(`id_input_amount_${step.value.id}_${step.value.ingredients.length - 1}`).select()
|
if (mobile.value) {
|
||||||
|
editingIngredientIndex.value = step.value.ingredients.length - 1
|
||||||
|
dialogIngredientEditor.value = true
|
||||||
|
} else {
|
||||||
|
document.getElementById(`id_input_amount_${step.value.id}_${step.value.ingredients.length - 1}`).select()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete ingredient from step at given index
|
||||||
|
* @param index
|
||||||
|
*/
|
||||||
|
function deleteIngredientAtIndex(index: number) {
|
||||||
|
step.value.ingredients.splice(index, 1)
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user