This commit is contained in:
2021-04-06 18:27:36 +00:00
parent 7eb993e23f
commit 91cebab9d4
3 changed files with 67 additions and 43 deletions

View File

@@ -171,7 +171,7 @@ export default {
items: [],
states: [],
isDirty: false,
isLocked: false
isLockedAtServer: false
}
},
formState: {
@@ -312,6 +312,31 @@ export default {
return 0;
}
return this.obj.items.length;
},
currentState() {
//return actual status object from top level shell based on current state
//if state is unknown then it should return a placeholder dummy state showing an error condition or empty I guess
if (this.obj.states != null) {
//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(
z => z.id == laststate.workOrderStatusId
);
if (found) {
return found;
}
}
//default
return {
id: 0,
name: "NOT SET YET",
active: true,
color: "#ffffff", //invisible
completed: false,
locked: false
};
}
},
methods: {
@@ -406,7 +431,10 @@ export default {
let fail = false;
//STATE first if unlocking only
if (this.obj.isLocked) {
//if moving to another locked state this will block further updates below but we're accepting that
//and user can unlock first to finish updating
if (this.obj.isLockedAtServer) {
console.log("savestateFirst");
fail = await saveState(vm);
}
@@ -416,7 +444,7 @@ export default {
//STATE last normally in case it locks
//or is completed
if (!this.obj.isLocked) {
if (!this.obj.isLockedAtServer) {
fail = await saveState(vm);
}
@@ -572,6 +600,8 @@ 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;
}
}
}
@@ -584,7 +614,7 @@ async function saveState(vm) {
function setSubRights(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, descendents still need to first check if workorder isLocked and rights are read only etc before this level is checked
//## NOTE: these are subrights only, descendents still need to first check if workorder isLockedAtServer and rights are read only etc before this level is checked
/*
*/
}
@@ -982,7 +1012,7 @@ Example workorder
}
],
isDirty: false,
isLocked: false
isLockedAtServer: false
};