72
72
73
73
<f7-col v-show =" ready && items.length > 0" >
74
74
<f7-block-title class =" no-margin-top" >
75
- <span >{{ getListSize() }} <template v-if =" $refs .searchbar ?.f7Searchbar .query " >of {{ items.length }} </template >Items<template v-if =" $refs .searchbar ?.f7Searchbar .query " > found</template ></span >
76
- <template v-if =" showCheckboxes && getListSize () > 0 " >
75
+ <span >
76
+ {{ listTitle }}
77
+ </span >
78
+ <template v-if =" showCheckboxes && filteredItemsCount > 0 " >
77
79
-
78
- <f7-link @click =" selectDeselectAll" :text =" areAllSelected() ? 'Deselect all' : 'Select all'" />
80
+ <f7-link @click =" selectDeselectAll" :text =" allSelected ? 'Deselect all' : 'Select all'" />
79
81
</template >
80
82
</f7-block-title >
81
83
<f7-list
@@ -171,6 +173,7 @@ export default {
171
173
renderExternal: this .renderExternal ,
172
174
height: this .height
173
175
},
176
+ searchQuery: ' ' ,
174
177
selectedItems: [],
175
178
showCheckboxes: false ,
176
179
eventSource: null
@@ -228,7 +231,8 @@ export default {
228
231
this .$oh .sse .close (this .eventSource )
229
232
this .eventSource = null
230
233
},
231
- filterSelectedItems (query ) {
234
+ filterSelectedItems (event ) {
235
+ this .searchQuery = event ? .query
232
236
if (! this .$refs .itemsList .f7VirtualList .filteredItems ) {
233
237
return
234
238
}
@@ -251,12 +255,6 @@ export default {
251
255
renderExternal (vl , vlData ) {
252
256
this .vlData = vlData
253
257
},
254
- getListSize () {
255
- if (this .$refs .searchbar ? .f7Searchbar .query ) {
256
- return this .$refs .itemsList .f7VirtualList .filteredItems .length
257
- }
258
- return this .items .length
259
- },
260
258
height (item ) {
261
259
let vlHeight
262
260
if (this .$theme .ios ) vlHeight = 78
@@ -299,11 +297,8 @@ export default {
299
297
this .selectedItems .push (item)
300
298
}
301
299
},
302
- areAllSelected () {
303
- return this .selectedItems .length >= this .getListSize ()
304
- },
305
300
selectDeselectAll () {
306
- if (this .areAllSelected () ) {
301
+ if (this .allSelected ) {
307
302
this .selectedItems = []
308
303
} else if (this .$refs .itemsList .f7VirtualList .filteredItems ? .length > 0 ) {
309
304
this .selectedItems = this .$refs .itemsList .f7VirtualList .filteredItems .map ((i ) => i .name )
@@ -366,6 +361,27 @@ export default {
366
361
computed: {
367
362
searchPlaceholder () {
368
363
return window .innerWidth >= 1280 ? ' Search (for advanced search, use the developer sidebar (Shift+Alt+D))' : ' Search'
364
+ },
365
+ filteredItemsCount () {
366
+ if (this .searchQuery ) {
367
+ return this .$refs .itemsList .f7VirtualList .filteredItems .length
368
+ }
369
+ return this .items .length
370
+ },
371
+ allSelected () {
372
+ return this .selectedItems .length >= this .filteredItemsCount
373
+ },
374
+ listTitle () {
375
+ let title = this .filteredItemsCount
376
+ if (this .searchQuery !== ' ' ) {
377
+ title += ` of ${ this .items .length } Items found`
378
+ } else {
379
+ title += ' Items'
380
+ }
381
+ if (this .selectedItems .length > 0 ) {
382
+ title += ` , ${ this .selectedItems .length } selected`
383
+ }
384
+ return title
369
385
}
370
386
}
371
387
}
0 commit comments