Skip to content

Commit

Permalink
adds updated state mgmt function, re #27
Browse files Browse the repository at this point in the history
  • Loading branch information
whatisgalen committed Jun 12, 2019
1 parent f981092 commit bd91f13
Showing 1 changed file with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,34 @@ define([
], function(_, $, arches, ko, AddRefStep) {

function viewModel(params) {
// console.log(params.parenttileid());
// console.log(params);

if (!params.resourceid() && params.requirements){
params.resourceid(params.requirements.resourceid);
params.tileid(params.requirements.tileid);
}

AddRefStep.apply(this, [params]);
var self = this;
var urlparams = params.parseUrlParams();
self.requirements = params.requirements;
params.tile = self.tile;

params.stateProperties = function(){
return {
resourceid: ko.unwrap(params.resourceid),
tile: !!(params.tile) ? koMapping.toJS(params.tile().data) : undefined,
tileid: !!(params.tile) ? ko.unwrap(params.tile().tileid): undefined
}
};

self.tile.subscribe(function(val) {
if(val) {
if(urlparams) {
if (urlparams.applyOutputToTarget) {
val.data[urlparams.targetnode](urlparams.value);
if(self.requirements) {
if (self.requirements.applyOutputToTarget) {
val.data[self.requirements.targetnode](self.requirements.value);
}
}
}
});
console.log(self.card());
};

return ko.components.register('set-reference-numbers', {
Expand Down

0 comments on commit bd91f13

Please sign in to comment.