@@ -21,9 +21,11 @@ import { Column } from "react-table";
2121import { usePopper } from "react-popper" ;
2222import { HeaderContext } from "components/contexts/HeaderContext" ;
2323import { getColumnWidthStyle } from "components/styles/ColumnWidthStyle" ;
24+ import { generateSortedColumns } from "components/behavior/SortingColumns" ;
2425import { ColumnModal } from "./modals/ColumnModal" ;
2526import { HeaderMenuProps } from "cdm/HeaderModel" ;
2627import TaskIcon from "components/img/TaskIcon" ;
28+ import CrossIcon from "components/img/CrossIcon" ;
2729
2830const HeaderMenu = ( headerMenuProps : HeaderMenuProps ) => {
2931 /** state of width columns */
@@ -86,19 +88,47 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
8688 buttons . push (
8789 {
8890 onClick : ( e : any ) => {
89- setSortBy ( [ { id : column . id , desc : false } ] ) ;
91+ const sortArray = generateSortedColumns ( initialState , column , false ) ;
92+ // Update state
93+ dispatch ( {
94+ type : ActionTypes . SET_SORT_BY ,
95+ sortArray : sortArray ,
96+ } ) ;
97+ setSortBy ( sortArray ) ;
9098 setExpanded ( false ) ;
9199 } ,
92- icon : < ArrowUpIcon /> ,
93- label : "Sort ascending" ,
100+ icon :
101+ column . isSorted && ! column . isSortedDesc ? (
102+ < CrossIcon />
103+ ) : (
104+ < ArrowUpIcon />
105+ ) ,
106+ label :
107+ column . isSorted && ! column . isSortedDesc
108+ ? "Remove ascending sort"
109+ : "Sort ascending" ,
94110 } ,
95111 {
96112 onClick : ( e : any ) => {
97- setSortBy ( [ { id : column . id , desc : true } ] ) ;
113+ const sortArray = generateSortedColumns ( initialState , column , true ) ;
114+ // Update state
115+ dispatch ( {
116+ type : ActionTypes . SET_SORT_BY ,
117+ sortArray : sortArray ,
118+ } ) ;
119+ setSortBy ( sortArray ) ;
98120 setExpanded ( false ) ;
99121 } ,
100- icon : < ArrowDownIcon /> ,
101- label : "Sort descending" ,
122+ icon :
123+ column . isSorted && column . isSortedDesc ? (
124+ < CrossIcon />
125+ ) : (
126+ < ArrowDownIcon />
127+ ) ,
128+ label :
129+ column . isSorted && column . isSortedDesc
130+ ? "Remove descending sort"
131+ : "Sort descending" ,
102132 }
103133 ) ;
104134 }
@@ -218,6 +248,20 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
218248 icon : < CalendarTimeIcon /> ,
219249 label : MetadataLabels . CALENDAR_TIME ,
220250 } ,
251+ ,
252+ {
253+ onClick : ( e : any ) => {
254+ dispatch ( {
255+ type : ActionTypes . UPDATE_COLUMN_TYPE ,
256+ columnId : column . id ,
257+ dataType : DataTypes . CHECKBOX ,
258+ } ) ;
259+ setShowType ( false ) ;
260+ setExpanded ( false ) ;
261+ } ,
262+ icon : < TaskIcon /> ,
263+ label : DataTypes . CHECKBOX ,
264+ } ,
221265 ] ;
222266
223267 const typePopper = usePopper ( typeReferenceElement , typePopperElement , {
0 commit comments