Skip to content

Commit

Permalink
Merge pull request #4909 from archesproject/4821_workflows_url_params
Browse files Browse the repository at this point in the history
Final workflow step improvements
  • Loading branch information
chiatt committed Jun 17, 2019
2 parents d8308d8 + 639b7c4 commit 638da86
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
2 changes: 2 additions & 0 deletions arches/app/media/js/viewmodels/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ define([
this.restoreStateFromURL = function(){
var urlparams = new window.URLSearchParams(window.location.search);
var res = {};
var pathArray = window.location.pathname.split('/');
res.workflowid = pathArray[2];
urlparams.forEach(function(v, k){res[k] = v;});
res.steps = res.steps ? JSON.parse(res.steps) : [];
this.state = res;
Expand Down
21 changes: 13 additions & 8 deletions arches/app/media/js/views/components/workflows/final-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ define([
], function(_, $, arches, ko, GraphModel, ReportModel, CardViewModel) {
function viewModel(params) {
var self = this;
this.urls = arches.urls;
if (!params.resourceid() && params.requirements){
params.resourceid(params.requirements.resourceid);
}

var url = arches.urls.api_card + (ko.unwrap(params.resourceid));
this.workflowid = params.workflow.state.workflowid;
this.resourceid = params.resourceid();
var url = arches.urls.api_card + (ko.unwrap(this.resourceid));
this.report = ko.observable();
this.loading = ko.observable(true);
this.nodegroupids = params.workflow.steps
.filter(function(step){return ko.unwrap(step.nodegroupid);})
.map(function(x){return ko.unwrap(x.nodegroupid);});

$.getJSON(url, function(data) {
var displayname = ko.observable(data.displayname);
Expand All @@ -30,9 +35,9 @@ define([

var topCards = _.filter(data.cards, function(card) {
var nodegroup = _.find(data.nodegroups, function(group) {
return group.nodegroupid === card.nodegroup_id;
return (group.nodegroupid === card.nodegroup_id);
});
return !nodegroup || !nodegroup.parentnodegroup_id;
return (!nodegroup || !nodegroup.parentnodegroup_id) && _.contains(self.nodegroupids, card.nodegroup_id);
}).map(function(card) {
params.nodegroupid = params.nodegroupid || card.nodegroup_id;
return new CardViewModel({
Expand All @@ -51,16 +56,16 @@ define([

topCards.forEach(function(topCard) {
topCard.topCards = topCards;
});
}, this);

self.report(new ReportModel(_.extend(data, {graphModel: graphModel, cards: topCards})));
self.loading(false);
});

params.stateProperties = function(){
return {}
};
};
return {};
};
}
return ko.components.register('final-step', {
viewModel: viewModel,
template: {
Expand Down
16 changes: 15 additions & 1 deletion arches/app/templates/views/components/workflows/final-step.htm
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<div class="workflows-get-tile-value">
<h4>Workflow Complete</h4>
<div style='display:flex; justify-content: space-between;'>
<h4>Workflow Complete</h4>
<div>
<a href="#" target="_self" type="button" class="btn btn-primary"
data-bind="attr: { href: urls.plugin(workflowid)}">
<i class="fa fa-plus"></i>
<span>New</span>
</a>
<a href="#" target="_self" type="button" class="btn btn-primary"
data-bind="attr: { href: urls.resource + '/' + resourceid}">
<i class="fa fa-pencil"></i>
<span>Edit</span>
</a>
</div>
</div>
<!--ko if: report() -->
<div class='resource-report editor-report' data-bind='component: {
name: "default-report",
Expand Down

0 comments on commit 638da86

Please sign in to comment.