This commit is contained in:
2020-03-19 19:36:59 +00:00
parent 48e71adf39
commit f122f6197e
2 changed files with 25 additions and 46 deletions

View File

@@ -1,26 +1,24 @@
<template> <template>
<div> <div>
<!-- <span class="v-label v-label--active theme--light">
{{ lt("label here") }}
</span> -->
<v-autocomplete <v-autocomplete
label="lbl Widgets"
v-model="selected" v-model="selected"
return-object return-object
:items="searchResults" :items="searchResults"
:label="Label"
item-text="name" item-text="name"
item-value="id" item-value="id"
item-disabled="!active" item-disabled="!active"
:error-messages="errors" :error-messages="errors"
:loading="searchUnderway" :loading="searchUnderway"
:placeholder="lt('search hint here')" :placeholder="lt('search hint here')"
:no-data-text="lt('NoData')"
:search-input.sync="searchEntry" :search-input.sync="searchEntry"
auto-select-first auto-select-first
:multiple="multiple" :multiple="multiple"
no-filter no-filter
hide-no-data
clearable
> >
<!-- <template v-slot:no-data>no-filter hide-selected v-on:input="$emit('input', $event)" cache-items="false" <!-- <template v-slot:no-data>no-filter hide-selected v-on:input="$emit('input', $event)" cache-items="false":no-data-text="lt('NoData')"
<v-list-item> <v-list-item>
<v-list-item-title> <v-list-item-title>
Search for your favorite Search for your favorite
@@ -29,37 +27,8 @@
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
</template> --> </template> -->
<!-- <template slot="no-data" v-if="searchEntry">
<v-container>
<v-row row>
<v-row justify-center>
<v-chip color="primary" text-color="white" class="display-1">
{{ this.normalizeTag(searchEntry) }}</v-chip
>
<v-btn large icon @click="addTag()">
<v-icon large color="success">fa-plus-circle</v-icon>
</v-btn>
</v-row>
</v-row>
</v-container>
</template> -->
</v-autocomplete> </v-autocomplete>
<div> <div>autocomplete selected item: {{ selected }}</div>
selected
{{ selected }}
</div>
<!-- <div>
value
{{ value }}
</div> -->
<div>
searchEntry
{{ searchEntry }}
</div>
<div>
searchResults
{{ searchResults }}
</div>
</div> </div>
</template> </template>
<script> <script>
@@ -70,7 +39,10 @@
//it would not recognize window in the function call //it would not recognize window in the function call
import _ from "../libs/lodash.min.js"; import _ from "../libs/lodash.min.js";
//todo: empty item support //todo: empty item support
//todo: custom filter that works with tags (ignore tag part and filter as normal) //todo: custom filter (highlight in results) that works with tags (ignore tag part and filter as normal)
//todo: validation error is obscured by no-data element
//todo: set actual seleted ID value from our local selected whole object so outer form just gets id
//todo test multiple selection
export default { export default {
created() { created() {
@@ -122,7 +94,8 @@ export default {
noSelectionValid: { noSelectionValid: {
type: Boolean, type: Boolean,
default: false default: false
} },
Label: { type: String, default: "" }
}, },
watch: { watch: {
searchEntry(val) { searchEntry(val) {
@@ -180,7 +153,6 @@ export default {
} }
//Now vet the terms //Now vet the terms
//Is user in mid entry of a second tag (space only?) //Is user in mid entry of a second tag (space only?)
//will appear as an empty string post split //will appear as an empty string post split
if (queryTerms[1] == "") { if (queryTerms[1] == "") {
@@ -240,16 +212,12 @@ export default {
urlParams += "&inactive=true"; urlParams += "&inactive=true";
} }
console.log("sending search to server ", urlParams);
window.$gz.api window.$gz.api
.get("PickList/List" + urlParams) .get("PickList/List" + urlParams)
.then(res => { .then(res => {
if (res.error) { if (res.error) {
throw res.error; throw res.error;
} }
//adding this to the property will automatically have it cached by the autocomplete component
//as cache-items has been set so this just needs to be set here once and all is well in future
//Any search will be kept for later so this is very efficient
vm.searchResults = res.data; vm.searchResults = res.data;
vm.searchUnderway = false; vm.searchUnderway = false;
}) })
@@ -258,7 +226,7 @@ export default {
}); });
//------------ //------------
}, 400)//did some checking, 200-300ms seems to be the most common }, 300) //did some checking, 200-300ms seems to be the most common debounce time for ajax search queries
}, },
beforeCreate() { beforeCreate() {
//check pre-requisites exist just in case //check pre-requisites exist just in case

View File

@@ -1,7 +1,17 @@
<template> <template>
<div> <div>
<gz-pick-list v-model="selectedWidget" :ayaType="ayaType().Widget"> <gz-pick-list
v-model="selectedWidget"
:ayaType="ayaType().Widget"
Label="Widget"
>
</gz-pick-list> </gz-pick-list>
<v-divider></v-divider>
<gz-pick-list v-model="selectedUser" :ayaType="ayaType().User" Label="User">
</gz-pick-list>
<v-divider></v-divider>
<div>FORM Selected Widget: {{ selectedWidget }}</div>
<div>FORM Selected User: {{ selectedUser }}</div>
</div> </div>
</template> </template>
@@ -32,7 +42,8 @@ export default {
}, },
data() { data() {
return { return {
selectedWidget: null selectedWidget: null,
selectedUser: null
}; };
}, },
methods: { methods: {