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

Finalize wizarding API #1

Open
ca-d opened this issue Apr 19, 2022 · 4 comments
Open

Finalize wizarding API #1

ca-d opened this issue Apr 19, 2022 · 4 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@ca-d
Copy link
Contributor

ca-d commented Apr 19, 2022

We are thinking about radically changing the WizardEvent in order to turn it into a pure declaration of intent.

Instead of the API user saying

"Please open a wizard with exactly these inputs, page titles, button labels, icons, etc., and exactly this WizardAction committed at the end.",

the API user would then either say

"Please open some wizard allowing the user to edit this element I have here."

or

"Please open some wizard allowing the user to create a new element of this tagName as a child of this parent element I have here."

In order to enable the API user to add properties from an extension namespace defined in some custom schema, the API user can specify pairs of XML Schema documents and namespace prefix strings to take into consideration. All other work would be done automatically by the core editor.

This would mean reducing the scope of Wizards to creating or editing elements only, while other tasks (e.g. our "select" wizards) would then be done using regular modal dialogues. This makes for a clean, single-purpose API with a clearly defined upgrade path when new versions of the standard schema are released.

interface CustomNamespace {
  prefix: string,
  schema: XMLDocument
}

interface WizardEventDetail {
  element: Element,
  tagName?: string,
  custom?: CustomNamespace[],
  hidden?: string[],
  subWizard?: boolean
};

function newEditWizardEvent(element: Element, customNS?: CustomNamespace[]): WizardEvent;
function newCreateWizardEvent(parent: Element, tagName: string, customNS?: CustomNamespace[]): WizardEvent;
@ca-d ca-d added documentation Improvements or additions to documentation enhancement New feature or request question Further information is requested and removed question Further information is requested labels Apr 20, 2022
@JakobVogelsang JakobVogelsang transferred this issue from openscd/open-scd-core Sep 2, 2022
@JakobVogelsang JakobVogelsang added this to To do in Wizarding mixin via automation Sep 2, 2022
@Sander3003
Copy link
Member

Sander3003 commented Apr 12, 2023

Create an ADR's:

  • Content of wizarding library (define inputs/outputs)

Acceptance criteria:
Pull-request

@Sander3003
Copy link
Member

@Sander3003
Copy link
Member

Related: #10

@ca-d
Copy link
Contributor Author

ca-d commented Jul 3, 2023

If we implement modular wizard libraries in open-scd-core, we don't actually need to take care of extension namespaces in the API any more, since these can be handled in purpose-built wizards for the same element. This is an alternative API we could use at that point.

export interface WizardBase {
  subWizard?: boolean;
}

export interface CreateWizard extends WizardBase {
  parent: Element;
  tagName: string;
}

export interface EditWizard extends WizardBase {
  element: Element;
}

export type Wizard = CreateWizard | EditWizard;

export function isCreateWizard(wizard: Wizard): wizard is CreateWizard {
  return 'parent' in wizard;
}

export function isEditWizard(wizard: Wizard): wizard is EditWizard {
  return 'element' in wizard;
}

export type WizardEvent = CustomEvent<Wizard>;

export function newWizardEvent(wizard: Wizard): WizardEvent {
  return new CustomEvent<Wizard>('oscd-wizard', {
    composed: true,
    bubbles: true,
    detail: wizard,
  });
}

declare global {
  interface ElementEventMap {
    ['oscd-wizard']: WizardEvent;
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants