This commit is contained in:
2021-04-06 17:25:10 +00:00
parent acf202a897
commit 7eb993e23f
3 changed files with 38 additions and 7 deletions

View File

@@ -68,6 +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"
-->
{{ currentState }}
</div>
</template>
<script>
@@ -147,11 +148,39 @@ export default {
};
},
canAdd: function() {
return (
!this.value.isLocked &&
this.pvm.rights.change &&
this.pvm.subRights.states.create
);
//first check most obvious disqualifying properties
if (!this.pvm.rights.change || !this.pvm.subRights.states.create) {
return false;
}
//not currently locked, user has rights to do it so allow it
if (!this.value.isLocked) {
return true;
}
//locked, confirm if user can change it
//if any role then no problem
//ok, only thing left to check is if the current user can unlock this
//get remove roles required for current state
let cs = this.currentState;
if (cs.removeRoles == null || cs.removeRoles == 0) {
//no state set yet
return true;
}
//ok, need to check the role here against current user roles to see if this is valid
if (window.$gz.role.hasRole(cs.removeRoles)) {
return true;
}
//failsafe
return false;
// return (
// !this.value.isLocked &&
// this.pvm.rights.change &&
// this.pvm.subRights.states.create
// );
}
}
};