Yangman - changed event strings to constants
[dlux.git] / modules / yangman-resources / src / main / resources / yangman / services / plugins-unsetter.services.js
1 define(['angular'], function (angular) {
2     'use strict';
3
4     angular.module('app.yangman').service('PluginsUnsetterService',
5         ['PathUtilsService', 'DataBackupService', PluginsUnsetterService]);
6
7     PluginsUnsetterService.$inject = ['constants'];
8
9     function PluginsUnsetterService(PathUtilsService, DataBackupService, constants){
10         var service = {
11             'YANGMAN_CUST_MOUNT_POINTS': unsetMountPoint,
12             unset: unset,
13         };
14
15         return service;
16
17         /**
18          * Method for unset mount point from application
19          * @param scope
20          */
21         function unsetMountPoint(scope){
22             var modulesListObj = {};
23
24             DataBackupService.getToScope(
25                 [
26                     'selectedDatastore', 'node', 'apis',
27                     'selectedApi', 'selectedSubApi', 'augmentations', 'selectedModule',
28                 ],
29                 scope,
30                 'MAIN_SCOPE'
31             );
32
33             DataBackupService.getToScope(['treeApis'], modulesListObj, 'MODULES_LIST');
34             scope.$broadcast(constants.YANGMAN_SET_API_TREE_DATA, { params: modulesListObj.treeApis });
35             scope.$broadcast(constants.YANGMAN_SET_MODULE_LIST_TITLE, { params: '' });
36
37             if ( scope.selectedDatastore ){
38                 scope.$broadcast(constants.YANGMAN_MODULE_D_INIT);
39             }
40         }
41
42         /**
43          * General method for pick correct unset method for plugins
44          * @param scope
45          * @param controller
46          */
47         function unset(scope, controller) {
48             if (service.hasOwnProperty(controller.selectedPlugin.label)) {
49                 service[controller.selectedPlugin.label](scope);
50             }
51         }
52
53     }
54
55 });