diff --git a/src/editors/templates/datype-wizards.ts b/src/editors/templates/datype-wizards.ts
index c26e1fa3cf..7ea4e56390 100644
--- a/src/editors/templates/datype-wizards.ts
+++ b/src/editors/templates/datype-wizards.ts
@@ -18,15 +18,15 @@ import {
EditorAction,
getValue,
identity,
- newActionEvent,
newSubWizardEvent,
- newWizardEvent,
patterns,
Replace,
selector,
Wizard,
+ WizardAction,
WizardActor,
WizardInput,
+ WizardMenuActor,
} from '../../foundation.js';
import { createBDAWizard, editBDAWizard } from '../../wizards/bda.js';
import {
@@ -35,6 +35,18 @@ import {
unifyCreateActionArray,
} from './foundation.js';
+function remove(element: Element): WizardMenuActor {
+ return (): EditorAction[] => {
+ return [{ old: { parent: element.parentElement!, element } }];
+ };
+}
+
+function openAddBda(parent: Element): WizardMenuActor {
+ return (): WizardAction[] => {
+ return [() => createBDAWizard(parent)];
+ };
+}
+
function updateDATpyeAction(element: Element): WizardActor {
return (inputs: WizardInput[]): EditorAction[] => {
const id = getValue(inputs.find(i => i.label === 'id')!)!;
@@ -88,25 +100,19 @@ export function editDaTypeWizard(
label: get('save'),
action: updateDATpyeAction(datype),
},
+ menuActions: [
+ {
+ label: get('remove'),
+ icon: 'delete',
+ action: remove(datype),
+ },
+ {
+ label: get('scl.DA'),
+ icon: 'playlist_add',
+ action: openAddBda(datype),
+ },
+ ],
content: [
- html` {
- e.target!.dispatchEvent(newWizardEvent());
- e.target!.dispatchEvent(
- newActionEvent({
- old: {
- parent: datype.parentElement!,
- element: datype,
- reference: datype.nextSibling,
- },
- })
- );
- }}
- fullwidth
- > `,
html``,
- html` {
- if (datype)
- e.target!.dispatchEvent(
- newSubWizardEvent(createBDAWizard(datype))
- );
- }}
- >
- {
- const bdaIdentity = ((e.target).selected).value;
- const bda = doc.querySelector(selector('BDA', bdaIdentity));
+ html` {
+ const bdaIdentity = ((e.target).selected).value;
+ const bda = doc.querySelector(selector('BDA', bdaIdentity));
- if (bda)
- e.target!.dispatchEvent(newSubWizardEvent(editBDAWizard(bda)));
- }}
- >
- ${Array.from(datype.querySelectorAll('BDA')).map(
- bda =>
- html`${bda.getAttribute('name')}${bda.getAttribute('bType') === 'Enum' ||
- bda.getAttribute('bType') === 'Struct'
- ? '#' + bda.getAttribute('type')
- : bda.getAttribute('bType')}`
- )}
-
`,
+ if (bda)
+ e.target!.dispatchEvent(newSubWizardEvent(editBDAWizard(bda)));
+ }}
+ >
+ ${Array.from(datype.querySelectorAll('BDA')).map(
+ bda =>
+ html`${bda.getAttribute('name')}${bda.getAttribute('bType') === 'Enum' ||
+ bda.getAttribute('bType') === 'Struct'
+ ? '#' + bda.getAttribute('type')
+ : bda.getAttribute('bType')}`
+ )}
+
`,
],
},
];
diff --git a/test/integration/editors/templates/__snapshots__/datype-wizarding.test.snap.js b/test/integration/editors/templates/__snapshots__/datype-wizarding.test.snap.js
index c15583c5a2..12f768de96 100644
--- a/test/integration/editors/templates/__snapshots__/datype-wizarding.test.snap.js
+++ b/test/integration/editors/templates/__snapshots__/datype-wizarding.test.snap.js
@@ -620,14 +620,45 @@ snapshots["DAType wizards defines a dATypeWizard looks like the latest snapshot"
heading="[datype.wizard.title.edit]"
open=""
>
-
-
+
+
+
+
+
+ [remove]
+
+
+ delete
+
+
+
+
+ [scl.DA]
+
+
+ playlist_add
+
+
+
+
+
-
-
{
)
);
deleteButton = (
- parent.wizardUI.dialog?.querySelector('mwc-button[icon="delete"]')
+ parent.wizardUI.dialog?.querySelector('mwc-menu > mwc-list-item')
);
});
diff --git a/test/integration/wizards/bda-wizarding-editing.test.ts b/test/integration/wizards/bda-wizarding-editing.test.ts
index 509daa5364..6d6de4db4b 100644
--- a/test/integration/wizards/bda-wizarding-editing.test.ts
+++ b/test/integration/wizards/bda-wizarding-editing.test.ts
@@ -132,7 +132,7 @@ describe('BDA wizarding editing integration', () => {
await parent.requestUpdate();
await new Promise(resolve => setTimeout(resolve, 100)); // await animation
((
- parent.wizardUI.dialog?.querySelector('mwc-button[icon="playlist_add"]')
+ parent.wizardUI.dialog?.querySelectorAll('mwc-menu > mwc-list-item')[1]
)).click();
await parent.requestUpdate();
await new Promise(resolve => setTimeout(resolve, 100)); // await animation