5
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
*/
7
7
8
- import { Box , Checkbox , Tooltip , IconButton , Menu , MenuItem } from '@mui/material' ;
8
+ import { Box , Checkbox , Tooltip } from '@mui/material' ;
9
9
import { Theme } from '@mui/material/styles' ;
10
10
import { ReactNode , useEffect , useRef , useState } from 'react' ;
11
- import CalculateIcon from '@mui/icons-material/Calculate' ;
12
- import { useDispatch , useSelector } from 'react-redux' ;
13
- import { setCalculationSelections } from '../../redux/actions' ;
14
- import { AppState } from '../../redux/reducer' ;
15
11
16
12
import { isBlankOrEmpty } from 'components/utils/validation-functions' ;
17
13
import { ICellRendererParams } from 'ag-grid-community' ;
18
14
import { CustomCellRendererProps } from 'ag-grid-react' ;
19
15
import { mergeSx } from '@gridsuite/commons-ui' ;
20
- import { useIntl } from 'react-intl' ;
21
- import { CalculationRowType , CalculationType } from '../spreadsheet-view/types/calculation.type' ;
22
- import { isCalculationRow } from '../spreadsheet-view/utils/calculation-utils' ;
23
16
24
17
const styles = {
25
18
tableCell : ( theme : Theme ) => ( {
@@ -42,18 +35,6 @@ const styles = {
42
35
numericValue : {
43
36
marginLeft : 'inherit' ,
44
37
} ,
45
- menuItemLabel : {
46
- marginLeft : 1 ,
47
- } ,
48
- calculationButton : {
49
- position : 'absolute' ,
50
- top : '50%' ,
51
- left : '50%' ,
52
- transform : 'translate(-50%, -50%)' ,
53
- padding : 0 ,
54
- minWidth : 'auto' ,
55
- minHeight : 'auto' ,
56
- } ,
57
38
} ;
58
39
59
40
export const BooleanCellRenderer = ( props : any ) => {
@@ -265,115 +246,3 @@ export const ContingencyCellRenderer = ({ value }: { value: { cellValue: ReactNo
265
246
</ Box >
266
247
) ;
267
248
} ;
268
-
269
- export const RowIndexCellRenderer = ( props : CustomCellRendererProps ) => {
270
- const [ anchorEl , setAnchorEl ] = useState < null | HTMLElement > ( null ) ;
271
- const open = Boolean ( anchorEl ) ;
272
-
273
- const intl = useIntl ( ) ;
274
-
275
- // Get tab UUID from context passed via column definition
276
- const tabUuid = props . colDef ?. context ?. tabUuid || '' ;
277
-
278
- const dispatch = useDispatch ( ) ;
279
- const calculationSelections = useSelector ( ( state : AppState ) => state . calculationSelections ) ;
280
-
281
- // Get selections for current tab
282
- const selections = calculationSelections [ tabUuid ] || [ ] ;
283
-
284
- const handleClick = ( event : React . MouseEvent < HTMLElement > ) => {
285
- setAnchorEl ( event . currentTarget ) ;
286
- } ;
287
-
288
- const handleClose = ( ) => {
289
- setAnchorEl ( null ) ;
290
- } ;
291
-
292
- const handleSelectionChange = ( option : CalculationType ) => {
293
- const newSelections = selections . includes ( option )
294
- ? selections . filter ( ( item ) => item !== option )
295
- : [ ...selections , option ] ;
296
-
297
- dispatch ( setCalculationSelections ( tabUuid , newSelections ) ) ;
298
- } ;
299
-
300
- if ( isCalculationRow ( props . data ?. rowType ) ) {
301
- if ( props . data ?. rowType === CalculationRowType . CALCULATION_BUTTON ) {
302
- return (
303
- < Box style = { { display : 'flex' , justifyContent : 'center' , alignItems : 'center' , height : '100%' } } >
304
- < IconButton size = "small" aria-label = "calculate" onClick = { handleClick } sx = { styles . calculationButton } >
305
- < CalculateIcon fontSize = "small" />
306
- </ IconButton >
307
- < Menu anchorEl = { anchorEl } open = { open } onClose = { handleClose } >
308
- < MenuItem dense onClick = { ( ) => handleSelectionChange ( CalculationType . AVERAGE ) } >
309
- < Checkbox
310
- checked = { selections . includes ( CalculationType . AVERAGE ) }
311
- size = "small"
312
- disableRipple
313
- />
314
- < Box sx = { styles . menuItemLabel } >
315
- { intl . formatMessage ( { id : 'spreadsheet/calculation/average' } ) }
316
- </ Box >
317
- </ MenuItem >
318
- < MenuItem dense onClick = { ( ) => handleSelectionChange ( CalculationType . SUM ) } >
319
- < Checkbox checked = { selections . includes ( CalculationType . SUM ) } size = "small" disableRipple />
320
- < Box sx = { styles . menuItemLabel } >
321
- { intl . formatMessage ( { id : 'spreadsheet/calculation/sum' } ) }
322
- </ Box >
323
- </ MenuItem >
324
- < MenuItem dense onClick = { ( ) => handleSelectionChange ( CalculationType . MIN ) } >
325
- < Checkbox checked = { selections . includes ( CalculationType . MIN ) } size = "small" disableRipple />
326
- < Box sx = { styles . menuItemLabel } >
327
- { intl . formatMessage ( { id : 'spreadsheet/calculation/min' } ) }
328
- </ Box >
329
- </ MenuItem >
330
- < MenuItem dense onClick = { ( ) => handleSelectionChange ( CalculationType . MAX ) } >
331
- < Checkbox checked = { selections . includes ( CalculationType . MAX ) } size = "small" disableRipple />
332
- < Box sx = { styles . menuItemLabel } >
333
- { intl . formatMessage ( { id : 'spreadsheet/calculation/max' } ) }
334
- </ Box >
335
- </ MenuItem >
336
- </ Menu >
337
- </ Box >
338
- ) ;
339
- }
340
-
341
- // Row with calculation results - show appropriate label
342
- if ( props . data ?. rowType === CalculationRowType . CALCULATION ) {
343
- let label = '' ;
344
- switch ( props . data . calculationType ) {
345
- case CalculationType . SUM :
346
- label = intl . formatMessage ( { id : 'spreadsheet/calculation/sum_abbrev' } ) ;
347
- break ;
348
- case CalculationType . AVERAGE :
349
- label = intl . formatMessage ( { id : 'spreadsheet/calculation/average_abbrev' } ) ;
350
- break ;
351
- case CalculationType . MIN :
352
- label = intl . formatMessage ( { id : 'spreadsheet/calculation/min_abbrev' } ) ;
353
- break ;
354
- case CalculationType . MAX :
355
- label = intl . formatMessage ( { id : 'spreadsheet/calculation/max_abbrev' } ) ;
356
- break ;
357
- }
358
-
359
- return (
360
- < Box
361
- style = { {
362
- display : 'flex' ,
363
- justifyContent : 'center' ,
364
- alignItems : 'center' ,
365
- height : '100%' ,
366
- fontWeight : 'bold' ,
367
- } }
368
- >
369
- { label }
370
- </ Box >
371
- ) ;
372
- }
373
-
374
- return null ;
375
- }
376
-
377
- // For normal rows, return the row index number
378
- return props . value ;
379
- } ;
0 commit comments