Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wizarding addon #1446

Merged
merged 38 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e236204
Feat: Added Waiter addon
pascalwilbrink Feb 12, 2024
26a362f
Fix: removed console.log
pascalwilbrink Feb 12, 2024
2a284a2
Fix: Removed .workdone
pascalwilbrink Feb 12, 2024
5541386
Fix: Removed waiting from OpenSCD
pascalwilbrink Feb 13, 2024
137612e
Fix: Added deferred promise to open-scd.test
pascalwilbrink Feb 13, 2024
5f11fd8
Fix: Added deferred promise to open-scd.test
pascalwilbrink Feb 13, 2024
12fc4d7
Fix: fixed E2E test
pascalwilbrink Feb 13, 2024
563d4c8
Removed waiting mixin
pascalwilbrink Feb 13, 2024
1a1c195
Feat: Settings addon
pascalwilbrink Feb 13, 2024
b833f9f
Fix: fixed test
pascalwilbrink Feb 13, 2024
e3d1515
Fix: updated import in themes.ts
pascalwilbrink Feb 13, 2024
4960d04
Fix: updated import in themes.ts
pascalwilbrink Feb 13, 2024
d051c91
Feat: Moved hosting into OpenSCD class
pascalwilbrink Feb 14, 2024
7a84fa2
Removed Hosting Mixin
pascalwilbrink Feb 15, 2024
e997916
Removed console.log
pascalwilbrink Feb 15, 2024
2a5bc49
Feat: Removed custom webcomponent definition in tests
pascalwilbrink Feb 15, 2024
7d4a6be
Fixed some tests
pascalwilbrink Feb 15, 2024
1d81b5a
Fixed more tests
pascalwilbrink Feb 15, 2024
9e92087
Fixed tests
pascalwilbrink Feb 15, 2024
a3470b7
Updated timeout
pascalwilbrink Feb 15, 2024
4742434
Removed dist folders
pascalwilbrink Feb 15, 2024
7cf43b8
Removed dist folder
pascalwilbrink Feb 15, 2024
ebf3714
Fixed tests
pascalwilbrink Feb 15, 2024
17d0605
Renamed wizarding.test.ts
pascalwilbrink Feb 16, 2024
328d490
Fix: Fixed some other tests
pascalwilbrink Feb 16, 2024
bd46e84
Removed dist folders
pascalwilbrink Feb 16, 2024
514b04d
Removed dist folder
pascalwilbrink Feb 16, 2024
e51a3f9
Removed console.logs
pascalwilbrink Feb 16, 2024
e59b1a3
Fixed merge conflicts
pascalwilbrink Feb 29, 2024
669d07d
Fixed merge conflicts
pascalwilbrink Feb 29, 2024
78debbc
Updated merge conflicts
pascalwilbrink Feb 29, 2024
2c469ef
Merge branch 'main' into Wizarding_Addon
pascalwilbrink Mar 1, 2024
f55d39d
Delete packages/open-scd/test/dist/mock-open-scd.js
pascalwilbrink Mar 1, 2024
92452fa
Delete packages/open-scd/test/integration/editors/communication/dist/…
pascalwilbrink Mar 1, 2024
4c93cf8
Delete packages/open-scd/test/integration/editors/templates/dist/doty…
pascalwilbrink Mar 1, 2024
99f7e77
Delete packages/open-scd/test/integration/editors/cleanup/dist/contro…
pascalwilbrink Mar 1, 2024
d434e80
Update mock-wizard-editor.ts
pascalwilbrink Mar 4, 2024
a84157a
Update connectedap-c.test.ts
pascalwilbrink Mar 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/open-scd/src/addons/Waiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class OscdWaiter extends LitElement {
waiting = false;

private work: Set<Promise<void>> = new Set();

/** A promise which resolves once all currently pending work is done. */
workDone = Promise.allSettled(this.work);

Expand All @@ -32,6 +31,7 @@ export class OscdWaiter extends LitElement {

constructor() {
super();

this.onPendingState = this.onPendingState.bind(this);
}

Expand Down
58 changes: 58 additions & 0 deletions packages/open-scd/src/addons/Wizards.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {
html,
state,
TemplateResult,
query,
customElement,
LitElement,
property,
} from 'lit-element';
import { WizardEvent, WizardFactory } from '../foundation.js';

import '../wizard-dialog.js';
import { WizardDialog } from '../wizard-dialog.js';

/** `LitElement` mixin that adds a `workflow` property which [[`Wizard`]]s are
* queued onto on incoming [[`WizardEvent`]]s, first come first displayed. */
@customElement('oscd-wizards')
export class Wizards extends LitElement {
@property({
type: Object,
})
host!: HTMLElement;

/** FIFO queue of [[`Wizard`]]s to display. */
@state()
workflow: WizardFactory[] = [];

@query('wizard-dialog') wizardUI!: WizardDialog;

private onWizard(we: WizardEvent) {
const wizard = we.detail.wizard;
if (wizard === null) this.workflow.shift();
else if (we.detail.subwizard) this.workflow.unshift(wizard);
else this.workflow.push(wizard);
this.requestUpdate('workflow');
this.updateComplete.then(() =>
this.wizardUI.updateComplete.then(() =>
this.wizardUI.dialog?.updateComplete.then(() =>
this.wizardUI.dialog?.focus()
)
)
);
}

connectedCallback() {
super.connectedCallback();

this.host.addEventListener('wizard', this.onWizard.bind(this));
this.host.addEventListener('editor-action', () =>
this.wizardUI.requestUpdate()
);
}

render(): TemplateResult {
return html`<slot></slot>
<wizard-dialog .wizard=${this.workflow[0]?.() ?? []}></wizard-dialog>`;
}
}
12 changes: 5 additions & 7 deletions packages/open-scd/src/open-scd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ import { Editing } from './Editing.js';
import { Historing } from './Historing.js';
import { Plugging, Plugin, pluginIcons } from './Plugging.js';

import { Wizarding } from './Wizarding.js';

import './addons/Settings.js';
import './addons/Waiter.js';
import { initializeNsdoc, Nsdoc } from './foundation/nsdoc.js';
import './addons/Wizards.js';

import { ActionDetail, List } from '@material/mwc-list';
import { Drawer } from '@material/mwc-drawer';
import { translate } from 'lit-translate';

import { initializeNsdoc, Nsdoc } from './foundation/nsdoc.js';

// HOSTING INTERFACES

interface MenuItem {
Expand All @@ -64,9 +64,7 @@ interface MenuPlugin {
/** The `<open-scd>` custom element is the main entry point of the
* Open Substation Configuration Designer. */
@customElement('open-scd')
export class OpenSCD extends Wizarding(
Plugging(Editing(Historing(LitElement)))
) {
export class OpenSCD extends Plugging(Editing(Historing(LitElement))) {
/** Object containing all *.nsdoc files and a function extracting element's label form them*/
@property({ attribute: false })
nsdoc: Nsdoc = initializeNsdoc();
Expand Down Expand Up @@ -166,7 +164,7 @@ export class OpenSCD extends Wizarding(
render(): TemplateResult {
return html`<oscd-waiter>
<oscd-settings .host=${this} .nsdoc=${this.nsdoc}>
${this.renderMain()}
<oscd-wizards .host=${this}> ${this.renderMain()}</oscd-wizards>
</oscd-settings>
</oscd-waiter>`;
}
Expand Down
Loading
Loading