Debian Codegraph @

lemonldap-ng-manager/site/htdocs/static/js/filterFunctions.js

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