@@ -29,6 +29,7 @@ import {
29
29
WizardInput ,
30
30
Delete ,
31
31
getUniqueElementName ,
32
+ ComplexAction ,
32
33
} from '../foundation.js' ;
33
34
import { FinderList } from '../finder-list.js' ;
34
35
import { dataAttributePicker , iEDPicker } from './foundation/finder.js' ;
@@ -327,8 +328,10 @@ function prepareReportControlCreateWizard(anyParent: Element): WizardActor {
327
328
} ;
328
329
}
329
330
330
- export function removeReportControlAction ( element : Element ) : Delete [ ] {
331
- if ( ! element . parentElement ) return [ ] ;
331
+ export function removeReportControlAction (
332
+ element : Element
333
+ ) : ComplexAction | null {
334
+ if ( ! element . parentElement ) return null ;
332
335
333
336
const dataSet = element . parentElement . querySelector (
334
337
`DataSet[name="${ element . getAttribute ( 'datSet' ) } "]`
@@ -358,11 +361,17 @@ export function removeReportControlAction(element: Element): Delete[] {
358
361
old : {
359
362
parent : element . parentElement ! ,
360
363
element : dataSet ,
361
- reference : element . nextSibling ,
364
+ reference : dataSet . nextSibling ,
362
365
} ,
363
366
} ) ;
364
367
365
- return actions ;
368
+ const name = element . getAttribute ( 'name' ) ! ;
369
+ const iedName = element . closest ( 'IED' ) ?. getAttribute ( 'name' ) ?? '' ;
370
+
371
+ return {
372
+ title : get ( 'controlblock.action.remove' , { type : 'Report' , name, iedName } ) ,
373
+ actions,
374
+ } ;
366
375
}
367
376
368
377
function getRptEnabledAction (
@@ -420,7 +429,7 @@ function updateReportControlAction(element: Element): WizardActor {
420
429
421
430
const max = getValue ( inputs . find ( i => i . label === 'max Clients' ) ! ) ;
422
431
423
- let rptEnabledAction : EditorAction | null = null ;
432
+ let rptEnabledAction : SimpleAction | null = null ;
424
433
if (
425
434
max !== ( element . querySelector ( 'RptEnabled' ) ?. getAttribute ( 'max' ) ?? null )
426
435
)
@@ -430,10 +439,22 @@ function updateReportControlAction(element: Element): WizardActor {
430
439
element
431
440
) ;
432
441
433
- const actions : EditorAction [ ] = [ ] ;
442
+ const actions : SimpleAction [ ] = [ ] ;
434
443
if ( reportControlAction ) actions . push ( reportControlAction ) ;
435
444
if ( rptEnabledAction ) actions . push ( rptEnabledAction ) ;
436
- return actions ;
445
+
446
+ const name = attributes [ 'name' ] ! ;
447
+ const iedName = element . closest ( 'IED' ) ! . getAttribute ( 'name' ) ! ;
448
+ const complexAction = {
449
+ title : get ( 'controlblock.action.edit' , {
450
+ type : 'Report' ,
451
+ name,
452
+ iedName,
453
+ } ) ,
454
+ actions,
455
+ } ;
456
+
457
+ return actions . length ? [ complexAction ] : [ ] ;
437
458
} ;
438
459
}
439
460
@@ -515,10 +536,10 @@ export function editReportControlWizard(element: Element): Wizard {
515
536
label ="${ translate ( 'remove' ) } "
516
537
icon ="delete "
517
538
@click =${ ( e : MouseEvent ) => {
518
- const deleteActions = removeReportControlAction ( element ) ;
519
- deleteActions . forEach ( deleteAction =>
520
- e . target ?. dispatchEvent ( newActionEvent ( deleteAction ) )
521
- ) ;
539
+ const complexAction = removeReportControlAction ( element ) ;
540
+ if ( complexAction )
541
+ e . target ?. dispatchEvent ( newActionEvent ( complexAction ) ) ;
542
+
522
543
e . target ?. dispatchEvent ( newWizardEvent ( ) ) ;
523
544
} }
524
545
> </ mwc-button > ` ,
0 commit comments