diff --git a/ayanova/src/components/pick-list.vue b/ayanova/src/components/pick-list.vue index c39b15ea..343d88af 100644 --- a/ayanova/src/components/pick-list.vue +++ b/ayanova/src/components/pick-list.vue @@ -57,30 +57,38 @@ todo: option to display icon to open the record selected, (we have the type and */ export default { created() { - //need to add no selection object if specified var vm = this; - //console.log("CREATED: calling getList for type ", this.ayaType); - if (vm.preFill) { + console.log("CREATED:value is ", this.value); + + //need to add no selection object if specified + if (vm.noSelectionValid) { + window.$gz.form.addNoSelectionItem(vm.searchResults); + // debugger; + //TODO: this may be needed to force new records to have a zero in their no selection valid fields rather than null + // however it could overwrite a valid value maybe so needs further testing + //this.$emit("input", 0); + } + + //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 + //note that by default this will just fetch the selected record instead of the prefill list + console.log("STUB: created: has value, sb fetched"); + } else if (vm.preFill) { + //no non-empty initial value to select but list specified to pre-fill vm.searchUnderway = true; vm.getList(); - } else { - if (vm.noSelectionValid) { - window.$gz.form.addNoSelectionItem(vm.searchResults); - // debugger; - - //TODO: this may be needed to force new records to have a zero in their no selection valid fields rather than null - // however it could overwrite a valid value maybe so needs further testing - //this.$emit("input", 0); - } - } + } }, beforeUpdate() { //Set the initial list items based on the record items, this only needs to be called once at init //Not sure what this is to picklist as it came from tags - // if (!this.initialized && this.value.length > 0) { - // this.searchResults = this.value; - // this.initialized = true; - // } + //console.log("beforeupdate: value is ", this.value); + if (!this.initialized && this.value && this.value != 0) { + //fetch here + + this.initialized = true; + } }, data() { @@ -91,8 +99,8 @@ export default { searchEntry: null, searchUnderway: false, isTagFilter: false, - errorIcon: null - //,initialized: false + errorIcon: null, + initialized: false }; }, props: { @@ -128,7 +136,7 @@ export default { //clear any local errors vm.errors = []; // console.log("WATCH::SEARCHENTRY TRIGGERED:", val); - if (!val || vm.searchUnderway) { + if (!val || vm.searchUnderway || !vm.initialized) { return; } if (vm.selected != null) { @@ -136,7 +144,7 @@ export default { return; } } - //console.log("WATCH::SEARCHENTRY doing search now"); + // console.log("WATCH::SEARCHENTRY doing search now"); this.doSearch(); }, // value(val) {