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 = '-'; |
|
|
|
|
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() { |
|
|
|
|
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
|
|
|
|