Skip to content

Commit

Permalink
autocomplete people picker improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Mar 8, 2024
1 parent 83727b0 commit cf20425
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions webroot/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default {
},
methods: {
performAction() {
this.$emit(this.action, this.item);
this.$emit('callback', this.item);
},
toKebabCase(str) {
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
Expand All @@ -34,6 +34,11 @@ export default {
computed: {
btnTxt() {
return eval(`this.txt.${this.action}`) ?? eval(`this.txt.${this.icon}`)
},
isBtnDisabled() {
// The minimum length that i start search is 3. So we only enable the button when
// the input text value has at least three characters
return this.activeBtn || (this.search.length < 3)
}
},
mounted(el) {
Expand Down Expand Up @@ -86,7 +91,7 @@ export default {
class=" btn btn-grouper btn-primary px-4 border-0"
type="button"
@click="performAction()"
:disabled="activeBtn">
:disabled="isBtnDisabled">
<em class="material-icons lg" aria-hidden="true">{{ this.icon }}</em>
<span class="ml-2">{{ btnTxt }}</span>
</button>
Expand Down
2 changes: 1 addition & 1 deletion webroot/js/members.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default {
<div class="d-flex mb-4">
<form id="add-user-form" class="add-user-form w-100">
<label class="sr-only" for="addUser">{{ txt.search }}</label>
<autocomplete @addUser="(item) => addSubscriber(item)" :activeBtn="loading"/>
<autocomplete @callback="(item) => addSubscriber(item)" :activeBtn="loading"/>
</form>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion webroot/js/page/UserManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default {
}
},
template: /*html*/`
<autocomplete @findManagedUsers="(item) => findManagedUsers(item)"
<autocomplete @callback="(item) => findManagedUsers(item)"
icon="search"
action="findManagedUsers"
:activeBtn="loading"
Expand Down

0 comments on commit cf20425

Please sign in to comment.