This commit is contained in:
2021-04-13 00:29:42 +00:00
parent 351d091f22
commit a046322b14
4 changed files with 65 additions and 25 deletions

View File

@@ -60,7 +60,7 @@ todo: cleanup unnecessary use of a ayatype access inside the Methods of objects
todo: use const, not let unless need to reassign the variable
Going to need a case by case through all uses but it's a very important precaution so code it that way now for all new code
todo: gzdecimal triggering dirty just by clicking into and out of a field witha value in it.
also, it sometimes shows without the decimal then with the decimal for editing then without, it's crazy
the decimal thing is probbly what's triggering the dirty change.
@@ -226,6 +226,9 @@ todo: many biz objects are not using new PUT methodology
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
- 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
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
(or let error from server handle it?? Not a first class UI experience though and might be a quite common mistake)

View File

@@ -311,7 +311,7 @@ and it's probably not a big list to fill anyway
},
canAdd: function() {
return (
!this.value.isLockedAtServer &&
!this.pvm.formState.readOnly &&
this.pvm.rights.change &&
this.pvm.subRights.items.create
);
@@ -319,7 +319,7 @@ and it's probably not a big list to fill anyway
canDelete: function() {
return (
this.activeItemIndex != null &&
!this.value.isLockedAtServer &&
!this.pvm.formState.readOnly &&
this.pvm.rights.change &&
this.pvm.subRights.items.delete
);

View File

@@ -111,8 +111,10 @@ export default {
userId: window.$gz.store.state.userId,
created: window.$gz.locale.nowUTC8601String()
});
//flag header itself as dirty
this.value.isDirty = true;
//this.value.isDirty = true; //Not sure why this is here
//flag form dirty
this.pvm.formState.dirty = true;
}

View File

@@ -53,7 +53,7 @@ export default {
GzWoItems
},
async created() {
let vm = this;
const vm = this;
try {
await initForm(vm);
@@ -90,7 +90,7 @@ export default {
//preset object so do things normally done in getdata
generateMenu(vm);
//update which areas are available to user
setSubRights(vm);
setAllRights(vm);
} catch (error) {
window.$gz.errorHandler.handleFormError(error, vm);
} finally {
@@ -258,7 +258,7 @@ export default {
}
//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");
} else {
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) {
//find it in the status collection
//and return here
let laststate = this.obj.states[this.obj.states.length - 1];
let found = this.selectLists.wostatus.find(
const laststate = this.obj.states[this.obj.states.length - 1];
const found = this.selectLists.wostatus.find(
z => z.id == laststate.workOrderStatusId
);
if (found) {
@@ -341,14 +341,14 @@ export default {
fieldValueChanged(ref) {
if (
this.formState.ready &&
!this.formState.loading &&
!this.formState.readOnly
!this.formState.loading
//&& !this.formState.readOnly //commented out to not affect state setting, I think it's redundant
) {
window.$gz.form.fieldValueChanged(this, ref);
}
},
async getDataFromApi(recordId) {
let vm = this;
const vm = this;
window.$gz.form.setFormState({
vm: vm,
loading: true
@@ -356,11 +356,11 @@ export default {
if (!recordId) {
throw new Error(FORM_KEY + "::getDataFromApi -> Missing recordID!");
}
let url = API_BASE_URL + recordId;
const url = API_BASE_URL + recordId;
try {
window.$gz.form.deleteAllErrorBoxErrors(vm);
let res = await window.$gz.api.get(url);
const res = await window.$gz.api.get(url);
if (res.error) {
//Not found?
@@ -374,7 +374,7 @@ export default {
//modify the menu as necessary
generateMenu(vm);
//update which areas are available to user
setSubRights(vm);
setAllRights(vm);
//Update the form status
window.$gz.form.setFormState({
@@ -394,7 +394,7 @@ export default {
}
},
async submit() {
let vm = this;
const vm = this;
if (vm.canSave == false) {
return;
}
@@ -404,7 +404,7 @@ export default {
vm: vm,
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
window.$gz.form.deleteAllErrorBoxErrors(vm);
@@ -419,6 +419,7 @@ export default {
//items in correct order
//########################################################
let noProblem = true;
const isPost = vm.obj.id == 0;
//UNSAVED HEADER MUST BE FIRST
//(otherwise there's nothing to hang the other things off of)
@@ -433,6 +434,9 @@ export default {
if (this.obj.isLockedAtServer) {
noProblem = await saveState(vm);
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 ###############
@@ -464,10 +468,12 @@ export default {
//in case it locks or is completed
if (!stateSaved && noProblem) {
noProblem = await saveState(vm);
setAllRights(vm);
}
//## ALL PARTIAL UPDATES SUCCEEDED
if (!noProblem) {
console.error("noProblem is not true, error!");
//this assumes error is already displayed from save op
window.$gz.form.setFormState({
vm: vm,
@@ -475,11 +481,23 @@ export default {
valid: false
});
} else {
window.$gz.form.setFormState({
vm: vm,
dirty: false,
valid: true
});
if (isPost) {
//nav to id'd url
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
@@ -646,7 +664,7 @@ async function saveState(vm) {
//CHANGED?
let totalItems = vm.obj.states.length;
if (totalItems == 0) {
return;
return true;
}
for (let i = 0; i < totalItems; i++) {
let o = vm.obj.states[i];
@@ -658,6 +676,7 @@ async function saveState(vm) {
return false;
} else {
vm.obj.states[i] = res.data;
//set locked status of entire wo now
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
//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);
}
/*
*/
}