Passed
Push — master ( 1c5edc...aba8d4 )
by Fran
06:33 queued 03:02
created

src/NOSQL/Public/js/composer/index.js   A

Complexity

Total Complexity 11
Complexity/F 1.57

Size

Lines of Code 65
Function Count 7

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 11
eloc 42
mnd 4
bc 4
fnc 7
dl 0
loc 65
rs 10
bpm 0.5714
cpm 1.5713
noi 2
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
C index.js ➔ prepareProperties 0 15 10
1
app.controller('IndexCtrl', ['$scope', '$msgSrv', '$timeout', '$log',
2
    ($scope, $msgSrv, $timeout, $log) => {
3
        $scope.show = false;
4
        $scope.indexProperties = [];
5
6
        $scope.getIndexLegend = () => {
7
            let label = '-';
0 ignored issues
show
Unused Code introduced by
The assignment to variable label seems to be never used. Consider removing it.
Loading history...
8
            try {
9
                label = $scope.model['name'];
10
            } catch(err) {
11
                $log.warn(err.message);
12
            }
13
14
            return label;
15
        };
16
17
        $scope.toggleIndexForm = () => {
18
            $scope.show = !$scope.show;
19
            if($scope.show) {
20
                $msgSrv.send('index.edit', $scope.model.id);
21
            }
22
        };
23
24
        $scope.removeIndex = () => {
25
            $msgSrv.send('index.remove', $scope.index);
26
        };
27
28
        $scope.$on('index.edit', (ev, id) => {
29
            if($scope.model.id !== id) {
30
                $scope.show = false;
31
            }
32
        });
33
34
        function prepareProperties() {
0 ignored issues
show
Bug introduced by
The function prepareProperties is declared conditionally. This is not supported by all runtimes. Consider moving it to root scope or using var prepareProperties = function() { /* ... */ }; instead.
Loading history...
35
            for(let i in $scope.properties) {
36
                let property = $scope.properties[i];
37
                $scope.indexProperties.push({
38
                    id: property.name + '.ASC',
39
                    name: property.name,
40
                    mode: 'ASC'
41
                });
42
                $scope.indexProperties.push({
43
                    id: property.name + '.DESC',
44
                    name: property.name,
45
                    mode: 'DESC'
46
                });
47
            }
48
        }
49
50
        prepareProperties();
51
    }
52
]);
53
app.directive('indexes', [() => {
54
    return {
55
        restrict: 'E',
56
        replace: true,
57
        controller: 'IndexCtrl',
58
        templateUrl: '/js/composer/index.html',
59
        scope: {
60
            properties: '=',
61
            model: '=',
62
            index: '='
63
        }
64
    };
65
}]);
66