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

@@ -74,7 +74,7 @@ export default {
}, },
canAdd: function() { canAdd: function() {
return ( return (
!this.value.isLocked && !this.value.isLockedAtServer &&
this.pvm.rights.change && this.pvm.rights.change &&
this.pvm.subRights.scheduledUsers.create this.pvm.subRights.scheduledUsers.create
); );

View File

@@ -4,12 +4,12 @@
<template v-if="hasState"> <template v-if="hasState">
<br /> <br />
<span class="text-h6">{{ currentState.name }}</span> <span class="text-h6">{{ pvm.currentState.name }}</span>
<v-icon :color="currentState.color" class="ml-4">$ayiFlag</v-icon> <v-icon :color="pvm.currentState.color" class="ml-4">$ayiFlag</v-icon>
<v-icon color="primary" v-if="currentState.locked" class="ml-4" <v-icon color="primary" v-if="pvm.currentState.locked" class="ml-4"
>$ayiLock</v-icon >$ayiLock</v-icon
> >
<v-icon color="primary" v-if="currentState.completed" class="ml-4" <v-icon color="primary" v-if="pvm.currentState.completed" class="ml-4"
>$ayiCheckCircle</v-icon >$ayiCheckCircle</v-icon
> >
</template> </template>
@@ -68,7 +68,7 @@
todo: it must be clear to user why they can not change if they have too low a role to change, perhaps text under state instead of selector box that says "Only select roles can change this state" todo: it must be clear to user why they can not change if they have too low a role to change, perhaps text under state instead of selector box that says "Only select roles can change this state"
--> -->
{{ currentState }} {{ pvm.currentState }}
</div> </div>
</template> </template>
<script> <script>
@@ -122,31 +122,31 @@ export default {
hasState() { hasState() {
return this.value.states != null && this.value.states.length > 0; return this.value.states != null && this.value.states.length > 0;
}, },
currentState() { // currentState() {
//return actual status object from top level shell based on current state // //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 state is unknown then it should return a placeholder dummy state showing an error condition or empty I guess
if (this.value.states != null) { // if (this.value.states != null) {
//find it in the status collection // //find it in the status collection
//and return here // //and return here
let laststate = this.value.states[this.value.states.length - 1]; // let laststate = this.value.states[this.value.states.length - 1];
let found = this.pvm.selectLists.wostatus.find( // let found = this.pvm.selectLists.wostatus.find(
z => z.id == laststate.workOrderStatusId // z => z.id == laststate.workOrderStatusId
); // );
if (found) { // if (found) {
return found; // return found;
} // }
} // }
//default // //default
return { // return {
id: 0, // id: 0,
name: "NOT SET YET", // name: "NOT SET YET",
active: true, // active: true,
color: "#ffffff", //invisible // color: "#ffffff", //invisible
completed: false, // completed: false,
locked: false // locked: false
}; // };
}, // },
canAdd: function() { canAdd: function() {
//first check most obvious disqualifying properties //first check most obvious disqualifying properties
if (!this.pvm.rights.change || !this.pvm.subRights.states.create) { if (!this.pvm.rights.change || !this.pvm.subRights.states.create) {
@@ -154,7 +154,7 @@ export default {
} }
//not currently locked, user has rights to do it so allow it //not currently locked, user has rights to do it so allow it
if (!this.value.isLocked) { if (!this.value.isLockedAtServer) {
return true; return true;
} }
@@ -163,7 +163,7 @@ export default {
//ok, only thing left to check is if the current user can unlock this //ok, only thing left to check is if the current user can unlock this
//get remove roles required for current state //get remove roles required for current state
let cs = this.currentState; let cs = pvm.currentState;
if (cs.removeRoles == null || cs.removeRoles == 0) { if (cs.removeRoles == null || cs.removeRoles == 0) {
//no state set yet //no state set yet
return true; return true;
@@ -174,13 +174,7 @@ export default {
return true; return true;
} }
//failsafe
return false; return false;
// return (
// !this.value.isLocked &&
// this.pvm.rights.change &&
// this.pvm.subRights.states.create
// );
} }
} }
}; };

View File

@@ -171,7 +171,7 @@ export default {
items: [], items: [],
states: [], states: [],
isDirty: false, isDirty: false,
isLocked: false isLockedAtServer: false
} }
}, },
formState: { formState: {
@@ -312,6 +312,31 @@ export default {
return 0; return 0;
} }
return this.obj.items.length; 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: { methods: {
@@ -406,7 +431,10 @@ export default {
let fail = false; let fail = false;
//STATE first if unlocking only //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); fail = await saveState(vm);
} }
@@ -416,7 +444,7 @@ export default {
//STATE last normally in case it locks //STATE last normally in case it locks
//or is completed //or is completed
if (!this.obj.isLocked) { if (!this.obj.isLockedAtServer) {
fail = await saveState(vm); fail = await saveState(vm);
} }
@@ -572,6 +600,8 @@ 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
vm.obj.isLockedAtServer = vm.currentState.locked;
} }
} }
} }
@@ -584,7 +614,7 @@ async function saveState(vm) {
function setSubRights(vm) { function setSubRights(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, 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, isDirty: false,
isLocked: false isLockedAtServer: false
}; };