diff --git a/ayanova/src/components/work-order-state.vue b/ayanova/src/components/work-order-state.vue index 686ec81d..08d2dabc 100644 --- a/ayanova/src/components/work-order-state.vue +++ b/ayanova/src/components/work-order-state.vue @@ -183,27 +183,29 @@ export default { return ret; }, canAdd: function() { - //first check most obvious disqualifying properties + //first check most obvious disqualifying property which is that user is not allowed to change at all if (!this.pvm.rights.change) { return false; } - //not currently locked, user has rights to do it so allow it - if (!this.value.isLockedAtServer) { - return true; - } - //locked, confirm if user can change it - //if any role then no problem - //only thing left to check is if the current user can unlock this - //get remove roles required for current state + + //FACT: isLockedAtServer is *only* set when the status is a locking status, no other time, it's poorly named + //and should be isSetToALockedStatus but here we are, it's post release, can't change it now + + //for purposes of making changes here it doesn't really matter if it's locked status or not, all that needs to be known is + //can the user remove this status const cs = this.pvm.currentState; - if (cs.removeRoles == null || cs.removeRoles == 0) { - //no state set yet + + if (cs == null || cs.removeRoles == null || cs.removeRoles == 0) { + //no state set yet or no remove roles set so nothing to check against return true; } - //need to check the role here against current user roles to see if this is valid + + //We have a state set already, need to check the role here against current user roles to see if this user is allowed to add a state if (window.$gz.role.hasRole(cs.removeRoles)) { return true; } + + //it's locked and there seems to be no reason to allow a change so no return false; }, allErrors: function() {