Skip to content

Commit

Permalink
Merge pull request #4913 from archesproject/4821_workflows_url_params
Browse files Browse the repository at this point in the history
Adds default updateState method to the workflow viewmodel
  • Loading branch information
chiatt authored Jun 17, 2019
2 parents 589b63b + 16acc85 commit 631e152
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 631e152

Please sign in to comment.