diff --git a/src/wizards/reportcontrol.ts b/src/wizards/reportcontrol.ts index c3205863e3..de3f2d78f1 100644 --- a/src/wizards/reportcontrol.ts +++ b/src/wizards/reportcontrol.ts @@ -20,8 +20,6 @@ import { identity, isPublic, newSubWizardEvent, - newWizardEvent, - newActionEvent, selector, SimpleAction, Wizard, @@ -30,6 +28,9 @@ import { Delete, getUniqueElementName, ComplexAction, + WizardMenuActor, + WizardAction, + MenuAction, } from '../foundation.js'; import { FinderList } from '../finder-list.js'; import { dataAttributePicker, iEDPicker } from './foundation/finder.js'; @@ -399,6 +400,32 @@ function getRptEnabledAction( }; } +export function removeReportControl(element: Element): WizardMenuActor { + return (): WizardAction[] => { + const complexAction = removeReportControlAction(element); + if (complexAction) return [complexAction]; + return []; + }; +} + +function openDataSetWizard(element: Element): WizardMenuActor { + return (): WizardAction[] => { + return [() => editDataSetWizard(element)]; + }; +} + +function openTrgOpsWizard(element: Element): WizardMenuActor { + return (): WizardAction[] => { + return [() => editTrgOpsWizard(element)]; + }; +} + +function openOptFieldsWizard(element: Element): WizardMenuActor { + return (): WizardAction[] => { + return [() => editOptFieldsWizard(element)]; + }; +} + function updateReportControlAction(element: Element): WizardActor { return (inputs: WizardInput[]): EditorAction[] => { const attributes: Record = {}; @@ -476,6 +503,34 @@ export function editReportControlWizard(element: Element): Wizard { `DataSet[name="${element.getAttribute('datSet')}"]` ); + const menuActions: MenuAction[] = []; + menuActions.push({ + icon: 'delete', + label: get('remove'), + action: removeReportControl(element), + }); + + if (dataSet) + menuActions.push({ + icon: 'edit', + label: get('scl.DataSet'), + action: openDataSetWizard(dataSet), + }); + + if (trgOps) + menuActions.push({ + icon: 'edit', + label: get('scl.TrgOps'), + action: openTrgOpsWizard(trgOps), + }); + + if (optFields) + menuActions.push({ + icon: 'edit', + label: get('scl.OptFields'), + action: openOptFieldsWizard(optFields), + }); + return [ { title: get('wizard.title.edit', { tagName: element.tagName }), @@ -485,6 +540,7 @@ export function editReportControlWizard(element: Element): Wizard { label: get('save'), action: updateReportControlAction(element), }, + menuActions, content: [ ...contentReportControlWizard({ name, @@ -496,53 +552,6 @@ export function editReportControlWizard(element: Element): Wizard { bufTime, intgPd, }), - dataSet - ? html` { - e.target?.dispatchEvent( - newSubWizardEvent(() => editDataSetWizard(dataSet)) - ); - }} - >` - : html``, - trgOps - ? html` { - e.target?.dispatchEvent( - newSubWizardEvent(() => editTrgOpsWizard(trgOps)) - ); - }} - >` - : html``, - optFields - ? html` { - e.target?.dispatchEvent( - newSubWizardEvent(() => editOptFieldsWizard(optFields)) - ); - }} - >` - : html``, - html` { - const complexAction = removeReportControlAction(element); - if (complexAction) - e.target?.dispatchEvent(newActionEvent(complexAction)); - - e.target?.dispatchEvent(newWizardEvent()); - }} - >`, ], }, ]; diff --git a/test/integration/wizards/reportcontrol-wizarding-editing.test.ts b/test/integration/wizards/reportcontrol-wizarding-editing.test.ts index 0e6a49bcf1..04724e6a1e 100644 --- a/test/integration/wizards/reportcontrol-wizarding-editing.test.ts +++ b/test/integration/wizards/reportcontrol-wizarding-editing.test.ts @@ -235,11 +235,15 @@ describe('Wizards for SCL element ReportControl', () => { }); it('opens edit wizard for DataSet element on edit dataset button click', async () => { - const editDataSetButton =