]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/js/ui/default/staff/reporter/template/app.js
aa5ca376196100972609bfa0359335bcdc562448
[Evergreen.git] / Open-ILS / web / js / ui / default / staff / reporter / template / app.js
1 /*
2  * Report template builder
3  */
4
5 angular.module('egReporter',
6     ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'egUiMod', 'egGridMod', 'egReportMod', 'treeControl', 'ngToast'])
7
8 .config(['ngToastProvider', function(ngToastProvider) {
9   ngToastProvider.configure({
10     verticalPosition: 'bottom',
11     animation: 'fade'
12   });
13 }])
14
15 .config(function($routeProvider, $locationProvider, $compileProvider) {
16     $locationProvider.html5Mode(true);
17     $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|mailto|blob):/); // grid export
18         
19     var resolver = {delay : function(egStartup) {return egStartup.go()}};
20
21     $routeProvider.when('/reporter/template/clone/:folder/:id', {
22         templateUrl: './reporter/t_edit_template',
23         controller: 'ReporterTemplateEdit',
24         resolve : resolver
25     });
26
27     $routeProvider.when('/reporter/legacy/template/clone/:folder/:id', {
28         templateUrl: './reporter/t_legacy',
29         controller: 'ReporterTemplateLegacy',
30         resolve : resolver
31     });
32
33     $routeProvider.when('/reporter/template/new/:folder', {
34         templateUrl: './reporter/t_edit_template',
35         controller: 'ReporterTemplateEdit',
36         resolve : resolver
37     });
38
39     $routeProvider.when('/reporter/legacy/main', {
40         templateUrl: './reporter/t_legacy',
41         controller: 'ReporterTemplateLegacy',
42         resolve : resolver
43     });
44
45     // default page
46     $routeProvider.otherwise({redirectTo : '/reporter/legacy/main'});
47 })
48
49 /**
50  * controller for legacy template stuff
51  */
52 .controller('ReporterTemplateLegacy',
53        ['$scope','$routeParams','$location','egCore',
54 function($scope , $routeParams , $location , egCore) {
55
56     var template_id = $routeParams.id;
57     var folder_id = $routeParams.folder;
58
59     $scope.rurl = '/reports/oils_rpt.xhtml?ses=' + egCore.auth.token();
60
61     if (folder_id) {
62         $scope.rurl = '/reports/oils_rpt_builder.xhtml?ses=' +
63                         egCore.auth.token() + '&folder=' + folder_id;
64
65         if (template_id) $scope.rurl += '&ct=' + template_id;
66     }
67
68 }])
69
70 /**
71  * Uber-controller for template editing
72  */
73 .controller('ReporterTemplateEdit',
74        ['$scope','$q','$routeParams','$location','$timeout','$window','egCore','$uibModal','egPromptDialog',
75         'egGridDataProvider','egReportTemplateSvc','$uibModal','egConfirmDialog','egSelectDialog','ngToast',
76 function($scope , $q , $routeParams , $location , $timeout , $window,  egCore , $uibModal , egPromptDialog ,
77          egGridDataProvider , egReportTemplateSvc , $uibModal , egConfirmDialog , egSelectDialog , ngToast) {
78
79     function values(o) { return Object.keys(o).map(function(k){return o[k]}) };
80
81     var template_id = $routeParams.id;
82     var folder_id = $routeParams.folder;
83
84     $scope.grid_display_fields_provider = egGridDataProvider.instance({
85         get : function (offset, count) {
86             return this.arrayNotifier(egReportTemplateSvc.display_fields, offset, count);
87         }
88     });
89     $scope.grid_filter_fields_provider = egGridDataProvider.instance({
90         get : function (offset, count) {
91             return this.arrayNotifier(egReportTemplateSvc.filter_fields, offset, count);
92         }
93     });
94
95     var dgrid = $scope.display_grid_controls = {};
96     var fgrid = $scope.filter_grid_controls = {};
97
98     var default_filter_obj = {
99         op : '=',
100         label     : egReportTemplateSvc.Filters['='].label
101     };
102
103     var default_transform_obj = {
104         transform : 'Bare',
105         label     : egReportTemplateSvc.Transforms.Bare.label,
106         aggregate : false
107     };
108
109     function mergePaths (items) {
110         var tree = {};
111
112         items.forEach(function (item) {
113             var t = tree;
114             var join_path = '';
115
116             var last_jtype = '';
117             item.path.forEach(function (p, i, a) {
118                 var alias; // unpredictable hashes are fine for intermediate tables
119
120                 if (i) { // not at the top of the tree
121                     if (i == 1) join_path = join_path.split('-')[0];
122
123                     // SQLBuilder relies on the first dash-separated component
124                     // of the join key to specify the column of left-hand relation
125                     // to join on; for has_many and might_have link types, we have to grab the
126                     // primary key of the left-hand table; otherwise, we can
127                     // just use the field/column name found in p.uplink.name.
128                     var uplink = (p.uplink.reltype == 'has_many' || p.uplink.reltype == 'might_have') ?
129                         egCore.idl.classes[p.from.split('.').slice(-1)[0]].pkey + '-' + p.uplink.name :
130                         p.uplink.name;
131                     join_path += '-' + uplink;
132                     alias = hex_md5(join_path);
133
134                     var uplink_alias = uplink + '-' + alias;
135
136                     if (!t.join) t.join = {};
137                     if (!t.join[uplink_alias]) t.join[uplink_alias] = {};
138
139                     t = t.join[uplink_alias];
140
141                     var djtype = 'inner';
142                     // we use LEFT JOINs for might_have and has_many, AND
143                     // also if our previous JOIN was a LEFT JOIN
144                     //
145                     // The last piece prevents later joins from limiting those
146                     // closer to the core table
147                     if (p.uplink.reltype != 'has_a' || last_jtype == 'left') djtype = 'left';
148
149                     t.type = p.jtype || djtype;
150                     last_jtype = t.type;
151                     t.key = p.uplink.key;
152                 } else {
153                     join_path = p.classname + '-' + p.classname;
154                     alias = hex_md5(join_path);
155                 }
156
157                 if (!t.alias) t.alias = alias;
158                 t.path = join_path;
159
160                 t.table = p.struct.source ? p.struct.source : p.table;
161                 t.idlclass = p.classname;
162
163                 if (a.length == i + 1) { // end of the path array, need a predictable hash
164                     t.label = item.path_label;
165                     t.alias = hex_md5(item.path_label);
166                 }
167
168             });
169         });
170
171         return tree;
172     };
173     // expose for testing
174     $scope._mergePaths = mergePaths;
175
176     $scope.constructTemplate = function () {
177         var param_counter = 0;
178         return {
179             version     : 5,
180             doc_url     : $scope.templateDocURL,
181             core_class  : egCore.idl.classTree.top.classname,
182             select      : dgrid.allItems().map(function (i) {
183                             return {
184                                 alias     : i.label,
185                                 path      : i.path[i.path.length - 1].classname + '-' + i.name,
186                                 field_doc : i.doc_text,
187                                 relation  : hex_md5(i.path_label),
188                                 column    : {
189                                     colname         : i.name,
190                                     transform       : i.transform ? i.transform.transform : '',
191                                     transform_label : i.transform ? i.transform.label : '',
192                                     aggregate       : !!i.transform.aggregate
193                                 }
194                             }
195                           }),
196             from        : mergePaths( dgrid.allItems().concat(fgrid.allItems()) ),
197             where       : fgrid.allItems().filter(function(i) {
198                             return !i.transform.aggregate;
199                           }).map(function (i) {
200                             var cond = {};
201                             if (
202                                 i.operator.op == 'is' ||
203                                 i.operator.op == 'is not' ||
204                                 i.operator.op == 'is blank' ||
205                                 i.operator.op == 'is not blank'
206                             ) {
207                                 cond[i.operator.op] = null;
208                             } else {
209                                 if (i.value === undefined) {
210                                     cond[i.operator.op] = '::P' + param_counter++;
211                                 }else {
212                                     cond[i.operator.op] = i.value;
213                                 }
214                             }
215                             return {
216                                 alias     : i.label,
217                                 path      : i.path[i.path.length - 1].classname + '-' + i.name,
218                                 field_doc : i.doc_text,
219                                 relation  : hex_md5(i.path_label),
220                                 column    : {
221                                     colname         : i.name,
222                                     transform       : i.transform.transform,
223                                     transform_label : i.transform.label,
224                                     aggregate       : 0
225                                 },
226                                 condition : cond // constructed above
227                             }
228                           }),
229             having      : fgrid.allItems().filter(function(i) {
230                             return !!i.transform.aggregate;
231                           }).map(function (i) {
232                             var cond = {};
233                             cond[i.operator.op] = '::P' + param_counter++;
234                             return {
235                                 alias     : i.label,
236                                 path      : i.path[i.path.length - 1].classname + '-' + i.name,
237                                 field_doc : i.doc_text,
238                                 relation  : hex_md5(i.path_label),
239                                 column    : {
240                                     colname         : i.name,
241                                     transform       : i.transform.transform,
242                                     transform_label : i.transform.label,
243                                     aggregate       : 1
244                                 },
245                                 condition : cond // constructed above
246                             }
247                           }),
248             display_cols: angular.copy( dgrid.allItems() ).map(strip_item),
249             filter_cols : angular.copy( fgrid.allItems() ).map(strip_item)
250         };
251
252         function strip_item (i) {
253             delete i.children;
254             i.path.forEach(function(p){
255                 delete p.children;
256                 delete p.fields;
257                 delete p.links;
258                 delete p.struct.permacrud;
259                 delete p.struct.field_map;
260                 delete p.struct.fields;
261             });
262             return i;
263         }
264
265     }
266
267     $scope.upgradeTemplate = function(template) {
268         template.name(template.name() + ' (converted from XUL)');
269         template.data.version = 5;
270
271         var order_by;
272         var rels = [];
273         for (var key in template.data.rel_cache) {
274             if (key == 'order_by') {
275                 order_by = template.data.rel_cache[key];
276             } else {
277                 rels.push(template.data.rel_cache[key]);
278             }
279         }
280
281         // preserve the old select order for the display cols
282         var sel_order = {};
283         template.data.select.map(function(val, idx) {
284             // set key to unique value easily derived from relcache
285             sel_order[val.relation + val.column.colname] = idx;
286         });
287
288         template.data['display_cols'] = [];
289         template.data['filter_cols'] = [];
290
291         function _convertPath(orig, rel) {
292             var newPath = [];
293
294             var table_path = rel.path.split(/\./);
295             if (table_path.length > 1 || rel.path.indexOf('-') > -1) table_path.push( rel.idlclass );
296
297             var prev_type = '';
298             var prev_link = '';
299             table_path.forEach(function(link) {
300                 var cls = link.split(/-/)[0];
301                 var fld = link.split(/-/)[1];
302                 var args = {
303                     label : egCore.idl.classes[cls].label
304                 }
305                 if (prev_link != '') {
306                     var link_parts = prev_link.split(/-/);
307                     args['from'] = link_parts[0];
308                     var join_parts = link_parts[1].split(/>/);
309                     var prev_col = join_parts[0];
310                     egCore.idl.classes[prev_link.split(/-/)[0]].fields.forEach(function(f) {
311                         if (prev_col == f.name) {
312                             args['link'] = f;
313                         }
314                     });
315                     args['jtype'] = join_parts[1]; // frequently undefined
316                 }
317                 newPath.push(egCore.idl.classTree.buildNode(cls, args));
318                 prev_link = link;
319             });
320             return newPath;
321
322         }
323
324         function _buildCols(rel, tab_type, col_idx) {
325             if (tab_type == 'dis_tab') {
326                 col_type = 'display_cols';
327             } else {
328                 col_type = 'filter_cols';
329             }
330
331             for (var col in rel.fields[tab_type]) {
332                 var orig = rel.fields[tab_type][col];
333                 var col = {
334                     name        : orig.colname,
335                     path        : _convertPath(orig, rel),
336                     label       : orig.alias,
337                     datatype    : orig.datatype,
338                     doc_text    : orig.field_doc,
339                     transform   : {
340                                     label     : orig.transform_label,
341                                     transform : orig.transform,
342                                     aggregate : (orig.aggregate == "undefined") ? undefined : orig.aggregate  // old structure sometimes has undefined as a quoted string
343                                   },
344                     path_label  : rel.label.replace('::', '->')
345                 };
346                 if (col_type == 'filter_cols') {
347                     col['operator'] = {
348                         op        : orig.op,
349                         label     : orig.op_label
350                     };
351                     col['index'] = col_idx++;
352                     if ('value' in orig.op_value) {
353                         col['value'] = orig.op_value.value;
354                     }
355                 } else { // display
356                     col['index'] = sel_order[rel.alias + orig.colname];
357                 }
358
359                 template.data[col_type].push(col);
360             }
361         }
362
363         rels.map(function(rel) {
364             _buildCols(rel, 'dis_tab');
365             _buildCols(rel, 'filter_tab', template.data.filter_cols.length);
366             _buildCols(rel, 'aggfilter_tab', template.data.filter_cols.length);
367         });
368
369         template.data['display_cols'].sort(function(a, b){return a.index - b.index});
370     }
371
372     function loadTemplate () {
373         if (!template_id) return;
374         egCore.pcrud.retrieve( 'rt', template_id)
375         .then( function(template) {
376             template.data = angular.fromJson(template.data());
377             if (template.data.version < 5) {
378                 $scope.upgradeTemplate(template);
379             }
380
381             $scope.templateName = template.name() + ' (clone)';
382             $scope.templateDescription = template.description();
383             $scope.templateDocURL = template.data.doc_url;
384
385             $scope.changeCoreSource( template.data.core_class );
386
387             egReportTemplateSvc.display_fields = template.data.display_cols;
388             egReportTemplateSvc.filter_fields = template.data.filter_cols;
389
390             $timeout(function(){
391                 dgrid.refresh();
392                 fgrid.refresh();
393             });
394         });
395
396     }
397
398     $scope.saveTemplate = function () {
399         var tmpl = new egCore.idl.rt();
400         tmpl.name( $scope.templateName );
401         tmpl.description( $scope.templateDescription );
402         tmpl.owner(egCore.auth.user().id());
403         tmpl.folder(folder_id);
404         tmpl.data(angular.toJson($scope.constructTemplate()));
405
406         egConfirmDialog.open(tmpl.name(), egCore.strings.TEMPLATE_CONF_CONFIRM_SAVE,
407             {ok : function() {
408                 return egCore.pcrud.create( tmpl )
409                 .then(
410                     function() {
411                         ngToast.create(egCore.strings.TEMPLATE_CONF_SUCCESS_SAVE);
412                         return $timeout(
413                             function(){
414                                 $window.location.href = egCore.env.basePath + 'reporter/legacy/main';
415                             },
416                             1000
417                         );
418                     },
419                     function() {
420                         ngToast.warning(egCore.strings.TEMPLATE_CONF_FAIL_SAVE);
421                     }
422                 );
423             }}
424         );
425     }
426
427     $scope.addDisplayFields = function () {
428         var t = $scope.selected_transform;
429         if (!t) t = default_transform_obj;
430
431         egReportTemplateSvc.addFields(
432             'display_fields',
433             $scope.selected_source_field_list, 
434             t,
435             $scope.currentPathLabel,
436             $scope.currentPath
437         );
438         $scope.selected_transform = null;
439         dgrid.refresh();
440     }
441
442     $scope.addFilterFields = function () {
443         var t = $scope.selected_transform;
444         if (!t) t = default_transform_obj;
445         f = default_filter_obj;
446
447         egReportTemplateSvc.addFields(
448             'filter_fields',
449             $scope.selected_source_field_list, 
450             t,
451             $scope.currentPathLabel,
452             $scope.currentPath,
453             f
454         );
455         $scope.selected_transform = null;
456         fgrid.refresh();
457     }
458
459     $scope.moveDisplayFieldUp = function (items) {
460         items.reverse().forEach(function(item) {
461             egReportTemplateSvc.moveFieldUp('display_fields', item);
462         });
463         dgrid.refresh();
464     }
465
466     $scope.moveDisplayFieldDown = function (items) {
467         items.forEach(function(item) {
468             egReportTemplateSvc.moveFieldDown('display_fields', item);
469         });
470         dgrid.refresh();
471     }
472
473     $scope.removeDisplayField = function (items) {
474         items.forEach(function(item) {egReportTemplateSvc.removeField('display_fields', item)});
475         dgrid.refresh();
476     }
477
478     $scope.changeDisplayLabel = function (items) {
479         items.forEach(function(item) {
480             egPromptDialog.open(egCore.strings.TEMPLATE_CONF_PROMPT_CHANGE, item.label || '',
481                 {ok : function(value) {
482                     if (value) egReportTemplateSvc.display_fields[item.index].label = value;
483                 }}
484             );
485         });
486         dgrid.refresh();
487     }
488
489     $scope.changeDisplayFieldDoc = function (items) {
490         items.forEach(function(item) {
491             egPromptDialog.open(egCore.strings.TEMPLATE_FIELD_DOC_PROMPT_CHANGE, item.doc_text || '',
492                 {ok : function(value) {
493                     if (value) egReportTemplateSvc.display_fields[item.index].doc_text = value;
494                 }}
495             );
496         });
497         dgrid.refresh();
498     }
499
500     $scope.changeFilterFieldDoc = function (items) {
501         items.forEach(function(item) {
502             egPromptDialog.open(egCore.strings.TEMPLATE_FIELD_DOC_PROMPT_CHANGE, item.doc_text || '',
503                 {ok : function(value) {
504                     if (value) egReportTemplateSvc.filter_fields[item.index].doc_text = value;
505                 }}
506             );
507         });
508         fgrid.refresh();
509     }
510
511     $scope.changeFilterValue = function (items) {
512         items.forEach(function(item) {
513             var l = null;
514             if (item.datatype == "bool") {
515                 var displayVal = typeof item.value === "undefined" ? egCore.strings.TEMPLATE_CONF_UNSET :
516                                  item.value === 't'                ? egCore.strings.TEMPLATE_CONF_TRUE :
517                                  item.value === 'f'                ? egCore.strings.TEMPLATE_CONF_FALSE :
518                                  item.value.toString();
519                 egConfirmDialog.open(egCore.strings.TEMPLATE_CONF_DEFAULT, displayVal,
520                     {ok : function() {
521                         egReportTemplateSvc.filter_fields[item.index].value = 't';
522                     },
523                     cancel : function() {
524                         egReportTemplateSvc.filter_fields[item.index].value = 'f';
525                     }}, egCore.strings.TEMPLATE_CONF_TRUE, egCore.strings.TEMPLATE_CONF_FALSE
526                 );
527             } else {
528                 egPromptDialog.open(egCore.strings.TEMPLATE_CONF_DEFAULT, item.value || '',
529                     {ok : function(value) {
530                         if (value) egReportTemplateSvc.updateFilterValue(item, value);
531                     }}
532                 );
533             }
534         });
535         fgrid.refresh();
536     }
537
538     $scope.changeTransform = function (items) {
539
540         var f = items[0];
541
542         var tlist = [];
543         angular.forEach(egReportTemplateSvc.Transforms, function (o,n) {
544             if ( o.datatype.indexOf(f.datatype) > -1) {
545                 if (tlist.indexOf(o.label) == -1) tlist.push( o.label );
546             }
547         });
548         
549         items.forEach(function(item) {
550             egSelectDialog.open(
551                 egCore.strings.SELECT_TFORM, tlist, item.transform.label,
552                 {ok : function(value) {
553                     if (value) {
554                         var t = egReportTemplateSvc.getTransformByLabel(value);
555                         item.transform = {
556                             label     : value,
557                             transform : t,
558                             aggregate : egReportTemplateSvc.Transforms[t].aggregate ? true : false
559                         };
560                     }
561                 }}
562             );
563         });
564
565         fgrid.refresh();
566     }
567
568     $scope.changeOperator = function (items) {
569
570         var flist = [];
571         Object.keys(egReportTemplateSvc.Filters).forEach(function(k){
572             var v = egReportTemplateSvc.Filters[k];
573             if (flist.indexOf(v.label) == -1) flist.push(v.label);
574             if (v.labels && v.labels.length > 0) {
575                 v.labels.forEach(function(l) {
576                     if (flist.indexOf(l) == -1) flist.push(l);
577                 })
578             }
579         });
580
581         items.forEach(function(item) {
582             var l = item.operator ? item.operator.label : '';
583             egSelectDialog.open(
584                 egCore.strings.SELECT_OP, flist, l,
585                 {ok : function(value) {
586                     if (value) {
587                         var t = egReportTemplateSvc.getFilterByLabel(value);
588                         item.operator = { label: value, op : t };
589
590                         //Update the filter value based on the new operator, because
591                         //  different operators treat the value differently
592                         egReportTemplateSvc.updateFilterValue(item, egReportTemplateSvc.filter_fields[item.index].value);
593                     }
594                 }}
595             );
596         });
597
598         fgrid.refresh();
599     }
600
601     $scope.removeFilterValue = function (items) {
602         items.forEach(function(item) {delete egReportTemplateSvc.filter_fields[item.index].value});
603         fgrid.refresh();
604     }
605
606     $scope.removeFilterField = function (items) {
607         items.forEach(function(item) {egReportTemplateSvc.removeField('filter_fields', item)});
608         fgrid.refresh();
609     }
610
611     $scope.allSources = values(egCore.idl.classes).sort( function(a,b) {
612         if (a.core && !b.core) return -1;
613         if (b.core && !a.core) return 1;
614         aname = a.label ? a.label : a.name;
615         bname = b.label ? b.label : b.name;
616         if (aname > bname) return 1;
617         return -1;
618     });
619
620     $scope.class_tree = [];
621     $scope.selected_source = null;
622     $scope.selected_source_fields = [];
623     $scope.selected_source_field_list = [];
624     $scope.available_field_transforms = [];
625     $scope.coreSource = null;
626     $scope.coreSourceChosen = false;
627     $scope.currentPathLabel = '';
628
629     $scope.treeExpand = function (node, expanding) {
630         if (expanding) node.children.map(egCore.idl.classTree.fleshNode);
631     }
632
633     $scope.filterFields = function (n) {
634         return n.virtual ? false : true;
635         // should we hide links?
636         return n.datatype && n.datatype != 'link'
637     }
638
639     $scope.field_tree_opts = {
640         multiSelection: true,
641         equality      : function(node1, node2) {
642             return node1.name == node2.name;
643         }
644     }
645
646     $scope.field_transforms_tree_opts = {
647         equality : function(node1, node2) {
648             if (!node2) return false;
649             return node1.transform == node2.transform;
650         }
651     }
652
653     $scope.selectFields = function () {
654         while ($scope.available_field_transforms.length) {
655             $scope.available_field_transforms.pop();
656         }
657
658         angular.forEach( $scope.selected_source_field_list, function (f) {
659             angular.forEach(egReportTemplateSvc.Transforms, function (o,n) {
660                 if ( o.datatype.indexOf(f.datatype) > -1) {
661                     var include = true;
662
663                     angular.forEach($scope.available_field_transforms, function (t) {
664                         if (t.transform == n) include = false;
665                     });
666
667                     if (include) $scope.available_field_transforms.push({
668                         transform : n,
669                         label     : o.label,
670                         aggregate : o.aggregate ? true : false
671                     });
672                 }
673             });
674         });
675
676     }
677
678     $scope.selectSource = function (node, selected, $path) {
679
680         while ($scope.selected_source_field_list.length) {
681             $scope.selected_source_field_list.pop();
682         }
683         while ($scope.selected_source_fields.length) {
684             $scope.selected_source_fields.pop();
685         }
686
687         if (selected) {
688             $scope.currentPath = angular.copy( $path().reverse() );
689             $scope.selected_source = node;
690             $scope.currentPathLabel = $scope.currentPath.map(function(n,i){
691                 var l = n.label
692                 if (i && n.jtype) l += ' (' + n.jtype + ')';
693                 return l;
694             }).join( ' -> ' );
695             angular.forEach( node.fields, function (f) {
696                 $scope.selected_source_fields.push( f );
697             });
698         } else {
699             $scope.currentPathLabel = '';
700         }
701
702         // console.log($scope.selected_source);
703     }
704
705     $scope.changeCoreSource = function (new_core) {
706         console.log('changeCoreSource: '+new_core);
707         function change_core () {
708             if (new_core) $scope.coreSource = new_core;
709             $scope.coreSourceChosen = true;
710
711             $scope.class_tree.pop();
712             $scope.class_tree.push(
713                 egCore.idl.classTree.setTop($scope.coreSource)
714             );
715
716             while ($scope.selected_source_fields.length) {
717                 $scope.selected_source_fields.pop();
718             }
719
720             while ($scope.available_field_transforms.length) {
721                 $scope.available_field_transforms.pop();
722             }
723
724             $scope.currentPathLabel = '';
725         }
726
727         if ($scope.coreSourceChosen) {
728             egConfirmDialog.open(
729                 egCore.strings.FOLDERS_TEMPLATE,
730                 egCore.strings.SOURCE_SETUP_CONFIRM_EXIT,
731                 {ok : change_core}
732             );
733         } else {
734             change_core();
735         }
736     }
737
738     loadTemplate();
739 }])
740
741 ;