@@ -12,7 +12,7 @@ use function_history_backend_thread::types::{
12
12
} ;
13
13
use git_function_history:: { types:: Directions , Commit , FileFilterType , Filter , FunctionHistory } ;
14
14
use itertools:: Itertools ;
15
- use types:: HistoryFilterType ;
15
+ use types:: { HistoryFilterType , PLFilter } ;
16
16
17
17
// TODO: stop cloning everyting and use references instead
18
18
pub struct MyEguiApp {
@@ -398,37 +398,13 @@ impl eframe::App for MyEguiApp {
398
398
HistoryFilterType :: None ,
399
399
"none" ,
400
400
) ;
401
- function_grep:: filter:: Filters :: default ( )
402
- . into_iter ( )
403
- . sorted_by_cached_key ( |( key, _) | {
404
- key. clone ( )
405
- } )
406
- . for_each ( |filter| {
407
- ui. selectable_value (
408
- & mut self . history_filter_type ,
409
- HistoryFilterType :: PL (
410
- if let function_grep:: filter:: FilterType :: All ( filter) =
411
- filter. 1
412
- {
413
- filter
414
- . attributes ( )
415
- . into_iter ( )
416
- . map ( |( attr, kind) | {
417
- (
418
- attr. to_string (
419
- ) ,
420
- kind. to_string (
421
- ) ,
422
- )
423
- } )
424
- . collect ( )
425
- } else {
426
- HashMap :: new ( )
427
- } ,
428
- filter. 1 ,
429
- ) ,
430
- filter. 0 ,
431
- ) ;
401
+ function_grep:: filter:: Filters :: default ( ) . into_iter ( ) . sorted_by_cached_key ( |( key, _) | { key. clone ( ) } ) . for_each ( |filter| { ui. selectable_value ( & mut self . history_filter_type , match filter. 1 { function_grep:: filter:: FilterType :: All ( allfilter) => { HistoryFilterType :: PL ( types:: PLFilter :: Single ( allfilter . attributes ( ) . into_iter ( ) . map ( |( attr, kind) | { ( attr. to_string ( ) , kind. to_string ( ) , ) } ) . collect ( ) , filter. 1 ) ) } function_grep:: filter:: FilterType :: Single ( allfilter) => { HistoryFilterType :: PL ( types:: PLFilter :: Single ( allfilter . attributes ( ) . into_iter ( ) . map ( |( attr, kind) | { ( attr. to_string ( ) , kind. to_string ( ) , ) } ) . collect ( ) , filter. 1 ) ) }
402
+
403
+
404
+ function_grep:: filter:: SingleOrMany :: Many ( ref filters) => {
405
+ let collect_vec = filters. filters . keys ( ) . cloned ( ) . collect_vec ( ) ;
406
+ HistoryFilterType :: PL ( types:: PLFilter :: Many ( HashMap :: new ( ) , filter. 1 , collect_vec, None , String :: new ( ) ) )
407
+ } } , filter. 0 , ) ;
432
408
} )
433
409
} ) ;
434
410
match & mut self . history_filter_type {
@@ -445,33 +421,52 @@ impl eframe::App for MyEguiApp {
445
421
HistoryFilterType :: None => {
446
422
// do nothing
447
423
}
448
- HistoryFilterType :: PL ( inputs, filters) => {
449
- inputs. iter_mut ( ) . for_each ( |( desc, field) | {
424
+ HistoryFilterType :: PL ( filter ) => {
425
+ match filter {
426
+ types:: PLFilter :: Single ( inputs, _) => {
427
+ inputs. iter_mut ( ) . for_each ( |( desc, field ) | {
450
428
ui. horizontal ( |ui| {
451
429
ui. set_min_width ( 4.0 ) ;
452
430
ui. set_max_width ( max) ;
453
431
ui. label ( desc. to_string ( ) ) ;
454
432
ui. add ( TextEdit :: singleline ( field) ) ;
455
433
} ) ;
456
- if let function_grep:: filter:: FilterType :: Many ( _) = filters {
434
+ } ) ;
435
+ }
436
+ types:: PLFilter :: Many ( inputs, filters, languages, specific, next_field ) => {
437
+ // TODO: cleanup
438
+ inputs. iter_mut ( ) . for_each ( |( desc, field ) | {
439
+ ui. horizontal ( |ui| {
440
+ ui. set_min_width ( 4.0 ) ;
441
+ ui. set_max_width ( max) ;
442
+ ui. label ( desc. to_string ( ) ) ;
443
+ ui. add ( TextEdit :: singleline ( & mut field. 1 ) ) ;
444
+ // TODO: make - work
445
+ field. 0 = ui. add ( Button :: new ( "-" ) ) . clicked ( ) ;
446
+ } ) ;
447
+ } ) ;
457
448
458
- // TODO: update history filter type
459
- // hashmap to keep track of if a field
460
- // is removed
461
- let resp = ui. add ( Button :: new ( "-" ) ) ;
462
- if resp. clicked ( ) {
463
- }
464
- }
465
- } ) ;
466
- if let function_grep:: filter:: FilterType :: Many ( _) = filters {
449
+ ui. add ( TextEdit :: singleline ( next_field) ) ;
467
450
let resp = ui. add ( Button :: new ( "add field" ) ) ;
468
451
if resp. clicked ( ) {
469
- let total = inputs. len ( ) + 1 ;
470
- inputs. insert ( format ! ( "field{total}" ) , String :: new ( ) ) ;
452
+ inputs. insert ( next_field. to_string ( ) , ( false , String :: new ( ) ) ) ;
471
453
}
472
- }
454
+
455
+ egui:: ComboBox :: from_id_source ( "filter_language_chooser" )
456
+ . selected_text ( "Language" )
457
+ . show_ui ( ui, |ui| {
458
+ ui. selectable_value (
459
+ specific, None , "All" ) ;
460
+ languages. iter ( ) . for_each ( |name| { ui. selectable_value ( specific, Some ( name. to_string ( ) ) , name) ; } ) ;
461
+ }
462
+
463
+ ) ;
464
+ if let Some ( language) = specific {
465
+ * filter = PLFilter :: Single ( HashMap :: new ( ) , filters. specific ( language) . unwrap ( ) ) ;
466
+ }
467
+
473
468
}
474
- }
469
+ } } }
475
470
let resp = ui. add ( Button :: new ( "Go" ) ) ;
476
471
if resp. clicked ( ) {
477
472
self . status = Status :: Loading ;
@@ -503,14 +498,13 @@ impl eframe::App for MyEguiApp {
503
498
self . status = Status :: Ok ( None ) ;
504
499
None
505
500
}
506
- HistoryFilterType :: PL ( input, filter) => {
507
- let filter = filter. to_filter (
508
- & input
509
- . values ( )
510
- . cloned ( )
511
- . collect :: < Vec < _ > > ( )
512
- . join ( " " ) ,
513
- ) ;
501
+ HistoryFilterType :: PL ( filter) => {
502
+ let filter = match filter {
503
+ types:: PLFilter :: Single ( hash_map, single_or_many) => single_or_many. to_filter ( & hash_map. into_iter ( ) . map ( |v| format ! ( "{}: {}" , v. 0 , v. 1 ) ) . collect_vec ( ) . join ( " " ) ) ,
504
+ types:: PLFilter :: Many ( input, filter, _, _, _) =>
505
+ filter. to_filter ( & input. into_iter ( ) . map ( |v| format ! ( "{}: {}" , v. 0 , v. 1.1 ) ) . collect_vec ( ) . join ( " " ) )
506
+
507
+ } ;
514
508
filter
515
509
. inspect_err ( |e| {
516
510
self . status =
0 commit comments