Skip to content

Commit

Permalink
refactor ADropdown isOpen binding
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhkelley1 committed Jul 17, 2022
1 parent ae5bb24 commit 46598c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
18 changes: 7 additions & 11 deletions check_run/public/js/check_run/ADropdown.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="autocomplete" :class="{ 'isOpen': state.transactions[transactionIndex].mopIsOpen }">
<div class="autocomplete" :class="{ 'isOpen': isOpen }">
<input
type="text"
:id="`mop-input-${transactionIndex}`"
Expand All @@ -13,7 +13,7 @@
/>
<ul
id="autocomplete-results"
v-show="state.transactions[transactionIndex].mopIsOpen"
v-show="isOpen"
class="autocomplete-results"
>
<li
Expand Down Expand Up @@ -41,7 +41,7 @@
name: 'ADropdown',
props: {
value: String,
//isOpen: Object,
isOpen: Boolean,
items: {
type: Array,
required: false,
Expand All @@ -52,9 +52,6 @@
required: false,
default: false,
},
state: {
required: false
},
transactionIndex: Number
},
data() {
Expand Down Expand Up @@ -97,15 +94,14 @@
});
},
onChange() {
//this.$emit('input', this.search);
if (this.isAsync) {
this.isLoading = true;
} else {
this.filterResults();
this.state.transactions[this.transactionIndex].mopIsOpen = true
//this.$emit('isOpenChanged', this.isOpen.val)
this.isOpen = true
this.$emit('isOpenChanged', this.isOpen)
}
},
Expand All @@ -117,8 +113,8 @@
},
closeResults() {
this.state.transactions[this.transactionIndex].mopIsOpen = false
//this.$emit('isOpenChanged', this.isOpen.val)
this.isOpen = false
this.$emit('isOpenChanged', this.isOpen)
if(!this.items.includes(this.search)) {
this.search = ''
Expand Down
2 changes: 1 addition & 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" :state="state" :transactionIndex="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"/>

<span v-else>{{ transactions[i].mode_of_payment }}</span>
</td>
Expand Down

0 comments on commit 46598c1

Please sign in to comment.