@@ -1144,8 +1144,31 @@ const checkType = (value: string, type: string | undefined): string => {
11441144 setChildren ( newChildren ) ;
11451145 setItems ( newItems ) ;
11461146 }
1147+ }
1148+
1149+
1150+ function onGroupUpClick ( index : number ) {
1151+ let newGroups = [ ...groups ] ;
1152+ const insertIndex = index - 1 ;
1153+ if ( insertIndex < 0 ) { return ; }
1154+
1155+ setIsDragAndDropEnabled ( true ) ;
1156+ newGroups = newGroups . filter ( ( _ , i ) => i !== index ) ;
1157+ newGroups . splice ( insertIndex , 0 , { ...groups [ index ] } ) ;
1158+
1159+ setGroups ( newGroups ) ;
1160+ }
11471161
1162+ function onGroupDownClick ( index : number ) {
1163+ let newGroups = [ ...groups ] ;
1164+ const insertIndex = index + 1 ;
1165+ if ( insertIndex > groups . length ) { return ; }
1166+
1167+ setIsDragAndDropEnabled ( true ) ;
1168+ newGroups = newGroups . filter ( ( _ , i ) => i !== index ) ;
1169+ newGroups . splice ( insertIndex , 0 , { ...groups [ index ] } ) ;
11481170
1171+ setGroups ( newGroups ) ;
11491172 }
11501173
11511174 const onRenderItemColumn = ( items : IFilterPart [ ] , item ?: any , index ?: number , column ?: IColumn ) : JSX . Element => {
@@ -1495,12 +1518,16 @@ const checkType = (value: string, type: string | undefined): string => {
14951518 dropdown : { width : 100 } ,
14961519 } ;
14971520
1498- const renderItems = ( items : IFilterPart [ ] , conjunction : string , index : number , isLastItem : boolean ) => {
1521+ const renderItems = ( items : IFilterPart [ ] , conjunction : string , index : number , isLastItem : boolean , isUpDownEnabled : boolean ) => {
14991522 const selection : Selection = new Selection ( {
15001523 onSelectionChanged : ( ) => handleSelectionChange ( selection , index )
15011524 } ) ;
15021525 return (
15031526 < div >
1527+ { isUpDownEnabled && groups . length > 1 && ( < div className = { classNames . upDown } >
1528+ < ActionButton iconProps = { { iconName : 'ChevronUp' } } onClick = { ( ) => onGroupUpClick ( index ) } style = { { marginTop : '15px' , marginBottom : '-15px' } } />
1529+ < ActionButton iconProps = { { iconName : 'ChevronDown' } } onClick = { ( ) => onGroupDownClick ( index ) } style = { { marginBottom : '-15px' } } />
1530+ </ div > ) }
15041531 < DetailsList
15051532 styles = { { root : classNames . detailsList } }
15061533 items = { items }
@@ -1519,7 +1546,7 @@ const checkType = (value: string, type: string | undefined): string => {
15191546 < div >
15201547 < Stack key = { parentIndex } >
15211548 < Stack tokens = { { childrenGap : 10 } } >
1522- { group . items . length > 0 && renderItems ( group . items , 'And' , parentIndex , parentIndex === groups . length - 1 ) }
1549+ { group . items . length > 0 && renderItems ( group . items , 'And' , parentIndex , parentIndex === groups . length - 1 , true ) }
15231550 { ( ( group . items && group . items . length > 0 && parentIndex !== groups . length - 1 ) || ( group . children && group . children . length > 0 ) ) && (
15241551 < div >
15251552 < Dropdown
@@ -1542,7 +1569,7 @@ const checkType = (value: string, type: string | undefined): string => {
15421569 < Stack key = { parentIndex + '-' + childIndex } tokens = { { childrenGap : 10 } } style = { { paddingLeft : '50px' } } >
15431570 < Label > { childGroup . name } </ Label >
15441571 < Stack tokens = { { childrenGap : 10 } } >
1545- { childGroup . items . length > 0 && renderItems ( childGroup . items , childGroup . items [ childGroup . items . length - 1 ] . andOr , parentIndex , childIndex === children . length - 1 ) }
1572+ { childGroup . items . length > 0 && renderItems ( childGroup . items , childGroup . items [ childGroup . items . length - 1 ] . andOr , parentIndex , childIndex === children . length - 1 , false ) }
15461573 { ( ( childGroup . items && childGroup . items . length > 0 && ( childIndex !== children . length - 1 || parentIndex !== groups . length - 1 ) ) || ( childGroup . children && childGroup . children . length > 0 ) ) && (
15471574 < div >
15481575 < Dropdown
0 commit comments