Change input enter event handler to use DOM

This commit is contained in:
benguozakinci@gmail.com 2021-08-27 15:33:11 +03:00
parent 714fd00971
commit 5633689c17
3 changed files with 10 additions and 4 deletions

View File

@ -97,13 +97,20 @@ const app = new Vue({
methods: {
onRefFocus(ref, index) {
this.disableFormSubmission();
ref
? ref === 'price'
? setPromiseTimeout(100).then(() => this.$refs[ref][0].$children[0].$el.focus())
? setPromiseTimeout(100).then(() => this.$refs[ref][index].$children[0].$el.focus())
: setPromiseTimeout(100).then(() => this.$refs[ref][index].focus())
: {}
},
disableFormSubmission() {
const saveButtonEl = document.getElementsByClassName("btn btn-icon btn-success")[0];
saveButtonEl.setAttribute("type", "button");
},
onCalculateTotal() {
let global_discount = parseFloat(this.form.discount);
let discount_total = 0;
@ -316,7 +323,7 @@ const app = new Vue({
let inputRef = `${itemType === 'newItem' ? 'name' : 'description'}`; // indication for which input to focus first
let total = 1 * item.price;
let item_taxes = [];
this.onRefFocus(inputRef, index); // trigger initial focus event on input
if (item.tax_ids) {

View File

@ -1,4 +1,3 @@
<div class="card">
<div class="card-footer">
<div class="row save-buttons" @click="onSubmit">

View File

@ -12,7 +12,7 @@
{!! Form::button(
'<span v-if="form.loading" class="btn-inner--icon"><i class="aka-loader"></i></span> <span :class="[{\'ml-0\': form.loading}]" class="btn-inner--text">' . trans('general.save') . '</span>',
[':disabled' => 'form.loading', 'class' => 'btn btn-icon btn-success']) !!}
[':disabled' => 'form.loading', 'type' => 'submit', 'class' => 'btn btn-icon btn-success']) !!}
</div>
@stack('save_buttons_end')