Modifications to picklist as it was not working with a delayed set when I tested with actual Widget form. Definitely better though with these changes.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
{{ value }}
|
||||
<v-autocomplete
|
||||
v-bind:value="value"
|
||||
v-on:input="selectionMade($event)"
|
||||
@@ -41,16 +42,7 @@ import _ from "../libs/lodash.min.js";
|
||||
|
||||
export default {
|
||||
created() {
|
||||
var vm = this;
|
||||
//need to add no selection object always, if it's not valid then that's a rule for the form, not the control
|
||||
window.$gz.form.addNoSelectionItem(vm.searchResults);
|
||||
|
||||
//set initial value in control if selected
|
||||
if (vm.value != null && vm.value != 0) {
|
||||
//It has a prior non empty selection that needs to be fetched
|
||||
var urlParams = "?ayaType=" + vm.ayaType + "&preId=" + vm.value;
|
||||
vm.getList(urlParams);
|
||||
}
|
||||
this.fetchValueIfNotPresent();
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -77,13 +69,36 @@ export default {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
allowEdit: {
|
||||
showEditIcon: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
label: { type: String, default: "" }
|
||||
},
|
||||
watch: {
|
||||
value(val) {
|
||||
this.fetchValueIfNotPresent();
|
||||
// //is there a value that might require fetching?
|
||||
// if (val == null || val == 0) {
|
||||
// return;
|
||||
// }
|
||||
// var vm = this;
|
||||
// //check if it's in the list of items we have here
|
||||
// for (var i = 0; i < vm.searchResults.length; i++) {
|
||||
// if (vm.searchResults[i].id == val) {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// //Not here, better get it
|
||||
// var urlParams = "?ayaType=" + vm.ayaType + "&preId=" + vm.value;
|
||||
// console.log("WATCH:Value not present, calling getlist with ", urlParams);
|
||||
// vm.getList(urlParams);
|
||||
|
||||
//todo: here is where we need to trigger the INIT single fetch because it's not being set otherwise as there is a delay on form fetching
|
||||
// console.log("WATCH:Value changed and it's not in the list FETCH?:", val);
|
||||
// setValue(this.$refs.textField.$refs.input, value);
|
||||
},
|
||||
searchEntry(val, oldVal) {
|
||||
var vm = this;
|
||||
//clear any local errors
|
||||
@@ -130,7 +145,7 @@ export default {
|
||||
});
|
||||
},
|
||||
editIcon: function() {
|
||||
if (!this.allowEdit) {
|
||||
if (!this.showEditIcon) {
|
||||
return null;
|
||||
}
|
||||
if (this.value != 0) {
|
||||
@@ -159,6 +174,29 @@ export default {
|
||||
}
|
||||
this.lastSelection = e;
|
||||
},
|
||||
fetchValueIfNotPresent() {
|
||||
//is there a value that might require fetching?
|
||||
|
||||
var vm = this;
|
||||
var val = vm.value;
|
||||
if (val == null) {
|
||||
return;
|
||||
}
|
||||
//check if it's in the list of items we have here
|
||||
for (var i = 0; i < vm.searchResults.length; i++) {
|
||||
if (vm.searchResults[i].id == val) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
//is it the no selection item?
|
||||
if (val == 0) {
|
||||
window.$gz.form.addNoSelectionItem(vm.searchResults);
|
||||
} else {
|
||||
//Not here, better get it
|
||||
var urlParams = "?ayaType=" + vm.ayaType + "&preId=" + vm.value;
|
||||
vm.getList(urlParams);
|
||||
}
|
||||
},
|
||||
replaceLastSelection() {
|
||||
var vm = this;
|
||||
//check if searchResults has last selection, if not then add it back in again
|
||||
|
||||
Reference in New Issue
Block a user