This commit is contained in:
@@ -28,8 +28,8 @@
|
||||
</v-list-item>
|
||||
</template> -->
|
||||
</v-autocomplete>
|
||||
<div>autocomplete selected item: {{ selected }}</div>
|
||||
<div>searchResults: {{ searchResults }}</div>
|
||||
<!-- <div>autocomplete selected item: {{ selected }}</div>
|
||||
<div>searchResults: {{ searchResults }}</div> -->
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
@@ -51,7 +51,11 @@ export default {
|
||||
created() {
|
||||
//need to add no selection object if specified
|
||||
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) {
|
||||
// window.$gz.form.addNoSelectionItem(vm.searchResults);
|
||||
// if (vm.value == null) {
|
||||
@@ -99,6 +103,10 @@ export default {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
preFill: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
label: { type: String, default: "" }
|
||||
},
|
||||
watch: {
|
||||
@@ -106,7 +114,7 @@ export default {
|
||||
var vm = this;
|
||||
//clear any local errors
|
||||
vm.errors = [];
|
||||
console.log("WATCH::SEARCHENTRY TRIGGERED");
|
||||
// console.log("WATCH::SEARCHENTRY TRIGGERED:", val);
|
||||
if (!val || vm.searchUnderway) {
|
||||
return;
|
||||
}
|
||||
@@ -115,7 +123,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log("WATCH::SEARCHENTRY doing search now");
|
||||
//console.log("WATCH::SEARCHENTRY doing search now");
|
||||
this.doSearch();
|
||||
},
|
||||
value(val) {
|
||||
@@ -131,6 +139,36 @@ export default {
|
||||
lt: function(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() {
|
||||
//NOTE debounce with a watcher is a bit different
|
||||
//https://vuejs.org/v2/guide/migration.html#debounce-Param-Attribute-for-v-model-removed
|
||||
@@ -223,26 +261,27 @@ export default {
|
||||
if (vm.includeInactive) {
|
||||
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
|
||||
.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);
|
||||
});
|
||||
// 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);
|
||||
// });
|
||||
|
||||
//------------
|
||||
}, 300) //did some checking, 200-300ms seems to be the most common debounce time for ajax search queries
|
||||
|
||||
@@ -5,15 +5,16 @@
|
||||
:ayaType="ayaType().Widget"
|
||||
:label="lt('Widget')"
|
||||
noSelectionValid
|
||||
:preFill="false"
|
||||
>
|
||||
</gz-pick-list>
|
||||
<v-divider></v-divider>
|
||||
<!-- <gz-pick-list
|
||||
<gz-pick-list
|
||||
v-model="selectedUser"
|
||||
:ayaType="ayaType().User"
|
||||
:label="lt('User')"
|
||||
>
|
||||
</gz-pick-list> -->
|
||||
</gz-pick-list>
|
||||
<v-divider></v-divider>
|
||||
<div>FORM Selected Widget: {{ selectedWidget }}</div>
|
||||
<div>FORM Selected User: {{ selectedUser }}</div>
|
||||
|
||||
Reference in New Issue
Block a user