diff --git a/src/editors/templates/lnodetype-wizard.ts b/src/editors/templates/lnodetype-wizard.ts index 24b2950063..aaaecabf92 100644 --- a/src/editors/templates/lnodetype-wizard.ts +++ b/src/editors/templates/lnodetype-wizard.ts @@ -29,8 +29,10 @@ import { Replace, selector, Wizard, + WizardAction, WizardActor, WizardInput, + WizardMenuActor, } from '../../foundation.js'; import { WizardSelect } from '../../wizard-select.js'; import { @@ -42,6 +44,18 @@ import { WizardOptions, } from './foundation.js'; +function remove(element: Element): WizardMenuActor { + return (): EditorAction[] => { + return [{ old: { parent: element.parentElement!, element } }]; + }; +} + +function openAddDo(parent: Element): WizardMenuActor { + return (): WizardAction[] => { + return [() => dOWizard({ parent })!]; + }; +} + function updateDoAction(element: Element): WizardActor { return (inputs: WizardInput[]): EditorAction[] => { const name = getValue(inputs.find(i => i.label === 'name')!)!; @@ -613,25 +627,19 @@ export function lNodeTypeWizard( label: get('save'), action: updateLNodeTypeAction(lnodetype), }, + menuActions: [ + { + label: get('remove'), + icon: 'delete', + action: remove(lnodetype), + }, + { + label: get('scl.DO'), + icon: 'playlist_add', + action: openAddDo(lnodetype), + }, + ], content: [ - html` { - e.target!.dispatchEvent(newWizardEvent()); - e.target!.dispatchEvent( - newActionEvent({ - old: { - parent: lnodetype.parentElement!, - element: lnodetype, - reference: lnodetype.nextSibling, - }, - }) - ); - }} - fullwidth - > `, html``, - html` { - const wizard = dOWizard({ - parent: lnodetype, - }); - if (wizard) e.target!.dispatchEvent(newSubWizardEvent(wizard)); - }} - >`, html` -
- + + + - + + + [remove] + + + delete + + + + + [scl.DO] + + + playlist_add + + + + +
- - { ) ); deleteButton = ( - parent.wizardUI.dialog?.querySelector('mwc-button[icon="delete"]') + parent.wizardUI.dialog?.querySelector('mwc-menu > mwc-list-item') ); }); @@ -505,9 +505,7 @@ describe('LNodeType wizards', () => { await parent.requestUpdate(); await new Promise(resolve => setTimeout(resolve, 100)); // await animation (( - parent.wizardUI.dialog?.querySelectorAll( - 'mwc-button[icon="playlist_add"]' - )[0] + parent.wizardUI.dialog?.querySelectorAll('mwc-menu > mwc-list-item')[1] )).click(); await parent.requestUpdate(); await new Promise(resolve => setTimeout(resolve, 100)); // await animation