@@ -227,7 +227,6 @@ export const HRQuerySourceBase: React.FunctionComponent<HRQuerySourceProps> = (p
227227 let operators : string [ ] = [ ] ;
228228
229229 input = input . trim ( ) ;
230- console . log ( "input" , input ) ;
231230 for ( let i = 0 ; i < input . length ; i ++ ) {
232231 const char = input [ i ] ;
233232
@@ -259,30 +258,31 @@ export const HRQuerySourceBase: React.FunctionComponent<HRQuerySourceProps> = (p
259258 return groups ;
260259}
261260
262- function parseSegment ( segment : string ) : Group {
261+ function parseSegment ( segment : string , groupOperator ?: string ) : Group {
263262 if ( segment . includes ( '(' ) && segment . includes ( ')' ) ) {
264263 let children : Group [ ] = [ ] ;
265264 const innerSegments = segment . match ( / \( ( .* ?) \) / g) ?. map ( innerSegment => innerSegment . replace ( / ^ \( | \) $ / g, '' ) ) ;
266-
265+ const contentOutsideParentheses = segment . replace ( / \s * \( [ ^ ) ] * \) \s * / g , '||' ) . split ( '||' ) ;
267266 if ( innerSegments ) {
268- innerSegments . forEach ( ( innerSegment ) => {
269- const childGroup = parseSegment ( innerSegment ) ;
267+ innerSegments . forEach ( ( innerSegment , index ) => {
268+ const childGroup = parseSegment ( innerSegment , contentOutsideParentheses && contentOutsideParentheses . length >= 0 ? contentOutsideParentheses [ index + 1 ] : "" ) ;
270269 children . push ( childGroup ) ;
271270 } ) ;
272271 }
273272
274273 let start = segment . indexOf ( '(' ) ;
275274 let end = segment . lastIndexOf ( ')' ) ;
276275 let remainingSegment = segment . substring ( 0 , start ) + segment . substring ( end + 1 ) ;
276+ var match = remainingSegment . match ( / \s * ( O r | A n d ) \s * $ / i) ;
277+ var operator = match ? match [ 1 ] : null ;
277278 remainingSegment = remainingSegment . replace ( / \s * ( O r | A n d ) \s * $ / , '' ) . trim ( ) ;
278279
279280 if ( remainingSegment ) {
280- console . log ( "Remaining segment:" , remainingSegment ) ;
281281 return {
282282 name : '' ,
283283 items : parseSegment ( remainingSegment ) . items ,
284284 children : children ,
285- andOr : ''
285+ andOr : operator ?? ''
286286 } ;
287287 }
288288 }
@@ -299,23 +299,24 @@ function parseSegment(segment: string): Group {
299299 name : '' ,
300300 items,
301301 children : [ ] ,
302- andOr : ''
302+ andOr : groupOperator ?? ''
303303 } ;
304304}
305305
306306function setItemsBasedOnGroups ( groups : Group [ ] ) {
307307 let items : IFilterPart [ ] = [ ] ;
308308 groups . forEach ( group => {
309309 items . push ( ...group . items ) ;
310+ group . children . forEach ( child => {
311+ items . push ( ...child . items ) ;
312+ } ) ;
310313 setItemsBasedOnGroups ( group . children ) ;
311314 } ) ;
312315 setItems ( items ) ;
313316}
314317
315318const getGroupLabels = ( groups : Group [ ] ) => {
316319 const str = stringifyGroups ( groups ) ;
317- console . log ( "groups" , groups ) ;
318- console . log ( "str" , str ) ;
319320 setGroupQuery ( str ) ;
320321 const groupQuery = str ;
321322 const groupingEnabled = true ;
@@ -1076,12 +1077,16 @@ const checkType = (value: string, type: string | undefined): string => {
10761077 )
10771078 ) ;
10781079 case 'remove' :
1079- return < ActionButton
1080- className = { classNames . removeButton }
1081- iconProps = { { iconName : "Blocked2" } }
1082- onClick = { ( ) => removeComponent ( index ?? - 1 ) } >
1083- { strings . remove }
1084- </ ActionButton > ;
1080+ return (
1081+ ! groupingEnabled ? (
1082+ < ActionButton
1083+ className = { classNames . removeButton }
1084+ iconProps = { { iconName : "Blocked2" } }
1085+ onClick = { ( ) => removeComponent ( index ?? - 1 ) } >
1086+ { strings . remove }
1087+ </ ActionButton >
1088+ ) : ( < div /> )
1089+ ) ;
10851090 default :
10861091 return (
10871092 < div >
@@ -1277,7 +1282,6 @@ const checkType = (value: string, type: string | undefined): string => {
12771282 setGroupingEnabled ( true ) ;
12781283 }
12791284
1280-
12811285 function onGroupClick ( ) {
12821286 let newGroups = [ ...groups ] ;
12831287 let indices : { selectedItemIndex : number , groupIndex : number ; childIndex : number } [ ] = [ ] ;
0 commit comments