This commit is contained in:
2020-02-25 23:25:55 +00:00
parent ff6683f7d5
commit 5482ef30cd
5 changed files with 44 additions and 20 deletions

View File

@@ -43,15 +43,15 @@ CURRENT TODOs
=-=-=-=-=-=-=
todo: keeping negative symbol when unsaved and duplicate
- route replace shit not proper? (no)
- how on earth does it work with a multi digit duplicate in widget edit form
duplicate ok because it just goes to the new record
it's really used only with a zero as the record id which is one digit so always works to replace
since a listview can be -1 it needs to use the replace to last slash method it was using prior instead
TODO: when filter saved sb the one used when you return to the form no exceptions
- right now it returns to the "unsaved", maybe it's not setting formsettings correctly on leave if saved
- actually caused by formstate dirty on exit of listVieweditor
- Is form submit POST route actually reloading the listVieweditor as expected? Looks like not?
TODO: no data should only show if not loading on datatable
todo: default "df" thing isn't really working at the moment, I can remove the Name column from widgets and then I can't open a widget from teh grid
- see if "df" has any purpose other than my initial though of an openable option for the record

View File

@@ -654,10 +654,17 @@ export default {
// and temporary ones are stored in session storage and don't persist a refresh
//
getFormSettings(formKey) {
return {
var formSettings = {
temp: JSON.parse(sessionStorage.getItem(formKey)),
saved: window.$gz.store.state.formSettings[formKey]
};
console.log(
"gzForm::getFormSettings list view id is:" +
window.$gz.store.state.formSettings["test-widgets"].dataTable.listViewId
);
return formSettings;
},
////////////////////////////////////
// Set form settings
@@ -682,6 +689,11 @@ export default {
if (formSettings.temp) {
sessionStorage.setItem(formKey, JSON.stringify(formSettings.temp));
}
console.trace();
console.log(
"gzForm::setFormSettings at bottom after commit, listviewid in store is:" +
window.$gz.store.state.formSettings["test-widgets"].dataTable.listViewId
);
}, ////////////////////////////////////
// Add no selection item
// Used by forms that need the option of an unselected

View File

@@ -783,7 +783,9 @@ function saveFormSettings(vm) {
function loadFormSettings(vm) {
//console.log("loadFormSettings::TOP");
// debugger;
console.log("gz-data-table::loadFormSettings getting form settings");
var formSettings = window.$gz.form.getFormSettings(vm.formKey);
//process SAVED formsettings
if (formSettings.saved) {
if (formSettings.saved.itemsPerPage) {

View File

@@ -429,14 +429,15 @@ const API_BASE_URL = "DataListView/";
var JUST_DELETED = false;
export default {
// beforeRouteEnter(to, from, next) {
// var ltKeysRequired = ["DataListView", "GridFilterName"];
// window.$gz.locale.fetch(ltKeysRequired).then(next);
// console.log("ay-data-list-view::beforeRouteEnter hit");
// next();
// },
//unsaved changes are actually valid for this form so no need to warn
beforeRouteLeave(to, from, next) {
console.log("ay-data-list-view::beforeRouteLeave hit");
var vm = this;
if (this.formState.dirty && !JUST_DELETED) {
console.log("before route leave: setting to unsaved list view ");
//Put in unsaved listview
var formSettings = window.$gz.form.getFormSettings(vm.formKey);
formSettings.saved.dataTable.unsavedListView = JSON.stringify(
@@ -455,15 +456,14 @@ export default {
},
created() {
var vm = this;
console.log("ay-data-list-view::created hit");
//set route values in data object so init form can handle
vm.dataListKey = this.$route.params.dataListKey;
vm.listViewId = this.$route.params.listViewId;
vm.formKey = this.$route.params.formKey;
//console.log("Created TOP calling initform...");
initForm(vm)
.then(() => {
//console.log("CREATED: back from initform");
// path: "/ay-data-list-view/:listViewId/:dataListKey",
vm.formState.ready = true;
@@ -755,9 +755,15 @@ export default {
window.$gz.form.setErrorBoxErrors(vm);
} else {
//Logic for detecting if a post or put: if id then it was a post, if no id then it was a put
// debugger;
if (res.data.id) {
//Handle "post" of new record (CREATE)
console.log(
"ay-data-list-view::submit, updating form settings, res.data.id is: " +
res.data.id
);
//Update the formSettings now that it's saved
var formSettings = window.$gz.form.getFormSettings(vm.formKey);
formSettings.temp.cachedListview = lvSave.listView;
@@ -765,6 +771,13 @@ export default {
formSettings.saved.dataTable.listViewId = res.data.id;
window.$gz.form.setFormSettings(vm.formKey, formSettings);
//No longer dirty
window.$gz.form.setFormState({
vm: vm,
dirty: false
//, readOnly: res.readOnly ? true : false
});
//change url to new record
vm.$router.replace(
window.$gz.api.replaceAfterLastSlash(

View File

@@ -500,14 +500,11 @@ export default {
//Logic for detecting if a post or put: if id then it was a post, if no id then it was a put
if (res.data.id) {
//Handle "post" of new record (CREATE)
// vm.obj = res.data;
// window.$gz.form.setFormState({
// vm: vm,
// dirty: false,
// readOnly: res.readOnly ? true : false
// });
//change url to new record in history and trigger navigate but with the id at the end instead of zero:
//change url to new record in history
//NOTE: will not cause a new navigate, almost nothing does unless forced with a KEY property or using router.GO()
//but will trigger navigation guard beforeRouteUpdate which we use here in this form
//to fetch data again
vm.$router.replace(
vm.$route.fullPath.slice(0, -1) + res.data.id
);