This commit is contained in:
@@ -55,6 +55,11 @@
|
||||
<v-list-item-action> </v-list-item-action>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
<div>
|
||||
allstates:
|
||||
{{ value.states }}
|
||||
</div>
|
||||
<div>currentstate:{{ pvm.currentState }}</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -66,9 +71,8 @@
|
||||
TODO: POC for now don't worry about rights to unset / set certain states, just hook it up for testing
|
||||
|
||||
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: view state history
|
||||
-->
|
||||
{{ pvm.currentState }}
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
@@ -100,6 +104,17 @@ export default {
|
||||
methods: {
|
||||
addState() {
|
||||
if (this.selectedStatus != null) {
|
||||
//first remove any other non saved states in collection, no need to send them to the server if there was multiple state changes since last save
|
||||
this.value.states = this.value.states.filter(
|
||||
z => z.concurrency != null
|
||||
);
|
||||
|
||||
//is it a different state?
|
||||
if (this.selectedStatus == this.pvm.currentState.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
//push in new state
|
||||
this.value.states.push({
|
||||
workOrderId: this.value.id,
|
||||
workOrderStatusId: this.selectedStatus,
|
||||
@@ -163,7 +178,7 @@ export default {
|
||||
|
||||
//ok, only thing left to check is if the current user can unlock this
|
||||
//get remove roles required for current state
|
||||
let cs = pvm.currentState;
|
||||
let cs = this.pvm.currentState;
|
||||
if (cs.removeRoles == null || cs.removeRoles == 0) {
|
||||
//no state set yet
|
||||
return true;
|
||||
|
||||
@@ -433,9 +433,11 @@ export default {
|
||||
//STATE first if unlocking only
|
||||
//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
|
||||
let stateSaved = false;
|
||||
if (this.obj.isLockedAtServer) {
|
||||
console.log("savestateFirst");
|
||||
fail = await saveState(vm);
|
||||
stateSaved = true;
|
||||
}
|
||||
|
||||
//WOITEMS
|
||||
@@ -444,16 +446,25 @@ export default {
|
||||
|
||||
//STATE last normally in case it locks
|
||||
//or is completed
|
||||
if (!this.obj.isLockedAtServer) {
|
||||
if (!stateSaved && !fail && !this.obj.isLockedAtServer) {
|
||||
fail = await saveState(vm);
|
||||
}
|
||||
|
||||
//## ALL PARTIAL UPDATES SUCCEEDED
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
valid: true
|
||||
});
|
||||
if (fail) {
|
||||
//this assumes error is already displayed from save op
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: true,
|
||||
valid: false
|
||||
});
|
||||
} else {
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
valid: true
|
||||
});
|
||||
}
|
||||
|
||||
//TODO: Nav to this again if it's a post
|
||||
|
||||
|
||||
Reference in New Issue
Block a user