@@ -129,6 +129,7 @@ export const MenuListsDropdown = () => {
129129 opsRoles,
130130 rangeSliderMinMax,
131131 rangeValue,
132+ isPercent,
132133 } = useSelector (
133134 ( state : RootState ) => state . rangeSlider as FilterObjectsState ,
134135 ) ;
@@ -226,8 +227,13 @@ export const MenuListsDropdown = () => {
226227 event : MouseEvent < HTMLLIElement > | MouseEvent < HTMLDivElement > ,
227228 ops : string [ ] ,
228229 roles ?: RolesProps [ ] ,
230+ isPercentParam ?: boolean ,
229231 ) => {
230- const { value, type, label, percent } = event . currentTarget . dataset ;
232+ const { value, type, label } = event . currentTarget . dataset ;
233+ const isPercent =
234+ value ?. includes ( 'percentage' ) ||
235+ value ?. includes ( '_ratio' ) ||
236+ isPercentParam ;
231237 event . stopPropagation ( ) ;
232238 setIsClickMenu ( ! isClickMenu ) ;
233239 let opsValue = '' ;
@@ -237,8 +243,8 @@ export const MenuListsDropdown = () => {
237243 } else {
238244 dispatch ( setKeyValueName ( value ) ) ;
239245 }
240- if ( percent ) {
241- dispatch ( setIsPercent ( Boolean ( percent ) ) ) ;
246+ if ( isPercent ) {
247+ dispatch ( setIsPercent ( Boolean ( isPercent ) ) ) ;
242248 } else {
243249 dispatch ( setIsPercent ( false ) ) ;
244250 }
@@ -456,12 +462,18 @@ export const MenuListsDropdown = () => {
456462 ( filter ) => filter . varName === varName ,
457463 ) ;
458464 if ( existingFilterIndex !== - 1 ) {
459- existingFilters [ existingFilterIndex ] . searchTerm = updateValue as number [ ] ;
465+ existingFilters [ existingFilterIndex ] . searchTerm = isPercent
466+ ? updateValue . map ( ( v ) => v / 100 )
467+ : updateValue ;
460468 existingFilters [ existingFilterIndex ] . op = opsRoles ! ;
461469 } else {
470+ const normalizedValue = isPercent
471+ ? updateValue . map ( ( v ) => v / 100 )
472+ : updateValue ;
473+
462474 const newFilter : Filter = {
463475 varName : varName ,
464- searchTerm : updateValue ! ,
476+ searchTerm : normalizedValue ,
465477 op : opsRoles ! ,
466478 label : labelVarName ,
467479 } ;
@@ -525,7 +537,8 @@ export const MenuListsDropdown = () => {
525537 if ( Array . isArray ( nodes ! ) ) {
526538 return nodes . map ( ( node : FilterMenu | ChildrenFilter , index : number ) => {
527539 const { children, var_name, type, label : nodeLabel , ops, roles } = node ;
528- const isPercent = var_name ?. includes ( 'percentage' ) ;
540+ const isPercent =
541+ var_name ?. includes ( 'percentage' ) || var_name ?. includes ( '_ratio' ) ;
529542 const hasChildren = children && children . length >= 1 ;
530543 const menuLabel = ( nodeLabel as LabelFilterMeneList ) [ languageValue ] ;
531544 const uniqueKey = `${ menuLabel } - ${ index } ` ;
@@ -549,18 +562,19 @@ export const MenuListsDropdown = () => {
549562 children : renderDropdownMenu ( children ) ,
550563 onClick : (
551564 event : MouseEvent < HTMLLIElement > | MouseEvent < HTMLDivElement > ,
552- ) => handleClickMenu ( event , ops ! , roles ! ) ,
565+ ) => handleClickMenu ( event , ops ! , roles ! , isPercent ! ) ,
553566 } ;
554567 }
555568
556569 return {
557570 key : uniqueKey ,
558571 label : menuLabel ,
559- onClick : ( event : any ) => handleClickMenu ( event , ops ! , roles ! ) ,
572+ onClick : ( event : any ) =>
573+ handleClickMenu ( event , ops ! , roles ! , isPercent ! ) ,
560574 'data-value' : var_name ,
561575 'data-type' : type ,
562576 'data-label' : menuLabel ,
563- 'data-percent' : isPercent ,
577+ 'data-is- percent' : isPercent ,
564578 } ;
565579 } ) ;
566580 }
@@ -574,6 +588,8 @@ export const MenuListsDropdown = () => {
574588 const { children, var_name, type, label : nodeLabel , ops, roles } = node ;
575589 const menuLabel = ( nodeLabel as LabelFilterMeneList ) [ languageValue ] ;
576590 const hasChildren = children && children . length >= 1 ;
591+ const isPercent =
592+ var_name ?. includes ( 'percentage' ) || var_name ?. includes ( '_ratio' ) ;
577593
578594 if ( hasChildren ) {
579595 return {
@@ -595,11 +611,12 @@ export const MenuListsDropdown = () => {
595611 value : var_name ,
596612 type : type ,
597613 label : menuLabel ,
614+ isPercent : String ( isPercent ) ,
598615 } ,
599616 } ,
600617 stopPropagation : ( ) => { } ,
601618 } as any ;
602- handleClickMenu ( mockEvent , ops ! , roles ! ) ;
619+ handleClickMenu ( mockEvent , ops ! , roles ! , isPercent ) ;
603620 } ,
604621 } ;
605622 } ) ;
@@ -771,58 +788,64 @@ export const MenuListsDropdown = () => {
771788 // Render desktop filter buttons
772789 const renderDesktopFilterButtons = ( ) => (
773790 < div className = "filter-menu-bar" >
774- { filterMenu . map ( ( item : FilterMenuList , index : number ) => {
775- const { var_name , label , type , ops } = item ;
776- const itemLabel = ( label as LabelFilterMeneList ) [ languageValue ] ;
777- return var_name ? (
778- < Button
779- key = { ` ${ itemLabel } - ${ index } ` }
780- data-value = { var_name }
781- data-type = { type }
782- data-label = { itemLabel }
783- onClick = { ( event : any ) => handleClickMenu ( event , ops ! ) }
784- style = { baseFilterButtonStyle }
785- >
786- < Tooltip
787- placement = "top"
788- title = { `Filter by ${ itemLabel } ` }
789- color = "rgba(0, 0, 0, 0.75)"
791+ { filterMenu . map (
792+ ( item : FilterMenuList | ChildrenFilter , index : number ) => {
793+ const { var_name , label, type , ops , roles } = item ;
794+ const isPercent =
795+ var_name ?. includes ( 'percentage' ) || var_name ?. includes ( '_ratio' ) ;
796+ const itemLabel = ( label as LabelFilterMeneList ) [ languageValue ] ;
797+ return var_name ? (
798+ < Button
799+ key = { ` ${ itemLabel } - ${ index } ` }
800+ data-value = { var_name }
801+ data-type = { type }
802+ data-label = { itemLabel }
803+ onClick = { ( event : any ) =>
804+ handleClickMenu ( event , ops ! , roles ! , isPercent )
805+ }
806+ style = { baseFilterButtonStyle }
790807 >
791- { itemLabel }
792- </ Tooltip >
793- </ Button >
794- ) : (
795- < DropdownCascading
796- key = { `${ itemLabel } - ${ index } ` }
797- trigger = {
798- < Button style = { baseFilterButtonStyle } >
799- < Tooltip
800- placement = "top"
801- title = { `Filter by ${ itemLabel } ` }
802- color = "rgba(0, 0, 0, 0.75)"
803- >
804- { itemLabel }
805- </ Tooltip >
806- < span style = { { marginTop : 4 } } >
807- < CaretRightOutlined
808- style = { {
809- display : isMobile ? 'inline' : 'none' ,
810- fontSize : 14 ,
811- } }
812- />
813- < CaretDownOutlined
814- style = { {
815- display : isMobile ? 'none' : 'inline' ,
816- fontSize : 16 ,
817- } }
818- />
819- </ span >
820- </ Button >
821- }
822- menu = { renderDropdownMenu ( item . children ! ) }
823- />
824- ) ;
825- } ) }
808+ < Tooltip
809+ placement = "top"
810+ title = { `Filter by ${ itemLabel } ` }
811+ color = "rgba(0, 0, 0, 0.75)"
812+ >
813+ { itemLabel }
814+ </ Tooltip >
815+ </ Button >
816+ ) : (
817+ < DropdownCascading
818+ key = { `${ itemLabel } - ${ index } ` }
819+ trigger = {
820+ < Button style = { baseFilterButtonStyle } >
821+ < Tooltip
822+ placement = "top"
823+ title = { `Filter by ${ itemLabel } ` }
824+ color = "rgba(0, 0, 0, 0.75)"
825+ >
826+ { itemLabel }
827+ </ Tooltip >
828+ < span style = { { marginTop : 4 } } >
829+ < CaretRightOutlined
830+ style = { {
831+ display : isMobile ? 'inline' : 'none' ,
832+ fontSize : 14 ,
833+ } }
834+ />
835+ < CaretDownOutlined
836+ style = { {
837+ display : isMobile ? 'none' : 'inline' ,
838+ fontSize : 16 ,
839+ } }
840+ />
841+ </ span >
842+ </ Button >
843+ }
844+ menu = { renderDropdownMenu ( item . children ! ) }
845+ />
846+ ) ;
847+ } ,
848+ ) }
826849 </ div >
827850 ) ;
828851
0 commit comments