This commit is contained in:
2021-04-06 19:27:02 +00:00
parent 91cebab9d4
commit 4afb02c8cd
2 changed files with 35 additions and 9 deletions

View File

@@ -55,6 +55,11 @@
<v-list-item-action> </v-list-item-action> <v-list-item-action> </v-list-item-action>
</template> </template>
</v-autocomplete> </v-autocomplete>
<div>
allstates:
{{ value.states }}
</div>
<div>currentstate:{{ pvm.currentState }}</div>
</div> </div>
</template> </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: 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: 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> </div>
</template> </template>
<script> <script>
@@ -100,6 +104,17 @@ export default {
methods: { methods: {
addState() { addState() {
if (this.selectedStatus != null) { 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({ this.value.states.push({
workOrderId: this.value.id, workOrderId: this.value.id,
workOrderStatusId: this.selectedStatus, workOrderStatusId: this.selectedStatus,
@@ -163,7 +178,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 = pvm.currentState; let cs = this.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;

View File

@@ -433,9 +433,11 @@ export default {
//STATE first if unlocking only //STATE first if unlocking only
//if moving to another locked state this will block further updates below but we're accepting that //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 //and user can unlock first to finish updating
let stateSaved = false;
if (this.obj.isLockedAtServer) { if (this.obj.isLockedAtServer) {
console.log("savestateFirst"); console.log("savestateFirst");
fail = await saveState(vm); fail = await saveState(vm);
stateSaved = true;
} }
//WOITEMS //WOITEMS
@@ -444,16 +446,25 @@ 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.isLockedAtServer) { if (!stateSaved && !fail && !this.obj.isLockedAtServer) {
fail = await saveState(vm); fail = await saveState(vm);
} }
//## ALL PARTIAL UPDATES SUCCEEDED //## ALL PARTIAL UPDATES SUCCEEDED
window.$gz.form.setFormState({ if (fail) {
vm: vm, //this assumes error is already displayed from save op
dirty: false, window.$gz.form.setFormState({
valid: true 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 //TODO: Nav to this again if it's a post