This commit is contained in:
@@ -226,6 +226,9 @@ todo: many biz objects are not using new PUT methodology
|
|||||||
|
|
||||||
|
|
||||||
CURRENTLY DOING: make from new
|
CURRENTLY DOING: make from new
|
||||||
|
current issues:
|
||||||
|
setting to locked state does not lock in UI even after save
|
||||||
|
I'm thinking it should lock after save but not before on selection and add to wo
|
||||||
|
|
||||||
BIG PICTURE STUFF
|
BIG PICTURE STUFF
|
||||||
- ability to create from nothing implement whatever is minimally necessary to get it to work and do full crud test at all layers
|
- ability to create from nothing implement whatever is minimally necessary to get it to work and do full crud test at all layers
|
||||||
@@ -239,6 +242,10 @@ BIG PICTURE STUFF
|
|||||||
|
|
||||||
|
|
||||||
CURRENT ACTIONABLE TODOS
|
CURRENT ACTIONABLE TODOS
|
||||||
|
todo: if islockedatserver is true I am still attempting to support editing, but it's a bit mixed up as the user would need to set the status to an unlocked state as well
|
||||||
|
current plan sucks. Instead it should be treated entirely as readonly if islocked at server with the sole exception of the state so the user is forced to
|
||||||
|
set an unlocked status, SAVE, *THEN* then can edit at will.
|
||||||
|
Trying to support both at once would be a mess.
|
||||||
|
|
||||||
todo: need to add a popup error if attempting to save from locked to locked state and there are other changes that need to be saved
|
todo: need to add a popup error if attempting to save from locked to locked state and there are other changes that need to be saved
|
||||||
(or let error from server handle it?? Not a first class UI experience though and might be a quite common mistake)
|
(or let error from server handle it?? Not a first class UI experience though and might be a quite common mistake)
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ and it's probably not a big list to fill anyway
|
|||||||
},
|
},
|
||||||
canAdd: function() {
|
canAdd: function() {
|
||||||
return (
|
return (
|
||||||
!this.value.isLockedAtServer &&
|
!this.pvm.formState.readOnly &&
|
||||||
this.pvm.rights.change &&
|
this.pvm.rights.change &&
|
||||||
this.pvm.subRights.items.create
|
this.pvm.subRights.items.create
|
||||||
);
|
);
|
||||||
@@ -319,7 +319,7 @@ and it's probably not a big list to fill anyway
|
|||||||
canDelete: function() {
|
canDelete: function() {
|
||||||
return (
|
return (
|
||||||
this.activeItemIndex != null &&
|
this.activeItemIndex != null &&
|
||||||
!this.value.isLockedAtServer &&
|
!this.pvm.formState.readOnly &&
|
||||||
this.pvm.rights.change &&
|
this.pvm.rights.change &&
|
||||||
this.pvm.subRights.items.delete
|
this.pvm.subRights.items.delete
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -111,8 +111,10 @@ export default {
|
|||||||
userId: window.$gz.store.state.userId,
|
userId: window.$gz.store.state.userId,
|
||||||
created: window.$gz.locale.nowUTC8601String()
|
created: window.$gz.locale.nowUTC8601String()
|
||||||
});
|
});
|
||||||
|
|
||||||
//flag header itself as dirty
|
//flag header itself as dirty
|
||||||
this.value.isDirty = true;
|
//this.value.isDirty = true; //Not sure why this is here
|
||||||
|
|
||||||
//flag form dirty
|
//flag form dirty
|
||||||
this.pvm.formState.dirty = true;
|
this.pvm.formState.dirty = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export default {
|
|||||||
GzWoItems
|
GzWoItems
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
let vm = this;
|
const vm = this;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await initForm(vm);
|
await initForm(vm);
|
||||||
@@ -90,7 +90,7 @@ export default {
|
|||||||
//preset object so do things normally done in getdata
|
//preset object so do things normally done in getdata
|
||||||
generateMenu(vm);
|
generateMenu(vm);
|
||||||
//update which areas are available to user
|
//update which areas are available to user
|
||||||
setSubRights(vm);
|
setAllRights(vm);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
window.$gz.errorHandler.handleFormError(error, vm);
|
window.$gz.errorHandler.handleFormError(error, vm);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -258,7 +258,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//enable / disable save button
|
//enable / disable save button
|
||||||
if (val.dirty && val.valid && !val.readOnly) {
|
if (val.dirty && val.valid) {
|
||||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
|
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
|
||||||
} else {
|
} else {
|
||||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||||
@@ -290,8 +290,8 @@ export default {
|
|||||||
if (this.obj.states != null && this.obj.states.length > 0) {
|
if (this.obj.states != null && this.obj.states.length > 0) {
|
||||||
//find it in the status collection
|
//find it in the status collection
|
||||||
//and return here
|
//and return here
|
||||||
let laststate = this.obj.states[this.obj.states.length - 1];
|
const laststate = this.obj.states[this.obj.states.length - 1];
|
||||||
let found = this.selectLists.wostatus.find(
|
const found = this.selectLists.wostatus.find(
|
||||||
z => z.id == laststate.workOrderStatusId
|
z => z.id == laststate.workOrderStatusId
|
||||||
);
|
);
|
||||||
if (found) {
|
if (found) {
|
||||||
@@ -341,14 +341,14 @@ export default {
|
|||||||
fieldValueChanged(ref) {
|
fieldValueChanged(ref) {
|
||||||
if (
|
if (
|
||||||
this.formState.ready &&
|
this.formState.ready &&
|
||||||
!this.formState.loading &&
|
!this.formState.loading
|
||||||
!this.formState.readOnly
|
//&& !this.formState.readOnly //commented out to not affect state setting, I think it's redundant
|
||||||
) {
|
) {
|
||||||
window.$gz.form.fieldValueChanged(this, ref);
|
window.$gz.form.fieldValueChanged(this, ref);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getDataFromApi(recordId) {
|
async getDataFromApi(recordId) {
|
||||||
let vm = this;
|
const vm = this;
|
||||||
window.$gz.form.setFormState({
|
window.$gz.form.setFormState({
|
||||||
vm: vm,
|
vm: vm,
|
||||||
loading: true
|
loading: true
|
||||||
@@ -356,11 +356,11 @@ export default {
|
|||||||
if (!recordId) {
|
if (!recordId) {
|
||||||
throw new Error(FORM_KEY + "::getDataFromApi -> Missing recordID!");
|
throw new Error(FORM_KEY + "::getDataFromApi -> Missing recordID!");
|
||||||
}
|
}
|
||||||
let url = API_BASE_URL + recordId;
|
const url = API_BASE_URL + recordId;
|
||||||
try {
|
try {
|
||||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||||
|
|
||||||
let res = await window.$gz.api.get(url);
|
const res = await window.$gz.api.get(url);
|
||||||
|
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
//Not found?
|
//Not found?
|
||||||
@@ -374,7 +374,7 @@ export default {
|
|||||||
//modify the menu as necessary
|
//modify the menu as necessary
|
||||||
generateMenu(vm);
|
generateMenu(vm);
|
||||||
//update which areas are available to user
|
//update which areas are available to user
|
||||||
setSubRights(vm);
|
setAllRights(vm);
|
||||||
|
|
||||||
//Update the form status
|
//Update the form status
|
||||||
window.$gz.form.setFormState({
|
window.$gz.form.setFormState({
|
||||||
@@ -394,7 +394,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async submit() {
|
async submit() {
|
||||||
let vm = this;
|
const vm = this;
|
||||||
if (vm.canSave == false) {
|
if (vm.canSave == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -404,7 +404,7 @@ export default {
|
|||||||
vm: vm,
|
vm: vm,
|
||||||
loading: true
|
loading: true
|
||||||
});
|
});
|
||||||
//let url = API_BASE_URL; // + vm.$route.params.recordid;
|
//const url = API_BASE_URL; // + vm.$route.params.recordid;
|
||||||
//clear any errors vm might be around from previous submit
|
//clear any errors vm might be around from previous submit
|
||||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||||
|
|
||||||
@@ -419,6 +419,7 @@ export default {
|
|||||||
//items in correct order
|
//items in correct order
|
||||||
//########################################################
|
//########################################################
|
||||||
let noProblem = true;
|
let noProblem = true;
|
||||||
|
const isPost = vm.obj.id == 0;
|
||||||
|
|
||||||
//UNSAVED HEADER MUST BE FIRST
|
//UNSAVED HEADER MUST BE FIRST
|
||||||
//(otherwise there's nothing to hang the other things off of)
|
//(otherwise there's nothing to hang the other things off of)
|
||||||
@@ -433,6 +434,9 @@ export default {
|
|||||||
if (this.obj.isLockedAtServer) {
|
if (this.obj.isLockedAtServer) {
|
||||||
noProblem = await saveState(vm);
|
noProblem = await saveState(vm);
|
||||||
stateSaved = true;
|
stateSaved = true;
|
||||||
|
//update which areas are available to user
|
||||||
|
//which may have changed due to state being saved (saveState sets the current islocked value)
|
||||||
|
setAllRights(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
//############# DELETE GRAPH ###############
|
//############# DELETE GRAPH ###############
|
||||||
@@ -464,10 +468,12 @@ export default {
|
|||||||
//in case it locks or is completed
|
//in case it locks or is completed
|
||||||
if (!stateSaved && noProblem) {
|
if (!stateSaved && noProblem) {
|
||||||
noProblem = await saveState(vm);
|
noProblem = await saveState(vm);
|
||||||
|
setAllRights(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
//## ALL PARTIAL UPDATES SUCCEEDED
|
//## ALL PARTIAL UPDATES SUCCEEDED
|
||||||
if (!noProblem) {
|
if (!noProblem) {
|
||||||
|
console.error("noProblem is not true, error!");
|
||||||
//this assumes error is already displayed from save op
|
//this assumes error is already displayed from save op
|
||||||
window.$gz.form.setFormState({
|
window.$gz.form.setFormState({
|
||||||
vm: vm,
|
vm: vm,
|
||||||
@@ -475,11 +481,23 @@ export default {
|
|||||||
valid: false
|
valid: false
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
window.$gz.form.setFormState({
|
if (isPost) {
|
||||||
vm: vm,
|
//nav to id'd url
|
||||||
dirty: false,
|
|
||||||
valid: true
|
this.$router.push({
|
||||||
});
|
name: "workorder-edit",
|
||||||
|
params: {
|
||||||
|
recordid: vm.obj.id,
|
||||||
|
obj: vm.obj // Pass data object to new form
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
dirty: false,
|
||||||
|
valid: true
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Nav to this again if it's a post
|
//TODO: Nav to this again if it's a post
|
||||||
@@ -646,7 +664,7 @@ async function saveState(vm) {
|
|||||||
//CHANGED?
|
//CHANGED?
|
||||||
let totalItems = vm.obj.states.length;
|
let totalItems = vm.obj.states.length;
|
||||||
if (totalItems == 0) {
|
if (totalItems == 0) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
for (let i = 0; i < totalItems; i++) {
|
for (let i = 0; i < totalItems; i++) {
|
||||||
let o = vm.obj.states[i];
|
let o = vm.obj.states[i];
|
||||||
@@ -658,6 +676,7 @@ async function saveState(vm) {
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
vm.obj.states[i] = res.data;
|
vm.obj.states[i] = res.data;
|
||||||
|
|
||||||
//set locked status of entire wo now
|
//set locked status of entire wo now
|
||||||
vm.obj.isLockedAtServer = vm.currentState.locked;
|
vm.obj.isLockedAtServer = vm.currentState.locked;
|
||||||
}
|
}
|
||||||
@@ -809,10 +828,22 @@ function displayResError(vm, res) {
|
|||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
function setSubRights(vm) {
|
function setAllRights(vm) {
|
||||||
//determine rights to each which sections are hidden due to form customized out or rights / roles
|
//determine rights to each which sections are hidden due to form customized out or rights / roles
|
||||||
//todo: determine this and set accordingly, for now all set to available true during init
|
//todo: determine this and set accordingly, for now all set to available true during init
|
||||||
//## NOTE: these are subrights only, descendants still need to first check if workorder isLockedAtServer and rights are read only etc before this level is checked
|
//## NOTE: these are subrights only, readOnly overrides all
|
||||||
|
const readOnlyBefore = vm.formState.readOnly;
|
||||||
|
if (vm.obj.isLockedAtServer) {
|
||||||
|
vm.formState.readOnly = true;
|
||||||
|
} else {
|
||||||
|
//state may have changed to open so set rights again if allowed here
|
||||||
|
vm.formState.readOnly = !vm.rights.change;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (readOnlyBefore != vm.formState.readOnly) {
|
||||||
|
generateMenu(vm);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user