/
partiesList.js
58 lines (49 loc) · 1.2 KB
/
partiesList.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import angular from 'angular';
import angularMeteor from 'angular-meteor';
import uiRouter from 'angular-ui-router';
import template from './partiesList.html';
import { Parties } from '../../../api/parties';
import { name as PartyAdd } from '../partyAdd/partyAdd';
import { name as PartyRemove } from '../partyRemove/partyRemove';
class PartiesList {
constructor($scope, $reactive) {
'ngInject';
$reactive(this).attach($scope);
this.perPage = 3;
this.page = 1;
this.sort = {
name: 1
};
this.subscribe('parties', () => [{
limit: parseInt(this.perPage),
skip: parseInt((this.getReactively('page') - 1) * this.perPage),
sort: this.getReactively('sort')}
]);
this.helpers({
parties() {
return Parties.find({});
}
});
}
}
const name = 'partiesList';
// create a module
export default angular.module(name, [
angularMeteor,
uiRouter,
PartyAdd,
PartyRemove
]).component(name, {
template,
controllerAs: name,
controller: PartiesList
})
.config(config);
function config($stateProvider) {
'ngInject';
$stateProvider
.state('parties', {
url: '/parties',
template: '<parties-list></parties-list>'
});
}