This commit is contained in:
@@ -5,7 +5,7 @@ PRIORITY - ALWAYS Lowest level stuff first, i.e. TODO at server, api route chang
|
||||
|
||||
|
||||
todo: if a post or put from the client receives the full record back then make sure not fetching it again redundantly see user form and widget form that seem to do this on submit
|
||||
I think it's ok, but double check for both new post and put
|
||||
POST -> Get -> Get all firing
|
||||
|
||||
todo: what is method "OPTIONS" in api calls all the time? I think it's CORS related but ... *every* time? weird
|
||||
disable cache causing it?
|
||||
|
||||
@@ -233,6 +233,7 @@
|
||||
const FORM_KEY = "user-edit";
|
||||
const API_BASE_URL = "user/";
|
||||
const FORM_CUSTOM_TEMPLATE_KEY = "User";
|
||||
let InternalRouteChange = false;
|
||||
|
||||
export default {
|
||||
async created() {
|
||||
@@ -245,6 +246,7 @@ export default {
|
||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||
//id 0 means create a new record don't load one
|
||||
if (vm.$route.params.recordid != 0) {
|
||||
console.trace("created, calling get data from api irc=",InternalRouteChange)
|
||||
vm.getDataFromApi(vm.$route.params.recordid);
|
||||
} else {
|
||||
//setup for new record
|
||||
@@ -267,12 +269,16 @@ export default {
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
//This triggers a fetch of the data when the ID value changes on the route
|
||||
//which happens on duplicate, submit new record and change of active record id (backward nav/forward nav etc)
|
||||
if (to.params.recordid != 0) {
|
||||
console.trace("beforeRouteUpdate irc=",InternalRouteChange)
|
||||
if (!InternalRouteChange && to.params.recordid != 0) {
|
||||
console.trace("beforeRouteUpdate, calling get data from api irc=",InternalRouteChange)
|
||||
this.getDataFromApi(to.params.recordid);
|
||||
}
|
||||
next();
|
||||
// react to route changes...
|
||||
// don't forget to call next()
|
||||
//reset flag
|
||||
InternalRouteChange = false;
|
||||
},
|
||||
async beforeRouteLeave(to, from, next) {
|
||||
if (!this.formState.dirty || JUST_DELETED) {
|
||||
@@ -469,6 +475,7 @@ export default {
|
||||
//change url to new record in history
|
||||
//NOTE: will not cause a page re-render, 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 freshly
|
||||
InternalRouteChange = true;
|
||||
vm.$router.replace(vm.$route.fullPath.slice(0, -1) + res.data.id);
|
||||
} else {
|
||||
//Handle "put" of an existing record (UPDATE)
|
||||
@@ -576,7 +583,7 @@ async function clickHandler(menuItem) {
|
||||
break;
|
||||
case "new":
|
||||
m.vm.$router.push({
|
||||
name: "user-edit",
|
||||
name: "adm-usr",
|
||||
params: { recordid: 0, new: true }
|
||||
});
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user