Skip to content

Commit

Permalink
Merge branch 'key-nav' of github.com:agritheory/check_run into key-nav
Browse files Browse the repository at this point in the history
  • Loading branch information
agritheory committed Jul 21, 2022
2 parents 0823fc5 + 0873c5d commit 33bc96b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
6 changes: 6 additions & 0 deletions check_run/public/js/check_run/ADropdown.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="autocomplete" :class="{ 'isOpen': isOpen }">
<input
ref="mopInput"
type="text"
:id="`mop-input-${transactionIndex}`"
@input="onChange"
Expand Down Expand Up @@ -140,6 +141,11 @@
this.closeResults()
this.arrowCounter = 0;
},
openWithSearch() {
this.search = ""
this.onChange()
this.$refs.mopInput.focus()
}
},
};
</script>
Expand Down
19 changes: 18 additions & 1 deletion check_run/public/js/check_run/CheckRun.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
:data-mop-index="i"
>

<ADropdown v-model="state.transactions[i].mode_of_payment" :items="modeOfPaymentNames" v-if="state.docstatus < 1" :transactionIndex="i" :isOpen="state.transactions[i].mopIsOpen" @isOpenChanged="val => state.transactions[i].mopIsOpen = val"/>
<ADropdown ref="dropdowns" v-model="state.transactions[i].mode_of_payment" :items="modeOfPaymentNames" v-if="state.docstatus < 1" :transactionIndex="i" :isOpen="state.transactions[i].mopIsOpen" @isOpenChanged="val => state.transactions[i].mopIsOpen = val"/>

<span v-else>{{ transactions[i].mode_of_payment }}</span>
</td>
Expand Down Expand Up @@ -149,11 +149,28 @@ export default {
cur_frm.doc.amount_check_run = cur_frm.check_run_state.check_run_total()
cur_frm.refresh_field("amount_check_run")
this.markDirty()
},
checkPay() {
if(this.state.docstatus >= 1 || !this.transactions.length) {
return
}
this.transactions[this.state.selectedRow].pay = !this.transactions[this.state.selectedRow].pay
this.onPayChange()
},
openMopWithSearch(keycode) {
if(!this.transactions.length) {
return
}
this.$refs.dropdowns[this.state.selectedRow].openWithSearch()
}
},
beforeMount() {
this.moment = moment;
this.format_currency = format_currency;
cur_frm.check_run_component = this;
}
}
</script>
Expand Down
9 changes: 7 additions & 2 deletions check_run/public/js/check_run/check_run.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ check_run.mount_table = frm => {
check_run.frm = frm
frm.transactions.forEach(val => {
val.mopIsOpen = false
val.pay = val.pay ? val.pay : false
})
frm.check_run_state = Vue.observable({
transactions: frm.transactions,
Expand Down Expand Up @@ -48,7 +49,6 @@ check_run.keyDownHandler = e => {
}

if(e.keyCode == 40 && check_run.frm.check_run_state.selectedRow < (check_run.frm.check_run_state.transactions.length - 1)){
console.log("state", check_run.frm.check_run_state)
for(let j=0;j<check_run.frm.check_run_state.transactions.length;j++) {
if(check_run.frm.check_run_state.transactions[j].mopIsOpen) {
return
Expand All @@ -70,8 +70,13 @@ check_run.keyDownHandler = e => {

if(e.keyCode == 32 && check_run.frm.check_run_state.selectedRow != null && check_run.frm.check_run_state.transactions.length){
e.preventDefault()
document.getElementById(`mop-input-${check_run.frm.check_run_state.selectedRow}`).focus()
if(check_run.frm.check_run_component) {
check_run.frm.check_run_component.checkPay();
}
}

if(e.keyCode && e.keyCode >= 65 && e.keyCode <= 90 && check_run.frm.check_run_state.selectedRow != null && check_run.frm.check_run_state.transactions.length){
check_run.frm.check_run_component.openMopWithSearch(e.keyCode)
}

}
Expand Down

0 comments on commit 33bc96b

Please sign in to comment.