diff --git a/ayanova/src/views/svc-workorder.vue b/ayanova/src/views/svc-workorder.vue index 0aa5fc32..5819d30a 100644 --- a/ayanova/src/views/svc-workorder.vue +++ b/ayanova/src/views/svc-workorder.vue @@ -58,8 +58,8 @@ export default { try { await initForm(vm); + //set base rights vm.rights = window.$gz.role.getRights(window.$gz.type.WorkOrder); - vm.formState.readOnly = !vm.rights.change; window.$gz.eventBus.$on("menu-click", clickHandler); //id 0 means create a new record don't load one @@ -87,10 +87,9 @@ export default { dirty: false, valid: true }); - //preset object so do things normally done in getdata - generateMenu(vm); - //update which areas are available to user - setAllRights(vm); + + //update which areas are available to user and force generate menu + updateRights(vm, true); } catch (error) { window.$gz.errorHandler.handleFormError(error, vm); } finally { @@ -339,11 +338,7 @@ export default { return window.$gz.form; }, fieldValueChanged(ref) { - if ( - this.formState.ready && - !this.formState.loading - //&& !this.formState.readOnly //commented out to not affect state setting, I think it's redundant - ) { + if (this.formState.ready && !this.formState.loading) { window.$gz.form.fieldValueChanged(this, ref); } }, @@ -374,7 +369,7 @@ export default { //modify the menu as necessary generateMenu(vm); //update which areas are available to user - setAllRights(vm); + updateRights(vm); //Update the form status window.$gz.form.setFormState({ @@ -436,7 +431,7 @@ export default { 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); + updateRights(vm); } //############# DELETE GRAPH ############### @@ -468,7 +463,7 @@ export default { //in case it locks or is completed if (!stateSaved && noProblem) { noProblem = await saveState(vm); - setAllRights(vm); + updateRights(vm); } //## ALL PARTIAL UPDATES SUCCEEDED @@ -828,19 +823,18 @@ function displayResError(vm, res) { ///////////////////////////// // // -function setAllRights(vm) { +function updateRights(vm, forceGenerateMenu) { //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, readOnly overrides all const readOnlyBefore = vm.formState.readOnly; if (vm.obj.isLockedAtServer) { + //locked is always read only (with state exception for sufficient roles) vm.formState.readOnly = true; } else { - //state may have changed to open so set rights again if allowed here + //state may have changed so update readOnly vm.formState.readOnly = !vm.rights.change; } - if (readOnlyBefore != vm.formState.readOnly) { + if (readOnlyBefore != vm.formState.readOnly || forceGenerateMenu === true) { generateMenu(vm); }