@@ -120,6 +120,8 @@ pub struct DPNSScreen {
120
120
/// Sorting
121
121
sort_column : SortColumn ,
122
122
sort_order : SortOrder ,
123
+ active_filter_term : String ,
124
+ past_filter_term : String ,
123
125
124
126
/// Which sub-screen is active: Active contests, Past, Owned, or Scheduled
125
127
pub dpns_subscreen : DPNSSubscreen ,
@@ -188,6 +190,8 @@ impl DPNSScreen {
188
190
message : None ,
189
191
sort_column : SortColumn :: ContestedName ,
190
192
sort_order : SortOrder :: Ascending ,
193
+ active_filter_term : String :: new ( ) ,
194
+ past_filter_term : String :: new ( ) ,
191
195
scheduled_vote_cast_in_progress : false ,
192
196
pending_backend_task : None ,
193
197
dpns_subscreen,
@@ -339,9 +343,31 @@ impl DPNSScreen {
339
343
340
344
/// Show the Active Contests table
341
345
fn render_table_active_contests ( & mut self , ui : & mut Ui ) {
346
+ ui. horizontal ( |ui| {
347
+ ui. label ( "Filter names:" ) ;
348
+ ui. text_edit_singleline ( & mut self . active_filter_term ) ;
349
+ } ) ;
350
+
342
351
let contested_names = {
343
352
let guard = self . contested_names . lock ( ) . unwrap ( ) ;
344
353
let mut cn = guard. clone ( ) ;
354
+ if !self . active_filter_term . is_empty ( ) {
355
+ let mut filter_lc = self . active_filter_term . to_lowercase ( ) ;
356
+ // Convert o and O to 0 and l to 1 in filter_lc
357
+ filter_lc = filter_lc
358
+ . chars ( )
359
+ . map ( |c| match c {
360
+ 'o' | 'O' => '0' ,
361
+ 'l' => '1' ,
362
+ _ => c,
363
+ } )
364
+ . collect ( ) ;
365
+ cn. retain ( |c| {
366
+ c. normalized_contested_name
367
+ . to_lowercase ( )
368
+ . contains ( & filter_lc)
369
+ } ) ;
370
+ }
345
371
self . sort_contested_names ( & mut cn) ;
346
372
cn
347
373
} ;
@@ -667,10 +693,34 @@ impl DPNSScreen {
667
693
668
694
/// Show a Past Contests table
669
695
fn render_table_past_contests ( & mut self , ui : & mut Ui ) {
696
+ ui. horizontal ( |ui| {
697
+ ui. label ( "Filter names:" ) ;
698
+ ui. text_edit_singleline ( & mut self . past_filter_term ) ;
699
+ } ) ;
700
+
670
701
let contested_names = {
671
702
let guard = self . contested_names . lock ( ) . unwrap ( ) ;
672
703
let mut cn = guard. clone ( ) ;
673
704
cn. retain ( |c| c. awarded_to . is_some ( ) || c. state == ContestState :: Locked ) ;
705
+ // 1) Filter by `active_filter_term`
706
+ if !self . past_filter_term . is_empty ( ) {
707
+ let mut filter_lc = self . past_filter_term . to_lowercase ( ) ;
708
+ // Convert o and O to 0 and l to 1 in filter_lc
709
+ filter_lc = filter_lc
710
+ . chars ( )
711
+ . map ( |c| match c {
712
+ 'o' | 'O' => '0' ,
713
+ 'l' => '1' ,
714
+ _ => c,
715
+ } )
716
+ . collect ( ) ;
717
+
718
+ cn. retain ( |c| {
719
+ c. normalized_contested_name
720
+ . to_lowercase ( )
721
+ . contains ( & filter_lc)
722
+ } ) ;
723
+ }
674
724
self . sort_contested_names ( & mut cn) ;
675
725
cn
676
726
} ;
@@ -784,7 +834,13 @@ impl DPNSScreen {
784
834
ui. label ( "Active" ) ;
785
835
}
786
836
ContestState :: WonBy ( identifier) => {
787
- ui. label ( identifier. to_string ( Encoding :: Base58 ) ) ;
837
+ ui. add (
838
+ egui:: Label :: new (
839
+ identifier. to_string ( Encoding :: Base58 ) ,
840
+ )
841
+ . sense ( egui:: Sense :: hover ( ) )
842
+ . truncate ( ) ,
843
+ ) ;
788
844
}
789
845
ContestState :: Locked => {
790
846
ui. label ( "Locked" ) ;
0 commit comments