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._
|
||||
//it would not recognize window in the function call cache-items
|
||||
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 {
|
||||
created() {
|
||||
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
|
||||
|
||||
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
|
||||
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");
|
||||
var urlParams = "?ayaType=" + vm.ayaType + "&preId=" + vm.value;
|
||||
vm.getList(urlParams);
|
||||
}
|
||||
@@ -139,13 +94,6 @@ export default {
|
||||
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 (!vm.initialized) {
|
||||
vm.$nextTick(() => {
|
||||
@@ -212,38 +160,26 @@ export default {
|
||||
this.lastSelection = e;
|
||||
},
|
||||
replaceLastSelection() {
|
||||
// console.log("replace last selection top");
|
||||
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) {
|
||||
//it might be initializing
|
||||
|
||||
for (var i = 0; i < vm.searchResults.length; i++) {
|
||||
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];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// console.log("RPL bailing as last selection is null and not in list");
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < vm.searchResults.length; i++) {
|
||||
if (vm.searchResults[i].id == vm.lastSelection.id) {
|
||||
//console.log("replacelastselection bailing, it's in list already");
|
||||
return;
|
||||
return; //already there
|
||||
}
|
||||
}
|
||||
|
||||
//Not there so insert it
|
||||
vm.searchResults.push(vm.lastSelection);
|
||||
// console.log(
|
||||
// "replacelastselection bottom, search results now:",
|
||||
// vm.searchResults
|
||||
// );
|
||||
},
|
||||
dropdown(e) {
|
||||
var vm = this;
|
||||
@@ -282,7 +218,6 @@ export default {
|
||||
return;
|
||||
}
|
||||
vm.fetching = true;
|
||||
// console.log("getlist: calling api.get.picklist for type ", vm.ayaType);
|
||||
//default params for when called on init
|
||||
if (!urlParams) {
|
||||
urlParams = "?ayaType=" + vm.ayaType;
|
||||
@@ -307,13 +242,11 @@ export default {
|
||||
});
|
||||
},
|
||||
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
|
||||
//-----------------
|
||||
|
||||
var vm = this;
|
||||
|
||||
//NOTE: empty query is perfectly valid; it means get the top 100 ordered by template order
|
||||
//NOTE: empty query is valid; it means get the top 100 ordered by template order
|
||||
var emptyQuery = false;
|
||||
if (this.searchEntry == null || this.searchEntry == "") {
|
||||
emptyQuery = true;
|
||||
@@ -377,8 +310,6 @@ export default {
|
||||
}
|
||||
|
||||
//build url
|
||||
//vm.fetching = true;
|
||||
|
||||
var urlParams = "?ayaType=" + vm.ayaType;
|
||||
if (!emptyQuery) {
|
||||
var query = queryTerms[0];
|
||||
|
||||
Reference in New Issue
Block a user