@@ -4,7 +4,7 @@ var table;
4
4
var backendServiceUrl ;
5
5
var subscriptionTemplateFile ;
6
6
7
- $ ( document ) . ready ( function ( ) {
7
+ jQuery ( document ) . ready ( function ( ) {
8
8
9
9
10
10
/*
@@ -134,10 +134,16 @@ $(document).ready(function() {
134
134
}
135
135
} ) ;
136
136
}
137
-
137
+
138
+
139
+
138
140
139
141
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 ) ;
141
147
}
142
148
143
149
@@ -153,6 +159,19 @@ $(document).ready(function() {
153
159
154
160
self . repeat_in = ko . observableArray ( [ true , false ] ) ;
155
161
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
+
156
175
} ;
157
176
158
177
// Apply bindings
@@ -435,16 +454,59 @@ $(document).ready(function() {
435
454
event . stopPropagation ( ) ;
436
455
event . preventDefault ( ) ;
437
456
438
- var condition = {
457
+ /* var condition = {
439
458
"conditions" : [
440
459
{
441
460
"jmespath" : ko.observable("")
442
461
}
443
462
]
444
463
}
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
+
446
476
// 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
+
448
510
} ) ;
449
511
// /Stop ## Add Condition ################################################
450
512
@@ -535,15 +597,45 @@ $(document).ready(function() {
535
597
var mappedPackageInfo = $ . map ( returnData , function ( item ) {
536
598
537
599
// Defining Observable on all parameters in Requirements array(which is defined as ObservableArray)
600
+ /*
538
601
for (i=0; i < item[0].requirements.length; i++){
539
602
var jmespath_temp = item[0].requirements[i].conditions[0].jmespath;
540
603
item[0].requirements[i].conditions[0] = {"jmespath" : ko.observable(jmespath_temp)};
541
604
542
605
var type_temp = item[0].requirements[i].type;
543
606
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
+ }
546
636
return new subscription_model ( item [ 0 ] ) ;
637
+
638
+
547
639
} ) ;
548
640
549
641
// Load data into observable array
@@ -620,7 +712,8 @@ $(document).ready(function() {
620
712
} ) ;
621
713
return ;
622
714
}
623
-
715
+
716
+ /*
624
717
var requirementsArray = vm.subscription()[0].requirements();
625
718
for (i=0; i < requirementsArray.length; i++){
626
719
if (requirementsArray[i].conditions[0].jmespath() == "") {
@@ -630,7 +723,7 @@ $(document).ready(function() {
630
723
});
631
724
return;
632
725
}
633
- }
726
+ }*/
634
727
//END: Check of other subscription fields values
635
728
636
729
var id = ko . toJSON ( vm . subscription ( ) [ 0 ] . subscriptionName ) . trim ( ) ;
0 commit comments