picklist done, all things working as far as I know :)
This commit is contained in:
@@ -38,61 +38,16 @@
|
|||||||
//NOTE: have to import lodash directly here as no combination was working with the window.$gz._
|
//NOTE: have to import lodash directly here as no combination was working with the window.$gz._
|
||||||
//it would not recognize window in the function call cache-items
|
//it would not recognize window in the function call cache-items
|
||||||
import _ from "../libs/lodash.min.js";
|
import _ from "../libs/lodash.min.js";
|
||||||
/*
|
|
||||||
States
|
|
||||||
1) Open form have a preselected Value
|
|
||||||
init: load preselected value only
|
|
||||||
change:
|
|
||||||
DROP DOWN need to drop down and have it populate with top 100
|
|
||||||
EDIT search as normal but keep preselected value until changed
|
|
||||||
|
|
||||||
2) Open form have no value
|
|
||||||
init: ALWAYS starts with no selection if no value, up to server routes to deal with 0 id selection if they need to
|
|
||||||
|
|
||||||
change
|
|
||||||
drop down, get top 100
|
|
||||||
edit and search as normal
|
|
||||||
|
|
||||||
NO VALUE
|
|
||||||
if not valid then there should be a rule enforcing that, not the control's issue
|
|
||||||
|
|
||||||
Control always has a value, either it's NO VALUE or it's a selection
|
|
||||||
|
|
||||||
DROP DOWN
|
|
||||||
if no items already loaded then fetches top 100 IN ADDITION to the preselect if present
|
|
||||||
if items already loaded then just shows those items as they are likely from a prior search and user can just search again
|
|
||||||
if user clears then drops down it acts as a fresh load of 100 items
|
|
||||||
|
|
||||||
PRE-FILL
|
|
||||||
NO prefill, fills only on user action or with defaults to save bandwidth. User must drop down to initiate action or type search text
|
|
||||||
|
|
||||||
|
|
||||||
todo: option to display icon to open the record selected, (we have the type and the id and in v7 you could click on most titles to navigate to that record)
|
|
||||||
if I add that then maybe need a "new" option on edit forms because it's a two step way to get to adding a new one of whatever it is without having to go
|
|
||||||
completely out of the page and hunt around lists and shit!!!
|
|
||||||
or consider a direct NEW button right there, (this might be a winner)
|
|
||||||
or maybe combine the two ideas, if no selection or empty selection then the button acts as new, puts any entered search text into the Name field
|
|
||||||
or, if selection then it acts as open
|
|
||||||
*/
|
|
||||||
export default {
|
export default {
|
||||||
created() {
|
created() {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
// console.log("CREATED:value is ", this.value);
|
|
||||||
|
|
||||||
//need to add no selection object always, if it's not valid then that's a rule for the form, not the control
|
//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);
|
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
|
|
||||||
//
|
|
||||||
|
|
||||||
//set initial value in control if selected
|
//set initial value in control if selected
|
||||||
if (vm.value != null && vm.value != 0) {
|
if (vm.value != null && vm.value != 0) {
|
||||||
//It has a prior non empty selection that needs to be fetched
|
//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");
|
|
||||||
var urlParams = "?ayaType=" + vm.ayaType + "&preId=" + vm.value;
|
var urlParams = "?ayaType=" + vm.ayaType + "&preId=" + vm.value;
|
||||||
vm.getList(urlParams);
|
vm.getList(urlParams);
|
||||||
}
|
}
|
||||||
@@ -139,13 +94,6 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log(
|
|
||||||
// "watch:searchentry cleared check to see if it's a selected list item, doing search for ",
|
|
||||||
// val
|
|
||||||
// );
|
|
||||||
// console.log("search results:", vm.searchResults);
|
|
||||||
|
|
||||||
if (!val || vm.fetching || !vm.initialized) {
|
if (!val || vm.fetching || !vm.initialized) {
|
||||||
if (!vm.initialized) {
|
if (!vm.initialized) {
|
||||||
vm.$nextTick(() => {
|
vm.$nextTick(() => {
|
||||||
@@ -212,38 +160,26 @@ export default {
|
|||||||
this.lastSelection = e;
|
this.lastSelection = e;
|
||||||
},
|
},
|
||||||
replaceLastSelection() {
|
replaceLastSelection() {
|
||||||
// console.log("replace last selection top");
|
|
||||||
var vm = this;
|
var vm = this;
|
||||||
//check if searchREsults has last selection, if not then add it back in again
|
//check if searchResults has last selection, if not then add it back in again
|
||||||
if (vm.lastSelection == null) {
|
if (vm.lastSelection == null) {
|
||||||
//it might be initializing
|
//it might be initializing
|
||||||
|
|
||||||
for (var i = 0; i < vm.searchResults.length; i++) {
|
for (var i = 0; i < vm.searchResults.length; i++) {
|
||||||
if (vm.searchResults[i].id == vm.value) {
|
if (vm.searchResults[i].id == vm.value) {
|
||||||
// console.log(
|
|
||||||
// "rpl last selection null but found in list so setting last selection"
|
|
||||||
// );
|
|
||||||
vm.lastSelection = vm.searchResults[i];
|
vm.lastSelection = vm.searchResults[i];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log("RPL bailing as last selection is null and not in list");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < vm.searchResults.length; i++) {
|
for (var i = 0; i < vm.searchResults.length; i++) {
|
||||||
if (vm.searchResults[i].id == vm.lastSelection.id) {
|
if (vm.searchResults[i].id == vm.lastSelection.id) {
|
||||||
//console.log("replacelastselection bailing, it's in list already");
|
return; //already there
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Not there so insert it
|
||||||
vm.searchResults.push(vm.lastSelection);
|
vm.searchResults.push(vm.lastSelection);
|
||||||
// console.log(
|
|
||||||
// "replacelastselection bottom, search results now:",
|
|
||||||
// vm.searchResults
|
|
||||||
// );
|
|
||||||
},
|
},
|
||||||
dropdown(e) {
|
dropdown(e) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
@@ -282,7 +218,6 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vm.fetching = true;
|
vm.fetching = true;
|
||||||
// console.log("getlist: calling api.get.picklist for type ", vm.ayaType);
|
|
||||||
//default params for when called on init
|
//default params for when called on init
|
||||||
if (!urlParams) {
|
if (!urlParams) {
|
||||||
urlParams = "?ayaType=" + vm.ayaType;
|
urlParams = "?ayaType=" + vm.ayaType;
|
||||||
@@ -307,13 +242,11 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
doSearch: _.debounce(function() {
|
doSearch: _.debounce(function() {
|
||||||
//NOTE debounce with a watcher is a bit different
|
//NOTE debounce with a watcher is a bit different, currently it has to be done exactly this way, nothing else will work properly
|
||||||
//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
|
||||||
//-----------------
|
//-----------------
|
||||||
|
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
//NOTE: empty query is valid; it means get the top 100 ordered by template order
|
||||||
//NOTE: empty query is perfectly valid; it means get the top 100 ordered by template order
|
|
||||||
var emptyQuery = false;
|
var emptyQuery = false;
|
||||||
if (this.searchEntry == null || this.searchEntry == "") {
|
if (this.searchEntry == null || this.searchEntry == "") {
|
||||||
emptyQuery = true;
|
emptyQuery = true;
|
||||||
@@ -377,8 +310,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//build url
|
//build url
|
||||||
//vm.fetching = true;
|
|
||||||
|
|
||||||
var urlParams = "?ayaType=" + vm.ayaType;
|
var urlParams = "?ayaType=" + vm.ayaType;
|
||||||
if (!emptyQuery) {
|
if (!emptyQuery) {
|
||||||
var query = queryTerms[0];
|
var query = queryTerms[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user