src/NOSQL/Public/js/composer/property.js   A
last analyzed

Complexity

Total Complexity 10
Complexity/F 1.67

Size

Lines of Code 50
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 10
eloc 31
c 0
b 0
f 0
dl 0
loc 50
rs 10
mnd 4
bc 4
fnc 6
bpm 0.6666
cpm 1.6666
noi 1
1
app.controller('PropertyCtrl', ['$scope', '$msgSrv', '$timeout', '$log',
2
    ($scope, $msgSrv, $timeout, $log) => {
3
        $scope.show = false;
4
5
        $scope.getPropertyLegend = () => {
6
            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...
7
            try {
8
                label = $scope.model['name'];
9
                if($scope.model.type) {
10
                    label += ' (' + $scope.model.type + ')';
11
                }
12
            } catch(err) {
13
                $log.warn(err.message);
14
            }
15
16
            return label;
17
        };
18
19
        $scope.togglePropertyForm = () => {
20
            $scope.show = !$scope.show;
21
            if($scope.show) {
22
                $msgSrv.send('property.edit', $scope.model.id);
23
            }
24
        };
25
26
        $scope.removeProperty = () => {
27
            $msgSrv.send('property.remove', $scope.index);
28
        };
29
30
        $scope.$on('property.edit', (ev, id) => {
31
            if($scope.model.id !== id) {
32
                $scope.show = false;
33
            }
34
        });
35
36
    }
37
]);
38
app.directive('property', [() => {
39
    return {
40
        restrict: 'E',
41
        replace: true,
42
        controller: 'PropertyCtrl',
43
        templateUrl: '/js/composer/property.html',
44
        scope: {
45
            types: '=',
46
            model: '=',
47
            index: '='
48
        }
49
    };
50
}]);