Yangman - delete_list_item button misses in operations form
[dlux.git] / modules / yangman-resources / src / main / resources / yangman / controllers / form / ym-leaf.controller.js
1 define([], function () {
2     'use strict';
3
4     angular.module('app.yangman').controller('YMLeafCtrl', YMLeafCtrl);
5
6     YMLeafCtrl.$inject = ['$scope'];
7
8     function YMLeafCtrl($scope){
9         var types = [
10                 'binary',
11                 'bits',
12                 'boolean',
13                 'decimal64',
14                 'enumeration',
15                 'empty',
16                 'identityref',
17                 'instance-identifier',
18                 'int16',
19                 'int32',
20                 'int64',
21                 'int8',
22                 'leafref',
23                 'string',
24                 'uint16',
25                 'uint32',
26                 'uint64',
27                 'uint8',
28                 'union',
29             ],
30             yangLeaf = this;
31
32         yangLeaf.infoBox = false;
33         yangLeaf.infoBoxSection = '';
34
35         // methods
36         yangLeaf.displayValue = displayValue;
37         yangLeaf.getLeafCentering = getLeafCentering;
38         yangLeaf.getLeafType = getLeafType;
39         yangLeaf.isActionMenu = isActionMenu;
40
41
42         function getLeafCentering(){
43             return ['union', 'bits', 'empty'].indexOf(getLeafType()) > -1 ? 'start' : 'center';
44         }
45
46         /**
47          * Get leaf type
48          * @returns {*}
49          */
50         function getLeafType(){
51             var label = $scope.node.getChildren('type')[0].label;
52             return types.indexOf(label) !== -1 ? label : 'default';
53         }
54
55         function displayValue() {
56             return $scope.node.typeChild.label !== 'empty';
57         }
58
59         /**
60          * Show hide action menu
61          * @returns {boolean|*}
62          */
63         function isActionMenu() {
64             return false;
65         }
66     }
67 });
68