Skip to content

Commit

Permalink
refactor(editors/template): use subwizard option (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobVogelsang authored Feb 27, 2022
1 parent f00092a commit d24537b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
7 changes: 3 additions & 4 deletions src/editors/templates/datype-wizards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
getValue,
identity,
newActionEvent,
newSubWizardEvent,
newWizardEvent,
patterns,
selector,
Expand Down Expand Up @@ -95,9 +96,8 @@ export function editDaTypeWizard(
@click=${(e: Event) => {
if (datype)
e.target!.dispatchEvent(
newWizardEvent(createBDAWizard(datype))
newSubWizardEvent(createBDAWizard(datype))
);
e.target!.dispatchEvent(newWizardEvent());
}}
></mwc-button>
<mwc-list
Expand All @@ -107,8 +107,7 @@ export function editDaTypeWizard(
const bda = doc.querySelector(selector('BDA', bdaIdentity));
if (bda)
e.target!.dispatchEvent(newWizardEvent(editBDAWizard(bda)));
e.target!.dispatchEvent(newWizardEvent());
e.target!.dispatchEvent(newSubWizardEvent(editBDAWizard(bda)));
}}
>
${Array.from(datype.querySelectorAll('BDA')).map(
Expand Down
12 changes: 6 additions & 6 deletions src/editors/templates/dotype-wizards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
identity,
isPublic,
newActionEvent,
newSubWizardEvent,
newWizardEvent,
selector,
Wizard,
Expand Down Expand Up @@ -391,8 +392,7 @@ export function dOTypeWizard(
const wizard = sDOWizard({
parent: dotype,
});
if (wizard) e.target!.dispatchEvent(newWizardEvent(wizard));
e.target!.dispatchEvent(newWizardEvent());
if (wizard) e.target!.dispatchEvent(newSubWizardEvent(wizard));
}}
></mwc-button>
<mwc-button
Expand All @@ -402,8 +402,9 @@ export function dOTypeWizard(
label="${translate('scl.DA')}"
@click=${(e: Event) => {
if (dotype)
e.target!.dispatchEvent(newWizardEvent(createDaWizard(dotype)));
e.target!.dispatchEvent(newWizardEvent());
e.target!.dispatchEvent(
newSubWizardEvent(createDaWizard(dotype))
);
}}
></mwc-button>
</section>`,
Expand All @@ -425,8 +426,7 @@ export function dOTypeWizard(
doc,
});
if (wizard) e.target!.dispatchEvent(newWizardEvent(wizard));
e.target!.dispatchEvent(newWizardEvent());
if (wizard) e.target!.dispatchEvent(newSubWizardEvent(wizard));
}}
>
${Array.from(dotype.querySelectorAll('SDO, DA')).map(
Expand Down
7 changes: 3 additions & 4 deletions src/editors/templates/enumtype-wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
identity,
isPublic,
newActionEvent,
newSubWizardEvent,
newWizardEvent,
patterns,
selector,
Expand Down Expand Up @@ -317,8 +318,7 @@ export function eNumTypeEditWizard(
const wizard = eNumValWizard({
parent: enumtype,
});
if (wizard) e.target!.dispatchEvent(newWizardEvent(wizard));
e.target!.dispatchEvent(newWizardEvent());
if (wizard) e.target!.dispatchEvent(newSubWizardEvent(wizard));
}}
></mwc-button>
<mwc-list
Expand All @@ -328,8 +328,7 @@ export function eNumTypeEditWizard(
identity: (<ListItem>(<List>e.target).selected).value,
doc,
});
if (wizard) e.target!.dispatchEvent(newWizardEvent(wizard));
e.target!.dispatchEvent(newWizardEvent());
if (wizard) e.target!.dispatchEvent(newSubWizardEvent(wizard));
}}
>${Array.from(enumtype.querySelectorAll('EnumVal')).map(
enumval =>
Expand Down
7 changes: 3 additions & 4 deletions src/editors/templates/lnodetype-wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
identity,
isPublic,
newActionEvent,
newSubWizardEvent,
newWizardEvent,
patterns,
selector,
Expand Down Expand Up @@ -601,8 +602,7 @@ export function lNodeTypeWizard(
const wizard = dOWizard({
parent: lnodetype,
});
if (wizard) e.target!.dispatchEvent(newWizardEvent(wizard));
e.target!.dispatchEvent(newWizardEvent());
if (wizard) e.target!.dispatchEvent(newSubWizardEvent(wizard));
}}
></mwc-button>`,
html`
Expand All @@ -614,8 +614,7 @@ export function lNodeTypeWizard(
doc,
});
if (wizard) e.target!.dispatchEvent(newWizardEvent(wizard));
e.target!.dispatchEvent(newWizardEvent());
if (wizard) e.target!.dispatchEvent(newSubWizardEvent(wizard));
}}
>
${Array.from(lnodetype.querySelectorAll('DO')).map(
Expand Down
2 changes: 2 additions & 0 deletions src/wizards/abstractda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { maxLength, patterns } from './foundation/limits.js';
import { predefinedBasicTypeEnum, valKindEnum } from './foundation/enums.js';

function selectType(e: SelectedEvent, data: Element, Val: string | null): void {
if (!e.target || !(e.target as Select).parentElement) return;

const typeSelected = (<Select>e.target).selected?.value;
const selectedBType = (<WizardSelect>(
(<Select>e.target).parentElement!.querySelector(
Expand Down

0 comments on commit d24537b

Please sign in to comment.