13
13
</chat-header >
14
14
<template v-if =" ! addNewChat && isExpanded " >
15
15
<div class =" chat-side__body" >
16
- <div class =" chat-side__search" >
17
- <i class =" fa fa-search" ></i >
18
- <input
19
- class =" seach-input"
20
- type =" text"
21
- placeholder =" Search ..."
22
- v-model =" search"
23
- />
24
- <i class =" fa fa-sliders-h" ></i >
25
- </div >
16
+ <div class =" chat-side__header" >
17
+ <div class =" chat-side__search" >
18
+ <i class =" fa fa-search" ></i >
19
+ <input
20
+ class =" seach-input"
21
+ type =" text"
22
+ placeholder =" Search ..."
23
+ v-model =" search"
24
+ />
25
+ <div class =" chat-side__action-container"
26
+ :class =" {'showing-filters': showFilters}"
27
+ @click =" showFilters=!showFilters" >
28
+ <i class =" fa fa-sliders-h" ></i >
29
+ </div >
30
+
31
+ </div >
32
+ <div class =" chat-side__filters" v-if =" showFilters" >
33
+ <button
34
+ v-for =" (filter, filterName) in filters"
35
+ class =" btn btn-tab"
36
+ :class =" {selected: selectedFilter == filterName}"
37
+ :key =" filterName"
38
+ @click =" selectedFilter = filterName"
39
+ >
40
+ {{ filter.label }}
41
+ </button >
42
+ </div >
43
+ </div >
26
44
27
45
<div class =" chat-side__list chat-scroller" >
28
46
<chat-side-item
54
72
<script >
55
73
import ChatHeader from " ./header" ;
56
74
import ChatSideItem from " ./side-list-item" ;
75
+ import Fuse from " fuse.js" ;
57
76
58
77
export default {
59
78
name: " ChatSider" ,
@@ -93,6 +112,30 @@ export default {
93
112
return {
94
113
channelData: {},
95
114
search: " " ,
115
+ showFilters: false ,
116
+ selectedFilter: ' all' ,
117
+ filters: {
118
+ all: {
119
+ value: ' ' ,
120
+ label: " All Messages" ,
121
+ field: ' '
122
+ },
123
+ active: {
124
+ label: ' Active' ,
125
+ value: 0 ,
126
+ field: ' status'
127
+ },
128
+ won: {
129
+ label: ' Won' ,
130
+ value: 1 ,
131
+ field: ' status'
132
+ },
133
+ lost: {
134
+ label: ' Lost' ,
135
+ value: 2 ,
136
+ field: ' status'
137
+ }
138
+ },
96
139
addNewChat: false ,
97
140
};
98
141
},
@@ -130,15 +173,11 @@ export default {
130
173
}, 0 );
131
174
},
132
175
133
- filteredChannels () {
134
- return this .channels
135
- .filter ((channel ) => {
136
- return (
137
- channel .lastMessage && channel .uniqueName .includes (this .search )
138
- );
139
- })
176
+ visibleChannels () {
177
+ const selectedFilter = this .filters [this .selectedFilter ].value ;
178
+ return this .channels .filter (channel => channel .lastMessage && (! selectedFilter || channel .attributes .status == selectedFilter))
140
179
.sort ((a , b ) => {
141
- const dateCreatedA = a .lastMessage
180
+ const dateCreatedA = a .lastMessage
142
181
? a .lastMessage .dateCreated .toISOString ()
143
182
: " " ;
144
183
const dateCreatedB = b .lastMessage
@@ -147,6 +186,29 @@ export default {
147
186
return dateCreatedA > dateCreatedB ? - 1 : 1 ;
148
187
});
149
188
},
189
+
190
+ filteredChannels () {
191
+ const options = {
192
+ // isCaseSensitive: false,
193
+ // includeScore: false,
194
+ // shouldSort: true,
195
+ // includeMatches: false,
196
+ // findAllMatches: false,
197
+ // minMatchCharLength: 1,
198
+ // location: 0,
199
+ threshold: 0.2 ,
200
+ distance: 50 ,
201
+ // useExtendedSearch: false,
202
+ // ignoreLocation: false,
203
+ // ignoreFieldNorm: false,
204
+ keys: [
205
+ " friendlyName"
206
+ ]
207
+ };
208
+
209
+ const fuse = new Fuse (this .visibleChannels , options);
210
+ return ! this .search ? this .visibleChannels : fuse .search (this .search || " " ).map ( item => item .item )
211
+ },
150
212
profileImage () {
151
213
return this .userContext .user .attributes ? this .userContext .user .attributes .photoUrl : " " ;
152
214
}
@@ -279,6 +341,7 @@ export default {
279
341
padding : 0 15px ;
280
342
color : #777 ;
281
343
position : relative ;
344
+ overflow : hidden ;
282
345
input {
283
346
height : 36px ;
284
347
border : none ;
@@ -292,6 +355,40 @@ export default {
292
355
}
293
356
}
294
357
358
+ & __action-container {
359
+ height : 100% ;
360
+ width : 40px ;
361
+ display : flex ;
362
+ justify-content : center ;
363
+ align-items : center ;
364
+ margin-right : -15px ;
365
+ cursor : pointer ;
366
+
367
+ & .showing-filters {
368
+ font-weight : bolder ;
369
+ color : #333 ;
370
+ background : #e4e4e4 ;
371
+ }
372
+ }
373
+
374
+ & __filters {
375
+ width : 100% ;
376
+ display : flex ;
377
+
378
+ .btn-tab {
379
+ width : 100% ;
380
+ border-radius : 0 0 0 0 ;
381
+ & :active , & :focus {
382
+ box-shadow : none ;
383
+ }
384
+ & .selected {
385
+ background : #cacaca ;
386
+ font-weight : bold ;
387
+ }
388
+ }
389
+
390
+ }
391
+
295
392
& __body {
296
393
height : 91% ;
297
394
display : flex ;
0 commit comments