Skip to content

Commit 2918928

Browse files
committed
subscription updates
1 parent 560d2ec commit 2918928

File tree

3 files changed

+257
-41
lines changed

3 files changed

+257
-41
lines changed
Loading

src/main/resources/static/js/main.js

Lines changed: 103 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var table;
44
var backendServiceUrl;
55
var subscriptionTemplateFile;
66

7-
$(document).ready(function() {
7+
jQuery(document).ready(function() {
88

99

1010
/*
@@ -134,10 +134,16 @@ $(document).ready(function() {
134134
}
135135
});
136136
}
137-
137+
138+
139+
138140

139141
function conditions_model(condition){
140-
this.jmepath = ko.observable(condition.conditions.jmepath);
142+
this.conditions = ko.observableArray(condition);
143+
}
144+
145+
function jmespath_model(jmespath){
146+
this.jmespath = ko.observable(jmespath.jmespath);
141147
}
142148

143149

@@ -153,6 +159,19 @@ $(document).ready(function() {
153159

154160
self.repeat_in = ko.observableArray([true, false]);
155161

162+
163+
164+
// removeSelected_cc_decision_cni_in_list
165+
self.add_conditions_test = function(item) {
166+
167+
self.subscription()[0].requirements()[0].conditions().push(new jmespath_model({"jmespath": ko.observable("cc")}));
168+
169+
console.log(ko.toJSON(self.subscription()[0].requirements()[0].conditions()));
170+
171+
self.subscription.valueHasMutated();
172+
173+
};
174+
156175
};
157176

158177
// Apply bindings
@@ -435,16 +454,59 @@ $(document).ready(function() {
435454
event.stopPropagation();
436455
event.preventDefault();
437456

438-
var condition = {
457+
/*var condition = {
439458
"conditions" : [
440459
{
441460
"jmespath" : ko.observable("")
442461
}
443462
]
444463
}
445-
464+
*/
465+
var condition = {
466+
"jmespath" : ko.observable("test")
467+
}
468+
469+
//var nisse = [];
470+
//nisse.push(new jmespath_model({"jmespath": ko.observable(jmespath_temp)}));
471+
472+
//new conditions_model(nisse);
473+
474+
//new conditions_model(new jmespath_model({"jmespath": ko.observable(jmespath_temp)})
475+
446476
// Not sure if its correct to use index 0(zero) here,, is it correct??
447-
vm.subscription()[0].requirements.push(condition);
477+
//vm.subscription()[0].requirements.conditions.push(condition);
478+
479+
//vm.subscription()[0].requirements.push([new conditions_model([new jmespath_model({"jmespath": ko.observable("")})])]);
480+
481+
//vm.subscription()[0].requirements[0].conditions.push([new conditions_model([new jmespath_model({"jmespath": ko.observable("")})])]);
482+
483+
//vm.subscription()[0].requirements[0].push([new conditions_model([new jmespath_model({"jmespath": ko.observable("")})])]);
484+
485+
486+
// vm.subscription()[0].requirements.push([new conditions_model([new jmespath_model({"jmespath": ko.observable("")})])]);
487+
488+
//vm.subscription()[0].requirements[0].conditions.push([new jmespath_model({"jmespath": ko.observable("")})]);
489+
490+
491+
492+
493+
vm.subscription()[0].requirements()[0].conditions().push(new jmespath_model({"jmespath": ko.observable("cc")}));
494+
495+
//vm.subscription()[0].requirements()[0].conditions().push({"jmespath": ko.observable("cc")});
496+
497+
498+
499+
console.log(ko.toJSON(vm.subscription()[0].requirements()[0].conditions()));
500+
501+
vm.subscription.valueHasMutated();
502+
503+
504+
//var vm = new SubscriptionViewModel();
505+
//ko.applyBindings(vm);
506+
507+
// ko.cleanNode(document.getElementById(element_id))
508+
// ko.applyBindings(viewModel, document.getElementById(element_id))
509+
448510
});
449511
// /Stop ## Add Condition ################################################
450512

@@ -535,15 +597,45 @@ $(document).ready(function() {
535597
var mappedPackageInfo = $.map(returnData, function (item) {
536598

537599
// Defining Observable on all parameters in Requirements array(which is defined as ObservableArray)
600+
/*
538601
for (i=0; i < item[0].requirements.length; i++){
539602
var jmespath_temp = item[0].requirements[i].conditions[0].jmespath;
540603
item[0].requirements[i].conditions[0] = {"jmespath" : ko.observable(jmespath_temp)};
541604
542605
var type_temp = item[0].requirements[i].type;
543606
item[0].requirements[i].type = ko.observable(type_temp);
544-
}
545-
607+
}*/
608+
609+
610+
611+
for (i=0; i < item[0].requirements.length; i++) {
612+
613+
var conditions_array = [];
614+
615+
for (k = 0; k < item[0].requirements[i].conditions.length; k++) {
616+
617+
var jmespath_temp = item[0].requirements[i].conditions[k].jmespath;
618+
619+
conditions_array.push(new jmespath_model({"jmespath": ko.observable(jmespath_temp)}));
620+
621+
//item[0].requirements[i].conditions[k] = {"jmespath": ko.observable(jmespath_temp)};
622+
623+
//item[0].requirements[i].conditions.push([{"jmespath": ko.observable(jmespath_temp)}])
624+
625+
//item[0].requirements[i].conditions.push(item[0].requirements[i].conditions[k] = {"jmespath": ko.observable(jmespath_temp)});
626+
627+
//item[0].requirements[i] = {"conditions": ko.observableArray([item[0].requirements[i].conditions[k] = {"jmespath": ko.observable(jmespath_temp)}])};
628+
629+
//item[0].requirements[i] = {"conditions": ko.observableArray([item[0].requirements[i].conditions[k] = {"jmespath": ko.observable(jmespath_temp)}])};
630+
631+
}
632+
633+
item[0].requirements[i] = new conditions_model(conditions_array);
634+
635+
}
546636
return new subscription_model(item[0]);
637+
638+
547639
});
548640

549641
// Load data into observable array
@@ -620,7 +712,8 @@ $(document).ready(function() {
620712
});
621713
return;
622714
}
623-
715+
716+
/*
624717
var requirementsArray = vm.subscription()[0].requirements();
625718
for (i=0; i < requirementsArray.length; i++){
626719
if (requirementsArray[i].conditions[0].jmespath() == "") {
@@ -630,7 +723,7 @@ $(document).ready(function() {
630723
});
631724
return;
632725
}
633-
}
726+
}*/
634727
//END: Check of other subscription fields values
635728

636729
var id = ko.toJSON(vm.subscription()[0].subscriptionName).trim();

0 commit comments

Comments
 (0)