75141233f24dad2d13e4c8695a35492275274584
[dlux.git] / modules / yangman-resources / src / main / resources / yangman / controllers / form / choice.controller.js
1 define([], function () {
2     'use strict';
3
4     angular.module('app.yangman').controller('ChoiceCtrl', ChoiceCtrl);
5
6     ChoiceCtrl.$inject = ['$scope', 'constants'];
7
8     function ChoiceCtrl($scope, constants){
9         var yangChoice = this;
10
11         $scope.constants = constants;
12
13         // methods
14         yangChoice.isActionMenu = isActionMenu;
15         $scope.caseShowing = caseShowing;
16         yangChoice.toggleExpanded = toggleExpanded;
17
18         /**
19          * Show hide node
20          */
21         function toggleExpanded() {
22             $scope.node.expanded = !$scope.node.expanded;
23         }
24
25         // TODO :: do method description
26         function caseShowing(node) {
27             return !node.augmentationId ? true :
28                                     $scope.augmentations.getAugmentation(node.parent, node.augmentationId).expanded;
29         }
30
31         /**
32          * Show hide action menu
33          * @returns {boolean|*}
34          */
35         function isActionMenu() {
36             return $scope.node.augmentionGroups && $scope.node.augmentionGroups.length;
37         }
38     }
39 });
40