From 16acc850272f3b0e623742047a45862157103aff Mon Sep 17 00:00:00 2001 From: Cyrus Hiatt Date: Mon, 17 Jun 2019 15:12:57 -0700 Subject: [PATCH] Adds default update state method to the workflow viewmodel. re #4821 --- arches/app/media/js/viewmodels/workflow.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arches/app/media/js/viewmodels/workflow.js b/arches/app/media/js/viewmodels/workflow.js index 6cf1dd215eb..7dbada12d81 100644 --- a/arches/app/media/js/viewmodels/workflow.js +++ b/arches/app/media/js/viewmodels/workflow.js @@ -65,6 +65,28 @@ define([ history.pushState(null, '', window.location.pathname + '?' + $.param(urlparams)); }; + this.updateState = function(val) { + var activeStep = val; + var previousStep = self.previousStep(); + var resourceId; + if (previousStep) { + self.state.steps[previousStep._index] = previousStep.stateProperties(); + self.state.steps[previousStep._index].complete = ko.unwrap(previousStep.complete); + self.state.activestep = val._index; + self.state.previousstep = previousStep._index; + if (!resourceId) { + resourceId = !!previousStep.resourceid ? ko.unwrap(previousStep.resourceid) : null; + self.state.resourceid = resourceId; + activeStep.requirements.resourceid = self.state.resourceid; + } + self.updateUrl(); + } else { + activeStep.requirements = self.state.steps[activeStep._index] || {}; + activeStep.requirements.resourceid = self.state.resourceid; + } + self.previousStep(activeStep); + }; + this.next = function(){ var activeStep = self.activeStep(); if (activeStep && activeStep.complete() && activeStep._index < self.steps.length - 1) {