Skip to content

Commit cf12bce

Browse files
authored
Merge pull request #2780 from tarekquao/master
Column type icon matches the datatype type of the field in column selectors (where, group by, sortby, filter)
2 parents 788e11c + 7110dd0 commit cf12bce

4 files changed

Lines changed: 28 additions & 5 deletions

File tree

rust/perspective-viewer/src/rust/components/column_selector/config_selector.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ impl Component for ConfigSelector {
514514
html_nested! {
515515
<PivotColumn
516516
dragdrop={ &ctx.props().dragdrop }
517+
session={ &ctx.props().session }
517518
action={ DragTarget::GroupBy }
518519
column={ group_by.clone() }>
519520
</PivotColumn>
@@ -540,6 +541,7 @@ impl Component for ConfigSelector {
540541
html_nested! {
541542
<PivotColumn
542543
dragdrop={ &ctx.props().dragdrop }
544+
session={ &ctx.props().session }
543545
action={ DragTarget::SplitBy }
544546
column={ split_by.clone() }>
545547
</PivotColumn>

rust/perspective-viewer/src/rust/components/column_selector/filter_column.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ impl Component for FilterColumn {
458458
}
459459
.unwrap_or_default();
460460

461+
let final_col_type = col_type.expect("Unknown column");
462+
461463
html! {
462464
<div
463465
class="pivot-column-draggable"
@@ -467,7 +469,8 @@ impl Component for FilterColumn {
467469
>
468470
<LocalStyle href={css!("filter-item")} />
469471
<div class="pivot-column-border">
470-
<TypeIcon ty={ColumnType::String} />
472+
// <TypeIcon ty={ColumnType::String} />
473+
<TypeIcon ty={final_col_type} />
471474
<span class="column_name">{ filter.column().to_owned() }</span>
472475
<FilterOpSelector
473476
class="filterop-selector"

rust/perspective-viewer/src/rust/components/column_selector/pivot_column.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@
1010
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
1111
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1212

13-
use perspective_client::ColumnType;
13+
// use perspective_client::ColumnType;
1414
use web_sys::*;
1515
use yew::prelude::*;
1616

1717
use crate::components::containers::dragdrop_list::*;
1818
use crate::components::type_icon::TypeIcon;
1919
use crate::dragdrop::*;
20+
use crate::session::*;
2021

2122
pub struct PivotColumn {}
2223

2324
#[derive(Properties)]
2425
pub struct PivotColumnProps {
26+
pub session: Session,
2527
pub column: String,
2628
pub dragdrop: DragDrop,
2729
pub action: DragTarget,
@@ -61,6 +63,13 @@ impl Component for PivotColumn {
6163
move |_event| dragdrop.notify_drag_end()
6264
});
6365

66+
let col_type = ctx
67+
.props()
68+
.session
69+
.metadata()
70+
.get_column_table_type(&ctx.props().column)
71+
.expect("Unknown column");
72+
6473
html! {
6574
<div
6675
class="pivot-column-draggable"
@@ -69,7 +78,8 @@ impl Component for PivotColumn {
6978
ondragend={dragend}
7079
>
7180
<div class="pivot-column-border">
72-
<TypeIcon ty={ColumnType::String} />
81+
<TypeIcon ty={col_type} />
82+
// <TypeIcon ty={ColumnType::String} />
7383
<span class="column_name">{ ctx.props().column.clone() }</span>
7484
</div>
7585
</div>

rust/perspective-viewer/src/rust/components/column_selector/sort_column.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1212

1313
use perspective_client::config::*;
14-
use perspective_client::ColumnType;
14+
// use perspective_client::ColumnType;
1515
use web_sys::*;
1616
use yew::prelude::*;
1717

@@ -101,6 +101,13 @@ impl Component for SortColumn {
101101
move |_event| dragdrop.notify_drag_end()
102102
});
103103

104+
let col_type = ctx
105+
.props()
106+
.session
107+
.metadata()
108+
.get_column_table_type(&ctx.props().sort.0.to_owned())
109+
.expect("Unknown column");
110+
104111
html! {
105112
<div
106113
class="pivot-column-draggable"
@@ -109,7 +116,8 @@ impl Component for SortColumn {
109116
ondragend={dragend}
110117
>
111118
<div class="pivot-column-border">
112-
<TypeIcon ty={ColumnType::String} />
119+
<TypeIcon ty={col_type} />
120+
// <TypeIcon ty={ColumnType::String} />
113121
<span class="column_name">{ ctx.props().sort.0.to_owned() }</span>
114122
<span
115123
class={format!("sort-icon {}", ctx.props().sort.1)}

0 commit comments

Comments
 (0)