1
1
<template >
2
- <QInfiniteScroll
3
- ref =" infiniteScroll"
4
- :disable =" !canFetchPast"
5
- @load =" maybeFetchPast"
6
- >
7
- <KSpinner v-show =" isPending" />
8
- <HistoryEntry
9
- v-for =" entry in history"
10
- :key =" entry.id"
11
- :entry =" entry"
12
- />
13
- <div v-if =" empty" >
14
- <QIcon name =" fas fa-bug" />
15
- {{ $t('HISTORY.NOTHING_HAPPENEND') }}
2
+ <div >
3
+ <div
4
+ v-if =" history.length > 0"
5
+ class =" row no-wrap items-center justify-between bg-white q-px-sm q-py-xs"
6
+ >
7
+ <div class =" row q-gutter-sm" >
8
+ <QSelect
9
+ v-model =" historyType"
10
+ :options =" historyTypeOptions"
11
+ emit-value
12
+ map-options
13
+ outlined
14
+ hide-bottom-space
15
+ dense
16
+ />
17
+ <QSelect
18
+ v-model =" userId"
19
+ :options =" usersOptions"
20
+ emit-value
21
+ map-options
22
+ outlined
23
+ hide-bottom-space
24
+ dense
25
+ />
26
+ </div >
27
+ <div class =" text-caption q-ml-xs" >
28
+ {{ filteredHistory.length }} / {{ history.length }}
29
+ </div >
16
30
</div >
17
- <template v-slot :loading >
18
- <KSpinner />
19
- </template >
20
- </QInfiniteScroll >
31
+ <QInfiniteScroll
32
+ ref =" infiniteScroll"
33
+ :disable =" !canFetchPast"
34
+ @load =" maybeFetchPast"
35
+ >
36
+ <KSpinner v-show =" isPending" />
37
+ <HistoryEntry
38
+ v-for =" entry in filteredHistory"
39
+ :key =" entry.id"
40
+ :entry =" entry"
41
+ />
42
+ <div v-if =" empty" >
43
+ <QIcon name =" fas fa-bug" />
44
+ {{ $t('HISTORY.NOTHING_HAPPENEND') }}
45
+ </div >
46
+ <template v-slot :loading >
47
+ <KSpinner />
48
+ </template >
49
+ </QInfiniteScroll >
50
+ </div >
21
51
</template >
22
52
23
53
<script >
24
54
import {
25
55
QIcon ,
26
56
QInfiniteScroll ,
57
+ QSelect ,
27
58
} from ' quasar'
28
59
import paginationMixin from ' @/utils/mixins/paginationMixin'
29
60
import statusMixin from ' @/utils/mixins/statusMixin'
61
+ import bindRoute from ' @/utils/mixins/bindRoute'
30
62
import HistoryEntry from ' @/history/components/HistoryEntry'
31
63
import KSpinner from ' @/utils/components/KSpinner'
32
64
33
65
export default {
34
66
components: {
35
67
QIcon,
36
68
QInfiniteScroll,
69
+ QSelect,
37
70
HistoryEntry,
38
71
KSpinner,
39
72
},
40
- mixins: [statusMixin, paginationMixin],
73
+ mixins: [
74
+ statusMixin,
75
+ paginationMixin,
76
+ bindRoute ({
77
+ historyType: ' all' ,
78
+ userId: ' all' ,
79
+ }),
80
+ ],
41
81
props: {
42
82
history: { required: true , type: Array },
43
83
status: { default: null , type: Object },
@@ -46,9 +86,57 @@ export default {
46
86
empty () {
47
87
return ! this .history .length && ! this .status .pending && ! this .status .hasValidationErrors
48
88
},
89
+ historyTypeOptions () {
90
+ return [
91
+ {
92
+ label: ` all types (${ this .history .length } )` ,
93
+ value: ' all' ,
94
+ },
95
+ ... (Object .entries (this .history .reduce ((acc , cur ) => {
96
+ acc[cur .typus ] = 1 + (acc[cur .typus ] || 0 )
97
+ return acc
98
+ }, {})).map (([typus , count ]) => ({
99
+ label: ` ${ this .historyTypeMessage (typus)} (${ count} )` ,
100
+ value: typus,
101
+ }))),
102
+ ]
103
+ },
104
+ usersOptions () {
105
+ return [
106
+ {
107
+ label: ` all users (${ this .history .length } )` ,
108
+ value: ' all' ,
109
+ },
110
+ ... (Object .entries (this .history .reduce ((acc , cur ) => {
111
+ cur .users .forEach (u => {
112
+ if (! acc[u .id ]) acc[u .id ] = { user: u, count: 0 }
113
+ acc[u .id ].count = 1 + acc[u .id ].count
114
+ })
115
+ return acc
116
+ }, {})).map (([_ , { user, count }]) => ({
117
+ label: ` ${ user .displayName } (${ count} )` ,
118
+ value: user .id ,
119
+ }))),
120
+ ]
121
+ },
122
+ filteredHistory () {
123
+ if (! this .history ) return []
124
+ let filtered = this .history
125
+ if (this .historyType !== ' all' ) filtered = filtered .filter (e => this .historyType === e .typus )
126
+ if (this .userId !== ' all' ) filtered = filtered .filter (e => e .users .map (u => u .id ).includes (parseInt (this .userId )))
127
+ return filtered
128
+ },
129
+ },
130
+ watch: {
131
+ ' $route.query' (val) {
132
+ console .log (' refetch' , this .$route .params , this .$route .query )
133
+ this .$store .dispatch (' history/fetch' , { ... this .$route .params , ... this .$route .query })
134
+ },
135
+ },
136
+ methods: {
137
+ historyTypeMessage (typus ) {
138
+ return this .$t (' HISTORY.' + typus .toUpperCase (), { storeName: ' ...' , name: ' ...' , applicantName: ' ...' })
139
+ },
49
140
},
50
141
}
51
142
</script >
52
-
53
- <style scoped lang="stylus">
54
- </style >
0 commit comments