This commit is contained in:
2020-03-19 22:48:50 +00:00
parent a598e5966f
commit f858036b00
2 changed files with 66 additions and 26 deletions

View File

@@ -28,8 +28,8 @@
</v-list-item> </v-list-item>
</template> --> </template> -->
</v-autocomplete> </v-autocomplete>
<div>autocomplete selected item: {{ selected }}</div> <!-- <div>autocomplete selected item: {{ selected }}</div>
<div>searchResults: {{ searchResults }}</div> <div>searchResults: {{ searchResults }}</div> -->
</div> </div>
</template> </template>
<script> <script>
@@ -51,7 +51,11 @@ export default {
created() { created() {
//need to add no selection object if specified //need to add no selection object if specified
var vm = this; var vm = this;
vm.doSearch(); //console.log("CREATED: calling getList for type ", this.ayaType);
if (vm.preFill) {
vm.searchUnderway = true;
vm.getList();
}
// if (vm.noSelectionValid) { // if (vm.noSelectionValid) {
// window.$gz.form.addNoSelectionItem(vm.searchResults); // window.$gz.form.addNoSelectionItem(vm.searchResults);
// if (vm.value == null) { // if (vm.value == null) {
@@ -99,6 +103,10 @@ export default {
type: Boolean, type: Boolean,
default: false default: false
}, },
preFill: {
type: Boolean,
default: true
},
label: { type: String, default: "" } label: { type: String, default: "" }
}, },
watch: { watch: {
@@ -106,7 +114,7 @@ export default {
var vm = this; var vm = this;
//clear any local errors //clear any local errors
vm.errors = []; vm.errors = [];
console.log("WATCH::SEARCHENTRY TRIGGERED"); // console.log("WATCH::SEARCHENTRY TRIGGERED:", val);
if (!val || vm.searchUnderway) { if (!val || vm.searchUnderway) {
return; return;
} }
@@ -115,7 +123,7 @@ export default {
return; return;
} }
} }
console.log("WATCH::SEARCHENTRY doing search now"); //console.log("WATCH::SEARCHENTRY doing search now");
this.doSearch(); this.doSearch();
}, },
value(val) { value(val) {
@@ -131,6 +139,36 @@ export default {
lt: function(ltkey) { lt: function(ltkey) {
return window.$gz.translation.get(ltkey); return window.$gz.translation.get(ltkey);
}, },
getList: function(urlParams) {
var vm = this;
// console.log("getlist: calling api.get.picklist for type ", vm.ayaType);
//default params for when called on init
if (!urlParams) {
urlParams = "?ayaType=" + vm.ayaType;
if (vm.includeInactive) {
urlParams += "&inactive=true";
}
}
window.$gz.api
.get("PickList/List" + urlParams)
.then(res => {
if (res.error) {
throw res.error;
}
vm.searchResults = res.data;
if (vm.noSelectionValid) {
window.$gz.form.addNoSelectionItem(vm.searchResults);
// if (vm.value == null) {
// vm.value = 0;
// }
}
vm.searchUnderway = false;
})
.catch(err => {
window.$gz.errorHandler.handleFormError(err);
});
},
doSearch: _.debounce(function() { doSearch: _.debounce(function() {
//NOTE debounce with a watcher is a bit different //NOTE debounce with a watcher is a bit different
//https://vuejs.org/v2/guide/migration.html#debounce-Param-Attribute-for-v-model-removed //https://vuejs.org/v2/guide/migration.html#debounce-Param-Attribute-for-v-model-removed
@@ -223,26 +261,27 @@ export default {
if (vm.includeInactive) { if (vm.includeInactive) {
urlParams += "&inactive=true"; urlParams += "&inactive=true";
} }
this.getList(urlParams);
// console.log("dosearch: calling api.get.picklist for type ", this.ayaType);
// window.$gz.api
// .get("PickList/List" + urlParams)
// .then(res => {
// if (res.error) {
// throw res.error;
// }
window.$gz.api // vm.searchResults = res.data;
.get("PickList/List" + urlParams) // if (vm.noSelectionValid) {
.then(res => { // window.$gz.form.addNoSelectionItem(vm.searchResults);
if (res.error) { // // if (vm.value == null) {
throw res.error; // // vm.value = 0;
} // // }
// }
vm.searchResults = res.data; // vm.searchUnderway = false;
if (vm.noSelectionValid) { // })
window.$gz.form.addNoSelectionItem(vm.searchResults); // .catch(err => {
// if (vm.value == null) { // window.$gz.errorHandler.handleFormError(err);
// vm.value = 0; // });
// }
}
vm.searchUnderway = false;
})
.catch(err => {
window.$gz.errorHandler.handleFormError(err);
});
//------------ //------------
}, 300) //did some checking, 200-300ms seems to be the most common debounce time for ajax search queries }, 300) //did some checking, 200-300ms seems to be the most common debounce time for ajax search queries

View File

@@ -5,15 +5,16 @@
:ayaType="ayaType().Widget" :ayaType="ayaType().Widget"
:label="lt('Widget')" :label="lt('Widget')"
noSelectionValid noSelectionValid
:preFill="false"
> >
</gz-pick-list> </gz-pick-list>
<v-divider></v-divider> <v-divider></v-divider>
<!-- <gz-pick-list <gz-pick-list
v-model="selectedUser" v-model="selectedUser"
:ayaType="ayaType().User" :ayaType="ayaType().User"
:label="lt('User')" :label="lt('User')"
> >
</gz-pick-list> --> </gz-pick-list>
<v-divider></v-divider> <v-divider></v-divider>
<div>FORM Selected Widget: {{ selectedWidget }}</div> <div>FORM Selected Widget: {{ selectedWidget }}</div>
<div>FORM Selected User: {{ selectedUser }}</div> <div>FORM Selected User: {{ selectedUser }}</div>