@@ -23,6 +23,7 @@ pub struct Data {
23
23
pub filter : Option < FilterConfig > ,
24
24
rows : Vec < LogRow > ,
25
25
filtered_rows : Option < Vec < usize > > ,
26
+ applied_filter : Option < FilterConfig > ,
26
27
}
27
28
28
29
#[ derive( serde:: Deserialize , serde:: Serialize , Default , Debug , PartialEq , Eq , Clone ) ]
@@ -174,7 +175,7 @@ impl Data {
174
175
// Collect other needed info before taking mutable borrow to appease the borrow checker (couldn't find another readable way)
175
176
let is_filtered = self . is_filtered ( ) ;
176
177
let filter = if is_filtered {
177
- self . filter . clone ( )
178
+ self . applied_filter . clone ( )
178
179
} else {
179
180
None
180
181
} ;
@@ -235,12 +236,14 @@ impl Data {
235
236
}
236
237
237
238
pub fn is_filtered ( & self ) -> bool {
239
+ debug_assert_eq ! ( self . applied_filter. is_some( ) , self . filtered_rows. is_some( ) ) ;
238
240
self . filtered_rows . is_some ( )
239
241
}
240
242
241
243
pub fn unfilter ( & mut self ) {
242
244
let previous_real_index_selected = self . selected_row . map ( |x| self . get_real_index ( x) ) ;
243
245
self . filtered_rows = None ;
246
+ self . applied_filter = None ;
244
247
if let Some ( old_selected) = previous_real_index_selected {
245
248
self . selected_row = Some ( old_selected) ;
246
249
}
@@ -250,6 +253,7 @@ impl Data {
250
253
if let Some ( filter) = self . filter . as_ref ( ) {
251
254
let previous_real_index_selected = self . selected_row . map ( |x| self . get_real_index ( x) ) ;
252
255
256
+ self . applied_filter = self . filter . clone ( ) ;
253
257
self . filtered_rows = Some (
254
258
self . rows
255
259
. iter_mut ( )
@@ -285,6 +289,26 @@ impl Data {
285
289
}
286
290
}
287
291
}
292
+
293
+ pub fn applied_filter_display ( & self ) -> String {
294
+ let Some ( FilterConfig {
295
+ search_key,
296
+ filter_on,
297
+ is_case_sensitive,
298
+ comparator,
299
+ } ) = self . applied_filter . as_ref ( )
300
+ else {
301
+ debug_assert ! ( false , "We really shouldn't end up here" ) ;
302
+ return "No Filter Applied" . to_string ( ) ;
303
+ } ;
304
+ format ! (
305
+ "Search Key: {search_key} | Filter On: {filter_on} | Case Sensitive: {} | Comparator: {comparator}" ,
306
+ if * is_case_sensitive {
307
+ "Yes"
308
+ } else {
309
+ "No"
310
+ } )
311
+ }
288
312
}
289
313
290
314
/// If the slice of fields and values matches the filter then the indices of the fields that match are returned or None if it does not match
0 commit comments