Total Complexity | 10 |
Complexity/F | 1.67 |
Lines of Code | 50 |
Function Count | 6 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | app.controller('PropertyCtrl', ['$scope', '$msgSrv', '$timeout', '$log', |
||
2 | ($scope, $msgSrv, $timeout, $log) => { |
||
3 | $scope.show = false; |
||
4 | |||
5 | $scope.getPropertyLegend = () => { |
||
6 | let label = '-'; |
||
|
|||
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 | }]); |