/
ArtistList.ts
72 lines (60 loc) · 2.1 KB
/
ArtistList.ts
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import ViewBase from '../Bases/ViewBase';
import Component from 'vue-class-component';
import ArtistStore from '../../Models/Artists/ArtistStore';
import SelectionItem from '../Shared/SelectionItem';
import Artist from 'src/ts/Models/Artists/Artist';
import Vue from 'vue';
import { default as InfiniteLoading, StateChanger } from 'vue-infinite-loading';
Vue.use(InfiniteLoading);
@Component({
template: `<div class="col-md-2 h-100">
<div class="card h-100">
<div class="card-header with-border bg-info">
<h3 class="card-title">Artists</h3>
<div class="card-tools">
<button type="button"
class="btn btn-tool"
@click="OnClickRemove" >
<i class="fa fa-remove" />
</button>
</div>
</div>
<div class="card-body list-scrollable">
<ul class="nav nav-pills h-100 d-flex flex-column flex-nowrap">
<template v-for="entity in entities">
<selection-item
ref="Items"
v-bind:entity="entity"
@click="OnClickItem" />
</template>
<infinite-loading @infinite="OnInfinite"></infinite-loading>
</ul>
</div>
</div>
</div>`,
components: {
'selection-item': SelectionItem
}
})
export default class ArtistList extends ViewBase {
private store: ArtistStore = new ArtistStore();
private page: number = 1;
private genreIds: number[] = [];
private entities: Artist[] = [];
private async OnInfinite($state: StateChanger): Promise<boolean> {
var result = await this.store.GetList(this.genreIds, this.page);
if (0 < result.ResultList.length)
this.entities = this.entities.concat(result.ResultList);
if (this.entities.length < result.TotalLength) {
$state.loaded();
this.page++;
} else {
$state.complete();
}
return true;
}
private OnClickRemove(): void {
}
private OnClickItem(): void {
}
}