Skip to content

Commit f5d0821

Browse files
committed
refactor workflow resourceId persistence logic #6949
1 parent 41fab6d commit f5d0821

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

arches/app/media/js/viewmodels/workflow-step.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ define([
2929
this.externalStepData = {};
3030

3131
var externalStepSourceData = ko.unwrap(config.externalstepdata) || {};
32-
console.log("!!!!!!!!!", externalStepSourceData)
3332
Object.keys(externalStepSourceData).forEach(function(key) {
3433
if (key !== '__ko_mapping__') {
3534
self.externalStepData[key] = {
@@ -41,6 +40,12 @@ define([
4140
delete config.externalstepdata;
4241

4342
this.value = ko.observable();
43+
this.value.subscribe(function(value) {
44+
/* if we have defined that this is part of a single-resource workflow, and that this step creates the desired resource */
45+
if (self.shouldtrackresource && !ko.unwrap(config.workflow.resourceId)) {
46+
config.workflow.resourceId(value.resourceid)
47+
}
48+
});
4449

4550
this.active = ko.computed(function() {
4651
return config.workflow.activeStep() === this;
@@ -95,7 +100,6 @@ define([
95100
};
96101

97102
this.getExternalStepData = function() {
98-
console.log(self.externalStepData)
99103
Object.keys(self.externalStepData).forEach(function(key) {
100104
self.externalStepData[key]['data'] = config.workflow.getStepData(externalStepSourceData[key]);
101105
});

arches/app/media/js/viewmodels/workflow.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ define([
106106

107107
this.getStepData = function(stepName) {
108108
/* ONLY to be used as intermediary for when a step needs data from a different step in the workflow */
109-
110109
var step = self.steps.find(function(step) { return ko.unwrap(step.name) === ko.unwrap(stepName) });
111-
console.log('888', step)
112110
if (step) { return step.value(); }
113111
};
114112

arches/app/media/js/views/components/workflows/new-tile-step.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ define([
1414

1515
this.resourceId = ko.observable();
1616

17+
var cachedValue = ko.unwrap(params.value);
18+
if (cachedValue) {
19+
self.resourceId(cachedValue.resourceid);
20+
params.tileid(cachedValue.tileid);
21+
}
22+
1723
if (ko.unwrap(params.resourceid)) {
1824
self.resourceId(ko.unwrap(params.resourceid));
1925
}
2026
else if (ko.unwrap(params.workflow.resourceId)) {
2127
self.resourceId(ko.unwrap(params.workflow.resourceId));
2228
}
2329

24-
var cachedValue = ko.unwrap(params.value);
25-
if (cachedValue) {
26-
self.resourceId(cachedValue.resourceid);
27-
params.tileid(cachedValue.tileid);
28-
}
29-
3030
this.getCardResourceIdOrGraphId = function() { // override for different cases
3131
return (ko.unwrap(this.resourceId) || ko.unwrap(params.graphid));
3232
};
@@ -157,7 +157,6 @@ define([
157157
if (self.customCardLabel) item.model.name(ko.unwrap(self.customCardLabel));
158158
self.card(item);
159159
if (ko.unwrap(params.tileid)) {
160-
console.log(item, params)
161160
ko.unwrap(item.tiles).forEach(function(tile) {
162161
if (tile.tileid === ko.unwrap(params.tileid)) {
163162
self.tile(tile);
@@ -248,13 +247,7 @@ define([
248247
}
249248

250249
params.value(params.defineStateProperties());
251-
252-
if (params.shouldtrackresource) {
253-
if (params.workflow.resourceId ) { /* if we have defined that this is part of a single-resource workflow */
254-
params.workflow.resourceId(tile.resourceinstance_id);
255-
}
256-
}
257-
250+
258251
if (self.completeOnSave === true) { self.complete(true); }
259252
};
260253

0 commit comments

Comments
 (0)