Debian Codegraph @

lemonldap-ng-manager/site/js-src/filterFunctions.js

raw symbols SCIP
1 var filterFunctions;
2
3 filterFunctions = {
4 // Here, `node` is the root node (authParams) and `n` points to its
5 // conditional subnodes. This subnodes have the property `show` that can
6 // be set to true or false depending on what has to be displayed
7
8 authParams: function(scope, $q, node) {
9 var i, len, n, ref, wait;
10 // 1. be sure to have all datas in main nodes
11 wait = [];
12 ref = node.nodes;
13 for (i = 0, len = ref.length; i < len; i++) {
14 n = ref[i];
15 wait.push(scope.getKey(n));
16 }
17 // 2. then do the job
18 return $q.all(wait).then(function() {
19 var all, j, k, l, len1, len2, len3, len4, len5, len6, m, nToShow, nd, o, p, q, r, ref1, ref2, ref3, ref4, restart, s;
20 // Flag to see all nodes
21 all = false;
22 // Nodes to show
23 nToShow = [];
24 // Little function to select good node
25 p = function(s) {
26 var tmp;
27 tmp = s.toLowerCase();
28 if (tmp === 'openidconnect') {
29 tmp = 'oidc';
30 }
31 nToShow.push(tmp + 'Params');
32 if (tmp === 'ad') {
33 return nToShow.push('ldapParams');
34 }
35 };
36 ref1 = node.nodes;
37 // Show all normal nodes
38 for (j = 0, len1 = ref1.length; j < len1; j++) {
39 n = ref1[j];
40 p(n.data);
41 }
42 ref2 = node.nodes_cond;
43 // Select conditional nodes to show
44 for (k = 0, len2 = ref2.length; k < len2; k++) {
45 n = ref2[k];
46 // Flag to reload this after downloading datas
47 restart = 0;
48 // Select unopened/opened node
49 nd = n._nodes ? n._nodes : n.nodes;
50 // Case "Choice"
51 if (node.nodes[0].data === 'Choice' && n.id === 'choiceParams') {
52 console.debug('Choice is selected');
53 if (nd[1].cnodes) {
54 restart++;
55 } else {
56 nd = nd[1]._nodes ? nd[1]._nodes : nd[1].nodes;
57 for (l = 0, len3 = nd.length; l < len3; l++) {
58 m = nd[l];
59 ref3 = m.data;
60 for (o = 0, len4 = ref3.length; o < len4; o++) {
61 s = ref3[o];
62 if (typeof s === 'string') {
63 p(s);
64 }
65 }
66 }
67 }
68 // Case "Combination"
69 } else if (node.nodes[0].data === 'Combination' && n.id === 'combinationParams') {
70 console.debug('Combination is selected');
71 if (nd[1].cnodes) {
72 restart++;
73 } else {
74 nd = nd[1]._nodes ? nd[1]._nodes : nd[1].nodes;
75 for (q = 0, len5 = nd.length; q < len5; q++) {
76 m = nd[q];
77 p(m.data.type);
78 }
79 }
80 }
81 if (restart) {
82 scope.waiting = true;
83 scope.download({
84 '$modelValue': nd[1]
85 }).then(function() {
86 return filterFunctions.authParams(scope, $q, node);
87 });
88 return;
89 }
90 }
91 ref4 = node.nodes_cond;
92 for (r = 0, len6 = ref4.length; r < len6; r++) {
93 n = ref4[r];
94 if (!all && nToShow.indexOf(n.id) === -1) {
95 n.show = false;
96 } else {
97 n.show = true;
98 }
99 }
100 });
101 }
102 };
103
104 window.filterFunctions = filterFunctions;