Skip to content

Commit

Permalink
Adds default update state method to the workflow viewmodel. re #4821
Browse files Browse the repository at this point in the history
  • Loading branch information
chiatt committed Jun 17, 2019
1 parent 638da86 commit 16acc85
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions arches/app/media/js/viewmodels/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 16acc85

Please sign in to comment.