From c2b5547aa2c780e607824643e911954fa2ed054a Mon Sep 17 00:00:00 2001 From: Christian Dinkel Date: Wed, 5 Apr 2023 11:37:30 +0200 Subject: [PATCH 1/4] fix(editing): use editCount property for change propagation --- src/Editing.ts | 10 - src/Logging.ts | 24 +- src/Plugging.ts | 9 +- src/editors/Cleanup.ts | 8 +- src/editors/Communication.ts | 6 +- src/editors/GooseSubscriberDataBinding.ts | 4 + src/editors/GooseSubscriberLaterBinding.ts | 6 +- src/editors/GooseSubscriberMessageBinding.ts | 10 +- src/editors/IED.ts | 3 + src/editors/Protocol104.ts | 80 +++-- src/editors/Publisher.ts | 6 + src/editors/SMVSubscriberDataBinding.ts | 4 + src/editors/SMVSubscriberLaterBinding.ts | 6 +- src/editors/SMVSubscriberMessageBinding.ts | 15 +- src/editors/Substation.ts | 7 +- src/editors/Templates.ts | 2 + .../communication/subnetwork-editor.ts | 4 + src/editors/ied/access-point-container.ts | 3 +- src/editors/ied/do-container.ts | 2 + src/editors/ied/foundation.ts | 2 + src/editors/ied/ied-container.ts | 1 + src/editors/ied/ldevice-container.ts | 1 + src/editors/ied/ln-container.ts | 1 + src/editors/ied/server-container.ts | 1 + src/editors/protocol104/base-container.ts | 2 + src/editors/protocol104/ied-container.ts | 6 +- .../protocol104/subnetwork-container.ts | 1 + src/editors/protocol104/values-container.ts | 1 + src/editors/publisher/gse-control-editor.ts | 3 + .../publisher/report-control-editor.ts | 4 + .../publisher/sampled-value-control-editor.ts | 3 + src/editors/subscription/fcda-binding-list.ts | 2 + src/editors/subscription/goose/goose-list.ts | 2 + .../subscription/goose/subscriber-list.ts | 2 + src/editors/subscription/ied-list.ts | 6 +- .../ext-ref-later-binding-list.ts | 2 + .../later-binding/ext-ref-ln-binding-list.ts | 3 +- .../subscription/sampledvalues/smv-list.ts | 2 + .../sampledvalues/subscriber-list.ts | 2 + src/editors/substation/bay-editor.ts | 12 +- .../substation/conducting-equipment-editor.ts | 5 + src/editors/substation/eq-function-editor.ts | 4 + .../substation/eq-sub-function-editor.ts | 4 + src/editors/substation/foundation.ts | 3 +- src/editors/substation/function-editor.ts | 7 +- .../substation/general-equipment-editor.ts | 4 + src/editors/substation/line-editor.ts | 6 + .../substation/powertransformer-editor.ts | 6 + .../substation/sub-equipment-editor.ts | 4 + src/editors/substation/sub-function-editor.ts | 5 +- src/editors/substation/substation-editor.ts | 12 +- src/editors/substation/tapchanger-editor.ts | 5 + .../substation/transformer-winding-editor.ts | 8 +- .../substation/voltage-level-editor.ts | 12 +- src/editors/substation/zeroline-pane.ts | 10 +- src/menu/CompareIED.ts | 2 + src/menu/ExportCommunication.ts | 2 + src/menu/ImportIEDs.ts | 2 + src/menu/SclHistory.ts | 2 + src/menu/VirtualTemplateIED.ts | 2 + .../GooseSubscriberDataBinding.test.ts | 34 +- .../GooseSubscriberLaterBinding.test.ts | 3 +- .../GooseSubscriberMessageBinding.test.ts | 3 +- .../editors/SMVSubscriberDataBinding.test.ts | 4 +- .../editors/SMVSubscriberLaterBinding.test.ts | 3 +- .../SMVSubscriberMessageBinding.test.ts | 3 +- ...GooseSubscriberMessageBinding.test.snap.js | 316 +++++++++++++++- .../SMVSubscriberMessageBinding.test.snap.js | 340 +++++++++++++++++- test/unit/Logging.test.ts | 24 +- test/unit/mock-plugger.ts | 3 +- 70 files changed, 979 insertions(+), 127 deletions(-) diff --git a/src/Editing.ts b/src/Editing.ts index fa25f8be5e..bc76e103e9 100644 --- a/src/Editing.ts +++ b/src/Editing.ts @@ -424,16 +424,6 @@ export function Editing(Base: TBase) { if (!this.doc) return; - const newDoc = document.implementation.createDocument( - this.doc.lookupNamespaceURI(''), - this.doc.documentElement.tagName, - this.doc.doctype - ); - - // change the document object reference to enable reactive updates - newDoc.documentElement.replaceWith(this.doc.documentElement); - this.doc = newDoc; - await this.updateComplete; this.dispatchEvent(newValidateEvent()); } diff --git a/src/Logging.ts b/src/Logging.ts index bd9009e5fc..b2f5b2ebb8 100644 --- a/src/Logging.ts +++ b/src/Logging.ts @@ -59,7 +59,7 @@ function getPluginName(src: string): string { * A mixin adding a `history` property to any `LitElement`, in which * incoming [[`LogEvent`]]s are logged. * - * For [[`EditorAction`]] entries, also sets `currentAction` to the index of + * For [[`EditorAction`]] entries, also sets `editCount` to the index of * the committed action, allowing the user to go to `previousAction` with * `undo()` if `canUndo` and to go to `nextAction` with `redo()` if `canRedo`. * @@ -75,7 +75,7 @@ export function Logging(Base: TBase) { history: LogEntry[] = []; /** Index of the last [[`EditorAction`]] applied. */ @property({ type: Number }) - currentAction = -1; + editCount = -1; @property() diagnoses = new Map(); @internalProperty() @@ -89,7 +89,7 @@ export function Logging(Base: TBase) { @query('#issue') issueUI!: Snackbar; get canUndo(): boolean { - return this.currentAction >= 0; + return this.editCount >= 0; } get canRedo(): boolean { return this.nextAction >= 0; @@ -98,15 +98,15 @@ export function Logging(Base: TBase) { get previousAction(): number { if (!this.canUndo) return -1; return this.history - .slice(0, this.currentAction) + .slice(0, this.editCount) .map(entry => (entry.kind == 'action' ? true : false)) .lastIndexOf(true); } get nextAction(): number { let index = this.history - .slice(this.currentAction + 1) + .slice(this.editCount + 1) .findIndex(entry => entry.kind == 'action'); - if (index >= 0) index += this.currentAction + 1; + if (index >= 0) index += this.editCount + 1; return index; } @@ -125,10 +125,10 @@ export function Logging(Base: TBase) { if (!this.canUndo) return false; this.dispatchEvent( newActionEvent( - invert((this.history[this.currentAction]).action) + invert((this.history[this.editCount]).action) ) ); - this.currentAction = this.previousAction; + this.editCount = this.previousAction; return true; } redo(): boolean { @@ -136,14 +136,14 @@ export function Logging(Base: TBase) { this.dispatchEvent( newActionEvent((this.history[this.nextAction]).action) ); - this.currentAction = this.nextAction; + this.editCount = this.nextAction; return true; } private onLog(le: LogEvent): void { if (le.detail.kind === 'reset') { this.history = []; - this.currentAction = -1; + this.editCount = -1; return; } @@ -156,7 +156,7 @@ export function Logging(Base: TBase) { if (entry.action.derived) return; entry.action.derived = true; if (this.nextAction !== -1) this.history.splice(this.nextAction); - this.currentAction = this.history.length; + this.editCount = this.history.length; } this.history.push(entry); @@ -206,7 +206,7 @@ export function Logging(Base: TBase) { class="${entry.kind}" graphic="icon" ?twoline=${!!entry.message} - ?activated=${this.currentAction == history.length - index - 1} + ?activated=${this.editCount == history.length - index - 1} > diff --git a/src/Plugging.ts b/src/Plugging.ts index 897d0a5a5a..1b0f86d5b4 100644 --- a/src/Plugging.ts +++ b/src/Plugging.ts @@ -25,7 +25,7 @@ import { ifImplemented, Mixin } from './foundation.js'; import { EditingElement } from './Editing.js'; import { officialPlugins } from '../public/js/plugins.js'; import { Nsdoc } from './foundation/nsdoc.js'; - +import { LoggingElement } from './Logging.js'; const pluginTags = new Map(); /** * Hashes `uri` using cyrb64 analogous to @@ -176,9 +176,9 @@ const loadedPlugins = new Set(); /** Mixin that manages Plugins in `localStorage` */ export type PluggingElement = Mixin; -export function Plugging EditingElement>( - Base: TBase -) { +export function Plugging< + TBase extends new (...args: any[]) => EditingElement & LoggingElement +>(Base: TBase) { class PluggingElement extends Base { // DIRTY HACK: will refactored with open-scd-core nsdoc!: Nsdoc; @@ -289,6 +289,7 @@ export function Plugging EditingElement>( content: staticTagHtml`<${tag} .doc=${this.doc} .docName=${this.docName} + .editCount=${this.editCount} .docId=${this.docId} .pluginId=${plugin.src} .nsdoc=${this.nsdoc} diff --git a/src/editors/Cleanup.ts b/src/editors/Cleanup.ts index 2a28ccff68..6296511847 100644 --- a/src/editors/Cleanup.ts +++ b/src/editors/Cleanup.ts @@ -13,13 +13,15 @@ export default class Cleanup extends LitElement { /** The document being edited as provided to plugins by [[`OpenSCD`]]. */ @property() doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; render(): TemplateResult { return html`
- - - + + +
`; } diff --git a/src/editors/Communication.ts b/src/editors/Communication.ts index e7bb1f0207..876f2f6547 100644 --- a/src/editors/Communication.ts +++ b/src/editors/Communication.ts @@ -17,6 +17,8 @@ export default class CommunicationPlugin extends LitElement { /** The document being edited as provided to plugins by [[`OpenSCD`]]. */ @property() doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; /** * Creates the Communication Element and returns the created Element @@ -37,7 +39,8 @@ export default class CommunicationPlugin extends LitElement { /** Opens a [[`WizardDialog`]] for creating a new `SubNetwork` element. */ private openCreateSubNetworkWizard(): void { - const parent =this.doc.querySelector(':root > Communication') || + const parent = + this.doc.querySelector(':root > Communication') || this.createCommunication(); this.dispatchEvent(newWizardEvent(createSubNetworkWizard(parent!))); @@ -68,6 +71,7 @@ export default class CommunicationPlugin extends LitElement { .map( subnetwork => html`` diff --git a/src/editors/GooseSubscriberDataBinding.ts b/src/editors/GooseSubscriberDataBinding.ts index 4f42f386f4..10b29be7d7 100644 --- a/src/editors/GooseSubscriberDataBinding.ts +++ b/src/editors/GooseSubscriberDataBinding.ts @@ -9,6 +9,8 @@ import './subscription/later-binding/ext-ref-ln-binding-list.js'; export default class GooseSubscribeDataBindingPlugin extends LitElement { @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; @property() nsdoc!: Nsdoc; @@ -19,12 +21,14 @@ export default class GooseSubscribeDataBindingPlugin extends LitElement { class="column" controlTag="GSEControl" .includeLaterBinding="${false}" + .editCount=${this.editCount} .doc="${this.doc}" > diff --git a/src/editors/GooseSubscriberLaterBinding.ts b/src/editors/GooseSubscriberLaterBinding.ts index c50a5312e4..c77bc1f754 100644 --- a/src/editors/GooseSubscriberLaterBinding.ts +++ b/src/editors/GooseSubscriberLaterBinding.ts @@ -7,6 +7,8 @@ import './subscription/later-binding/ext-ref-later-binding-list.js'; export default class GooseSubscribeLaterBindingPlugin extends LitElement { @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; render(): TemplateResult { return html`
@@ -15,13 +17,13 @@ export default class GooseSubscribeLaterBindingPlugin extends LitElement { class="column" controlTag="GSEControl" .includeLaterBinding="${true}" - .doc="${this.doc}" + .editCount=${this.editCount} .doc="${this.doc}" >
diff --git a/src/editors/GooseSubscriberMessageBinding.ts b/src/editors/GooseSubscriberMessageBinding.ts index 76d96e9084..31128d220d 100644 --- a/src/editors/GooseSubscriberMessageBinding.ts +++ b/src/editors/GooseSubscriberMessageBinding.ts @@ -25,6 +25,8 @@ export default class GooseSubscriberMessageBindingPlugin extends LitElement { /** The document being edited as provided to plugins by [[`OpenSCD`]]. */ @property() doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; @query('#goosePublisherView') goosePublisherView!: RadioListItem; @@ -75,14 +77,20 @@ export default class GooseSubscriberMessageBindingPlugin extends LitElement {
${view == View.PUBLISHER - ? html`` + ? html`` : html``}
diff --git a/src/editors/IED.ts b/src/editors/IED.ts index 3bdd5e8dbc..2f239e9b95 100644 --- a/src/editors/IED.ts +++ b/src/editors/IED.ts @@ -32,6 +32,8 @@ export default class IedPlugin extends LitElement { /** The document being edited as provided to plugins by [[`OpenSCD`]]. */ @property() doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; /** All the nsdoc files that are being uploaded via the settings. */ @property() @@ -175,6 +177,7 @@ export default class IedPlugin extends LitElement { -
- - this.listDiv.dispatchEvent(newViewEvent(View.VALUES))} - > - - - this.listDiv.dispatchEvent(newViewEvent(View.NETWORK))} - > - -
- ${selectedViewProtocol104Plugin == View.VALUES - ? html `` - : html `` - } -
+ return html`
+
+ + + this.listDiv.dispatchEvent(newViewEvent(View.VALUES))} + > + + + + this.listDiv.dispatchEvent(newViewEvent(View.NETWORK))} + > + +
+ ${selectedViewProtocol104Plugin == View.VALUES + ? html`` + : html``}
-
`; +
+ `; } static styles = css` @@ -93,5 +101,5 @@ export default class Communication104Plugin extends LitElement { section { padding: 8px 12px 16px; } - `; + `; } diff --git a/src/editors/Publisher.ts b/src/editors/Publisher.ts index 552cea2c47..656dbc25af 100644 --- a/src/editors/Publisher.ts +++ b/src/editors/Publisher.ts @@ -21,6 +21,8 @@ export default class PublisherPlugin extends LitElement { /** The document being edited as provided to plugins by [[`OpenSCD`]]. */ @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; @state() private publisherType: 'Report' | 'GOOSE' | 'SampledValue' | 'DataSet' = @@ -55,24 +57,28 @@ export default class PublisherPlugin extends LitElement { > diff --git a/src/editors/SMVSubscriberLaterBinding.ts b/src/editors/SMVSubscriberLaterBinding.ts index 5c6f9ad347..f8d5be3c00 100644 --- a/src/editors/SMVSubscriberLaterBinding.ts +++ b/src/editors/SMVSubscriberLaterBinding.ts @@ -7,6 +7,8 @@ import './subscription/later-binding/ext-ref-later-binding-list.js'; export default class SMVSubscribeLaterBindingPlugin extends LitElement { @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; render(): TemplateResult { return html`
@@ -15,13 +17,13 @@ export default class SMVSubscribeLaterBindingPlugin extends LitElement { class="column" controlTag="SampledValueControl" .includeLaterBinding="${true}" - .doc="${this.doc}" + .editCount=${this.editCount} .doc="${this.doc}" >
diff --git a/src/editors/SMVSubscriberMessageBinding.ts b/src/editors/SMVSubscriberMessageBinding.ts index e135804aeb..f5ec0856cc 100644 --- a/src/editors/SMVSubscriberMessageBinding.ts +++ b/src/editors/SMVSubscriberMessageBinding.ts @@ -23,6 +23,8 @@ export default class SMVSubscriberMessageBindingPlugin extends LitElement { /** The document being edited as provided to plugins by [[`OpenSCD`]]. */ @property() doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; @query('#smvPublisherView') smvPublisherView!: RadioListItem; @@ -73,13 +75,22 @@ export default class SMVSubscriberMessageBindingPlugin extends LitElement {
${view == View.PUBLISHER - ? html`` + ? html`` : html``} - +
`; } diff --git a/src/editors/Substation.ts b/src/editors/Substation.ts index c23ca9f1c1..297fd562ab 100644 --- a/src/editors/Substation.ts +++ b/src/editors/Substation.ts @@ -12,6 +12,8 @@ export default class SubstationPlugin extends LitElement { /** The document being edited as provided to plugins by [[`OpenSCD`]]. */ @property() doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; /** Opens a [[`WizardDialog`]] for creating a new `Substation` element. */ openCreateSubstationWizard(): void { @@ -20,7 +22,10 @@ export default class SubstationPlugin extends LitElement { } render(): TemplateResult { - return html` + return html` ${!this.doc?.querySelector( ':root > Substation, :root > Line, :root > Process' ) diff --git a/src/editors/Templates.ts b/src/editors/Templates.ts index 92d89767a3..d0a2ea7f29 100644 --- a/src/editors/Templates.ts +++ b/src/editors/Templates.ts @@ -53,6 +53,8 @@ export default class TemplatesPlugin extends LitElement { /** The document being edited as provided to plugins by [[`OpenSCD`]]. */ @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; async openCreateLNodeTypeWizard(): Promise { this.createDataTypeTemplates(); diff --git a/src/editors/communication/subnetwork-editor.ts b/src/editors/communication/subnetwork-editor.ts index 8ba1a00765..57f35ae4c1 100644 --- a/src/editors/communication/subnetwork-editor.ts +++ b/src/editors/communication/subnetwork-editor.ts @@ -26,6 +26,8 @@ import { wizards } from '../../wizards/wizard-library.js'; export class SubNetworkEditor extends LitElement { @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; /** SCL element SubNetwork */ @property({ attribute: false }) element!: Element; @@ -85,6 +87,7 @@ export class SubNetworkEditor extends LitElement { ).map( smv => html`` @@ -99,6 +102,7 @@ export class SubNetworkEditor extends LitElement { ).map( gse => html`` diff --git a/src/editors/ied/access-point-container.ts b/src/editors/ied/access-point-container.ts index d70189a287..ef81558df7 100644 --- a/src/editors/ied/access-point-container.ts +++ b/src/editors/ied/access-point-container.ts @@ -9,7 +9,6 @@ import { } from 'lit-element'; import { nothing } from 'lit-html'; import { translate } from 'lit-translate'; -import { wizards } from '../../wizards/wizard-library.js'; import { getDescriptionAttribute, @@ -85,6 +84,7 @@ export class AccessPointContainer extends Container { ${Array.from(this.element.querySelectorAll(':scope > Server')).map( server => html` ${lnElements.map( ln => html` html` html` AccessPoint')).map( ap => html` html` html` html` { return html` - + `; })}`; diff --git a/src/editors/protocol104/subnetwork-container.ts b/src/editors/protocol104/subnetwork-container.ts index 08144bb3a4..32d422d9b1 100644 --- a/src/editors/protocol104/subnetwork-container.ts +++ b/src/editors/protocol104/subnetwork-container.ts @@ -52,6 +52,7 @@ export class SubNetwork104Container extends Base104Container { class="${connectedAP.parentElement !== this.element ? 'disabled' : ''}" + .editCount=${this.editCount} .doc="${this.doc}" .element=${connectedAP} >` diff --git a/src/editors/protocol104/values-container.ts b/src/editors/protocol104/values-container.ts index 68433d6907..346deaee16 100644 --- a/src/editors/protocol104/values-container.ts +++ b/src/editors/protocol104/values-container.ts @@ -56,6 +56,7 @@ export class Values104Container extends Base104Container { return html` ${ieds.map(iedElement => { return html``; diff --git a/src/editors/publisher/gse-control-editor.ts b/src/editors/publisher/gse-control-editor.ts index ec5264a2ef..19f71a4503 100644 --- a/src/editors/publisher/gse-control-editor.ts +++ b/src/editors/publisher/gse-control-editor.ts @@ -29,6 +29,8 @@ export class GseControlEditor extends LitElement { /** The document being edited as provided to plugins by [[`OpenSCD`]]. */ @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; @state() selectedGseControl?: Element; @@ -81,6 +83,7 @@ export class GseControlEditor extends LitElement { .element=${this.selectedDataSet!} > diff --git a/src/editors/publisher/report-control-editor.ts b/src/editors/publisher/report-control-editor.ts index 4d8e0e2ca0..3aa580a752 100644 --- a/src/editors/publisher/report-control-editor.ts +++ b/src/editors/publisher/report-control-editor.ts @@ -29,6 +29,8 @@ export class ReportControlEditor extends LitElement { /** The document being edited as provided to plugins by [[`OpenSCD`]]. */ @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; @state() selectedReportControl?: Element; @@ -83,10 +85,12 @@ export class ReportControlEditor extends LitElement { if (this.selectedReportControl !== undefined) return html`
diff --git a/src/editors/publisher/sampled-value-control-editor.ts b/src/editors/publisher/sampled-value-control-editor.ts index 5cc332bd35..ae68c94d97 100644 --- a/src/editors/publisher/sampled-value-control-editor.ts +++ b/src/editors/publisher/sampled-value-control-editor.ts @@ -29,6 +29,8 @@ export class SampledValueControlEditor extends LitElement { /** The document being edited as provided to plugins by [[`OpenSCD`]]. */ @property({ attribute: false }) doc!: XMLDocument; + @property({type: Number}) + editCount = -1; @state() selectedSampledValueControl?: Element; @@ -88,6 +90,7 @@ export class SampledValueControlEditor extends LitElement { .element=${this.selectedDataSet!} > diff --git a/src/editors/subscription/fcda-binding-list.ts b/src/editors/subscription/fcda-binding-list.ts index 6187044aee..3ec10122cf 100644 --- a/src/editors/subscription/fcda-binding-list.ts +++ b/src/editors/subscription/fcda-binding-list.ts @@ -54,6 +54,8 @@ type iconLookup = Record; export class FcdaBindingList extends LitElement { @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; @property() controlTag!: controlTag; @property() diff --git a/src/editors/subscription/goose/goose-list.ts b/src/editors/subscription/goose/goose-list.ts index cb296193a4..04395f8634 100644 --- a/src/editors/subscription/goose/goose-list.ts +++ b/src/editors/subscription/goose/goose-list.ts @@ -37,6 +37,8 @@ addEventListener('open-doc', onOpenDocResetSelectedGooseMsg); export class GooseList extends LitElement { @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; private onSelect(gseControl: Element): void { if (gseControl == selectedGseControl) return; diff --git a/src/editors/subscription/goose/subscriber-list.ts b/src/editors/subscription/goose/subscriber-list.ts index 877f1cd8cf..d45c36b51b 100644 --- a/src/editors/subscription/goose/subscriber-list.ts +++ b/src/editors/subscription/goose/subscriber-list.ts @@ -54,6 +54,8 @@ let view: View = View.PUBLISHER; export class SubscriberList extends SubscriberListContainer { @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; /** Current selected GOOSE message (when in GOOSE Publisher view) */ currentSelectedGseControl: Element | undefined; diff --git a/src/editors/subscription/ied-list.ts b/src/editors/subscription/ied-list.ts index fd8b484001..b5fbb6ce58 100644 --- a/src/editors/subscription/ied-list.ts +++ b/src/editors/subscription/ied-list.ts @@ -26,6 +26,8 @@ addEventListener('open-doc', onOpenDocResetSelectedGooseMsg); export class IedList extends LitElement { @property() doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; @property({ type: String }) serviceType?: 'goose' | 'smv'; @@ -46,7 +48,9 @@ export class IedList extends LitElement { render(): TemplateResult { return html`
-

${translate(`subscription.${this.serviceType}.subscriber.iedListTitle`)}

+

+ ${translate(`subscription.${this.serviceType}.subscriber.iedListTitle`)} +

${getOrderedIeds(this.doc).map( ied => diff --git a/src/editors/subscription/later-binding/ext-ref-later-binding-list.ts b/src/editors/subscription/later-binding/ext-ref-later-binding-list.ts index 14d936bd62..3b3c0a2bae 100644 --- a/src/editors/subscription/later-binding/ext-ref-later-binding-list.ts +++ b/src/editors/subscription/later-binding/ext-ref-later-binding-list.ts @@ -47,6 +47,8 @@ import { export class ExtRefLaterBindingList extends LitElement { @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; @property() controlTag!: 'SampledValueControl' | 'GSEControl'; diff --git a/src/editors/subscription/later-binding/ext-ref-ln-binding-list.ts b/src/editors/subscription/later-binding/ext-ref-ln-binding-list.ts index a156b4dc8f..c7b1ca825c 100644 --- a/src/editors/subscription/later-binding/ext-ref-ln-binding-list.ts +++ b/src/editors/subscription/later-binding/ext-ref-ln-binding-list.ts @@ -12,7 +12,6 @@ import { get, translate } from 'lit-translate'; import { ComplexAction, - Create, createElement, Delete, identity, @@ -44,6 +43,8 @@ import { emptyInputsDeleteActions } from '../../../foundation/ied.js'; export class ExtRefLnBindingList extends LitElement { @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; @property() nsdoc!: Nsdoc; @property() diff --git a/src/editors/subscription/sampledvalues/smv-list.ts b/src/editors/subscription/sampledvalues/smv-list.ts index fd244e3c2f..5062831c92 100644 --- a/src/editors/subscription/sampledvalues/smv-list.ts +++ b/src/editors/subscription/sampledvalues/smv-list.ts @@ -37,6 +37,8 @@ addEventListener('open-doc', onOpenDocResetSelectedSmvMsg); export class SmvPublisherList extends LitElement { @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; private onSelect(smvControl: Element) { const ln = smvControl.parentElement; diff --git a/src/editors/subscription/sampledvalues/subscriber-list.ts b/src/editors/subscription/sampledvalues/subscriber-list.ts index 28ec6da6e6..67a2b72188 100644 --- a/src/editors/subscription/sampledvalues/subscriber-list.ts +++ b/src/editors/subscription/sampledvalues/subscriber-list.ts @@ -54,6 +54,8 @@ let view: View = View.PUBLISHER; export class SubscriberList extends SubscriberListContainer { @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; /** Current selected Sampled Values element (when in GOOSE Publisher view) */ currentSelectedSmvControl: Element | undefined; diff --git a/src/editors/substation/bay-editor.ts b/src/editors/substation/bay-editor.ts index 15817c6d97..e44f2b2175 100644 --- a/src/editors/substation/bay-editor.ts +++ b/src/editors/substation/bay-editor.ts @@ -54,6 +54,8 @@ export class BayEditor extends LitElement { /** The document being edited as provided to editor by [[`Zeroline`]]. */ @property({ attribute: false }) doc!: XMLDocument; + @property({type: Number}) + editCount = -1; @property({ attribute: false }) element!: Element; @property({ type: Boolean }) @@ -132,6 +134,7 @@ export class BayEditor extends LitElement { ${lNodes.map( lNode => html`` @@ -147,6 +150,7 @@ export class BayEditor extends LitElement { return html` ${functions.map( fUnction => html` ${ieds.map( ied => - html`` + html`` )}
` : html``; @@ -239,6 +247,7 @@ export class BayEditor extends LitElement { ).map( pwt => html` html` html`` @@ -119,6 +122,7 @@ export class ConductingEquipmentEditor extends LitElement { return html` ${eqFunctions.map( eqFunction => html` html`` diff --git a/src/editors/substation/eq-function-editor.ts b/src/editors/substation/eq-function-editor.ts index 83687201b9..57ed5d1fe1 100644 --- a/src/editors/substation/eq-function-editor.ts +++ b/src/editors/substation/eq-function-editor.ts @@ -45,6 +45,8 @@ export class EqFunctionEditor extends LitElement { /** The document being edited as provided to editor by [[`Zeroline`]]. */ @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; /** The edited `EqFunction` element */ @property({ attribute: false }) element!: Element; @@ -99,6 +101,7 @@ export class EqFunctionEditor extends LitElement { ${lNodes.map( lNode => html`` @@ -115,6 +118,7 @@ export class EqFunctionEditor extends LitElement { return html` ${eqSubFunctions.map( eqSubFunction => html` html`` @@ -112,6 +115,7 @@ export class EqSubFunctionEditor extends LitElement { return html` ${eqSubFunctions.map( eqSubFunction => html`` diff --git a/src/editors/substation/foundation.ts b/src/editors/substation/foundation.ts index d0f65baece..116c6ad56b 100644 --- a/src/editors/substation/foundation.ts +++ b/src/editors/substation/foundation.ts @@ -556,6 +556,7 @@ export function getIcon(condEq: Element): TemplateResult { } /** * Creates a general-equipment template literal. + * FIXME(ca-d): this cannot update since it is not a LitElement instance method. * @param doc - Project xml document. * @param element - scl general-equipment element. * @param showfunctions - Whether rendered as action pane (true). @@ -564,7 +565,7 @@ export function getIcon(condEq: Element): TemplateResult { export function renderGeneralEquipment( doc: XMLDocument, element: Element, - showfunctions: Boolean + showfunctions: boolean ): TemplateResult { const generalEquipment = getChildElementsByTagName( element, diff --git a/src/editors/substation/function-editor.ts b/src/editors/substation/function-editor.ts index 66a8c942a7..abe4da81cc 100644 --- a/src/editors/substation/function-editor.ts +++ b/src/editors/substation/function-editor.ts @@ -24,7 +24,6 @@ import { emptyWizard, wizards } from '../../wizards/wizard-library.js'; import { Menu } from '@material/mwc-menu'; import { ListItem } from '@material/mwc-list/mwc-list-item'; import { IconButton } from '@material/mwc-icon-button'; -import { classMap } from 'lit-html/directives/class-map.js'; import { renderGeneralEquipment } from './foundation.js'; function childTags(element: Element | null | undefined): SCLTag[] { @@ -41,6 +40,8 @@ export class FunctionEditor extends LitElement { /** The document being edited as provided to editor by [[`Zeroline`]]. */ @property({ attribute: false }) doc!: XMLDocument; + @property({type: Number}) + editCount = -1; /** The edited `Function` element */ @property({ attribute: false }) element!: Element; @@ -95,7 +96,7 @@ export class FunctionEditor extends LitElement { ${lNodes.map( lNode => html`` )} @@ -108,7 +109,7 @@ export class FunctionEditor extends LitElement { return html` ${subfunctions.map( subFunction => html`` diff --git a/src/editors/substation/general-equipment-editor.ts b/src/editors/substation/general-equipment-editor.ts index 3812d84ad9..cf6e951f8e 100644 --- a/src/editors/substation/general-equipment-editor.ts +++ b/src/editors/substation/general-equipment-editor.ts @@ -44,6 +44,8 @@ function childTags(element: Element | null | undefined): SCLTag[] { export class GeneralEquipmentEditor extends LitElement { @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; @property({ attribute: false }) element!: Element; @@ -100,6 +102,7 @@ export class GeneralEquipmentEditor extends LitElement { ${lNodes.map( lNode => html`` @@ -115,6 +118,7 @@ export class GeneralEquipmentEditor extends LitElement { ? html`${eFunctions.map( eFunction => html` ` diff --git a/src/editors/substation/line-editor.ts b/src/editors/substation/line-editor.ts index b70a24061a..1c16fe6ed4 100644 --- a/src/editors/substation/line-editor.ts +++ b/src/editors/substation/line-editor.ts @@ -47,6 +47,8 @@ export class LineEditor extends LitElement { /** The document being edited as provided to editor by [[`Zeroline`]]. */ @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; /** SCL element Line */ @property({ attribute: false }) element!: Element; @@ -84,6 +86,7 @@ export class LineEditor extends LitElement { return html` ${ConductingEquipments.map( ConductingEquipment => html` html` html` html`` diff --git a/src/editors/substation/powertransformer-editor.ts b/src/editors/substation/powertransformer-editor.ts index 73e3975137..a23f0c1532 100644 --- a/src/editors/substation/powertransformer-editor.ts +++ b/src/editors/substation/powertransformer-editor.ts @@ -50,6 +50,8 @@ export class PowerTransformerEditor extends LitElement { /** The document being edited as provided to editor by [[`Zeroline`]]. */ @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; /** SCL element PowerTransformer */ @property({ attribute: false }) element!: Element; @@ -108,6 +110,7 @@ export class PowerTransformerEditor extends LitElement { ${lNodes.map( lNode => html`` @@ -123,6 +126,7 @@ export class PowerTransformerEditor extends LitElement { return html` ${eqFunctions.map( eqFunction => html` html`` @@ -229,6 +234,7 @@ export class PowerTransformerEditor extends LitElement { ${transformerWindings.map( transformerWindings => html` html`` @@ -129,6 +132,7 @@ export class SubEquipmentEditor extends LitElement { ? html` ${eqFunctions.map( eqFunction => html`` diff --git a/src/editors/substation/sub-function-editor.ts b/src/editors/substation/sub-function-editor.ts index 5e43e133ca..9d08b1591d 100644 --- a/src/editors/substation/sub-function-editor.ts +++ b/src/editors/substation/sub-function-editor.ts @@ -28,7 +28,6 @@ import { tags, } from '../../foundation.js'; import { emptyWizard, wizards } from '../../wizards/wizard-library.js'; -import { classMap } from 'lit-html/directives/class-map.js'; import { renderGeneralEquipment } from './foundation.js'; function childTags(element: Element | null | undefined): SCLTag[] { @@ -45,6 +44,8 @@ export class SubFunctionEditor extends LitElement { /** The document being edited as provided to editor by [[`Zeroline`]]. */ @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; /** The edited `SubFunction` element */ @property({ attribute: false }) element!: Element; @@ -99,6 +100,7 @@ export class SubFunctionEditor extends LitElement { ${lNodes.map( lNode => html`` @@ -112,6 +114,7 @@ export class SubFunctionEditor extends LitElement { return html` ${subfunctions.map( subFunction => html` html`` @@ -148,6 +151,7 @@ export class SubstationEditor extends LitElement { return html` ${functions.map( fUnction => html` ${ieds.map( ied => - html`` + html`` )} ` : html``; @@ -183,6 +191,7 @@ export class SubstationEditor extends LitElement { ${pwts.map( pwt => html` html` html`` @@ -113,6 +116,7 @@ export class TapChangerEditor extends LitElement { return html` ${eqFunctions.map( eqFunction => html` html`` diff --git a/src/editors/substation/transformer-winding-editor.ts b/src/editors/substation/transformer-winding-editor.ts index f00e4d02ae..29d8b1edd7 100644 --- a/src/editors/substation/transformer-winding-editor.ts +++ b/src/editors/substation/transformer-winding-editor.ts @@ -47,6 +47,8 @@ export class TransformerWindingEditor extends LitElement { /** The document being edited as provided to editor by [[`Zeroline`]]. */ @property({ attribute: false }) doc!: XMLDocument; + @property({type: Number}) + editCount = -1; /** SCL element TransformerWinding */ @property({ attribute: false }) element!: Element; @@ -111,7 +113,7 @@ export class TransformerWindingEditor extends LitElement { ${lNodes.map( lNode => html`` )} @@ -126,7 +128,7 @@ export class TransformerWindingEditor extends LitElement { ? html` ${eqFunctions.map( eqFunction => html`` @@ -141,7 +143,7 @@ export class TransformerWindingEditor extends LitElement { ? html` ${tapChangers.map( tapChanger => html`` diff --git a/src/editors/substation/voltage-level-editor.ts b/src/editors/substation/voltage-level-editor.ts index 8c96a1e4b2..744e80ccc9 100644 --- a/src/editors/substation/voltage-level-editor.ts +++ b/src/editors/substation/voltage-level-editor.ts @@ -55,6 +55,8 @@ export class VoltageLevelEditor extends LitElement { /** The document being edited as provided to editor by [[`Zeroline`]]. */ @property({ attribute: false }) doc!: XMLDocument; + @property({ type: Number }) + editCount = -1; @property({ attribute: false }) element!: Element; @property({ type: Boolean }) @@ -143,6 +145,7 @@ export class VoltageLevelEditor extends LitElement { ${lNodes.map( lNode => html`` @@ -158,6 +161,7 @@ export class VoltageLevelEditor extends LitElement { return html` ${functions.map( fUnction => html` ${ieds.map( ied => - html`` + html`` )} ` : html``; @@ -193,6 +201,7 @@ export class VoltageLevelEditor extends LitElement { ${pwts.map( pwt => html` ${Array.from(this.element?.querySelectorAll(selectors.Bay) ?? []).map( bay => html` ${ieds.map( ied => - html`` + html`` )} ` : html``; @@ -140,6 +146,7 @@ export class ZerolinePane extends LitElement { .map( substation => html` html`( diff --git a/test/integration/editors/GooseSubscriberDataBinding.test.ts b/test/integration/editors/GooseSubscriberDataBinding.test.ts index 77430a7068..eae5c221da 100644 --- a/test/integration/editors/GooseSubscriberDataBinding.test.ts +++ b/test/integration/editors/GooseSubscriberDataBinding.test.ts @@ -1,6 +1,7 @@ import { expect, fixture, html } from '@open-wc/testing'; import { Wizarding } from '../../../src/Wizarding.js'; import { Editing } from '../../../src/Editing.js'; +import { Logging } from '../../../src/Logging.js'; import { initializeNsdoc } from '../../../src/foundation/nsdoc.js'; import GooseSubscriberDataBinding from '../../../src/editors/GooseSubscriberDataBinding.js'; @@ -15,7 +16,7 @@ import { describe('GOOSE Subscribe Data Binding Plugin', async () => { customElements.define( 'goose-subscriber-data-binding-plugin', - Wizarding(Editing(GooseSubscriberDataBinding)) + Wizarding(Editing(Logging(GooseSubscriberDataBinding))) ); let element: GooseSubscriberDataBinding; @@ -45,8 +46,9 @@ describe('GOOSE Subscribe Data Binding Plugin', async () => { 'GOOSE_Publisher>>QB2_Disconnector>GOOSE1', 'GOOSE_Publisher>>QB2_Disconnector>GOOSE1sDataSet>QB1_Disconnector/ CSWI 1.Pos q (ST)' ); - await element.requestUpdate(); - await extRefListElement.requestUpdate(); + await element.updateComplete; + await extRefListElement.updateComplete; + await fcdaListElement.updateComplete; expect(extRefListElement['getSubscribedLNElements']().length).to.be.equal( 0 @@ -64,12 +66,16 @@ describe('GOOSE Subscribe Data Binding Plugin', async () => { 'mwc-list-item[value="GOOSE_Subscriber2>>Earth_Switch> XSWI 1"]' ) )).click(); - await element.requestUpdate(); + await element.updateComplete; + await extRefListElement.updateComplete; + await fcdaListElement.updateComplete; expect(extRefListElement['getSubscribedLNElements']().length).to.be.equal( 1 ); - expect(getSelectedSubItemValue(fcdaListElement)).to.have.text('1'); + expect(getSelectedSubItemValue(fcdaListElement)).to.exist.and.have.text( + '1' + ); expect(extRefListElement['getAvailableLNElements']().length).to.be.equal(7); expect( element.doc.querySelectorAll( @@ -87,8 +93,8 @@ describe('GOOSE Subscribe Data Binding Plugin', async () => { 'GOOSE_Publisher>>QB2_Disconnector>GOOSE2', 'GOOSE_Publisher>>QB2_Disconnector>GOOSE2sDataSet>QB2_Disconnector/ CSWI 1.Pos q (ST)' ); - await element.requestUpdate(); - await extRefListElement.requestUpdate(); + await element.updateComplete; + await extRefListElement.updateComplete; expect(extRefListElement['getSubscribedLNElements']().length).to.be.equal( 1 @@ -107,7 +113,7 @@ describe('GOOSE Subscribe Data Binding Plugin', async () => { 'mwc-list-item[value="GOOSE_Subscriber2>>Earth_Switch"]' ) )).click(); - await element.requestUpdate(); + await element.updateComplete; expect(extRefListElement['getSubscribedLNElements']().length).to.be.equal( 0 @@ -137,30 +143,30 @@ describe('GOOSE Subscribe Data Binding Plugin', async () => { 'GOOSE_Publisher>>QB2_Disconnector>GOOSE2', 'GOOSE_Publisher>>QB2_Disconnector>GOOSE2sDataSet>QB2_Disconnector/ CSWI 1.Pos q (ST)' ); - await element.requestUpdate(); - await extRefListElement.requestUpdate(); + await element.updateComplete; + await extRefListElement.updateComplete; (( extRefListElement.shadowRoot!.querySelector( 'mwc-list-item[value="GOOSE_Subscriber2>>Earth_Switch"]' ) )).click(); - await element.requestUpdate(); + await element.updateComplete; selectFCDAItem( fcdaListElement, 'GOOSE_Publisher>>QB2_Disconnector>GOOSE2', 'GOOSE_Publisher>>QB2_Disconnector>GOOSE2sDataSet>QB2_Disconnector/ CSWI 1.Pos stVal (ST)' ); - await element.requestUpdate(); - await extRefListElement.requestUpdate(); + await element.updateComplete; + await extRefListElement.updateComplete; (( extRefListElement.shadowRoot!.querySelector( 'mwc-list-item[value="GOOSE_Subscriber2>>Earth_Switch"]' ) )).click(); - await element.requestUpdate(); + await element.updateComplete; expect( element.doc.querySelectorAll( diff --git a/test/integration/editors/GooseSubscriberLaterBinding.test.ts b/test/integration/editors/GooseSubscriberLaterBinding.test.ts index c95134aa14..ac3961d19a 100644 --- a/test/integration/editors/GooseSubscriberLaterBinding.test.ts +++ b/test/integration/editors/GooseSubscriberLaterBinding.test.ts @@ -1,6 +1,7 @@ import { expect, fixture, html } from '@open-wc/testing'; import { Wizarding } from '../../../src/Wizarding.js'; import { Editing } from '../../../src/Editing.js'; +import { Logging } from '../../../src/Logging.js'; import GooseSubscriberLaterBinding from '../../../src/editors/GooseSubscriberLaterBinding.js'; import { @@ -14,7 +15,7 @@ import { ExtRefLaterBindingList } from '../../../src/editors/subscription/later- describe('GOOSE Subscribe Later Binding Plugin', () => { customElements.define( 'goose-subscriber-later-binding-plugin', - Wizarding(Editing(GooseSubscriberLaterBinding)) + Wizarding(Editing(Logging(GooseSubscriberLaterBinding))) ); let element: GooseSubscriberLaterBinding; diff --git a/test/integration/editors/GooseSubscriberMessageBinding.test.ts b/test/integration/editors/GooseSubscriberMessageBinding.test.ts index 353e8849e0..9b45b77c98 100644 --- a/test/integration/editors/GooseSubscriberMessageBinding.test.ts +++ b/test/integration/editors/GooseSubscriberMessageBinding.test.ts @@ -6,12 +6,13 @@ import { ListItem } from '@material/mwc-list/mwc-list-item.js'; import { Editing } from '../../../src/Editing.js'; import { Wizarding } from '../../../src/Wizarding.js'; +import { Logging } from '../../../src/Logging.js'; import GooseSubscriberMessageBindingPlugin from '../../../src/editors/GooseSubscriberMessageBinding.js'; describe('GOOSE subscriber plugin', () => { customElements.define( 'subscription-plugin', - Wizarding(Editing(GooseSubscriberMessageBindingPlugin)) + Wizarding(Editing(Logging(GooseSubscriberMessageBindingPlugin))) ); let element: GooseSubscriberMessageBindingPlugin; let doc: XMLDocument; diff --git a/test/integration/editors/SMVSubscriberDataBinding.test.ts b/test/integration/editors/SMVSubscriberDataBinding.test.ts index afe357844b..3e8d80d481 100644 --- a/test/integration/editors/SMVSubscriberDataBinding.test.ts +++ b/test/integration/editors/SMVSubscriberDataBinding.test.ts @@ -11,11 +11,11 @@ import { getSelectedSubItemValue, selectFCDAItem, } from './test-support.js'; - +import { Logging } from '../../../src/Logging.js'; describe('SMV Subscribe Data Binding Plugin', async () => { customElements.define( 'smv-subscriber-data-binding-plugin', - Wizarding(Editing(SMVSubscriberDataBinding)) + Wizarding(Editing(Logging(SMVSubscriberDataBinding))) ); let element: SMVSubscriberDataBinding; diff --git a/test/integration/editors/SMVSubscriberLaterBinding.test.ts b/test/integration/editors/SMVSubscriberLaterBinding.test.ts index 9bfc6b9e3d..2f69700d20 100644 --- a/test/integration/editors/SMVSubscriberLaterBinding.test.ts +++ b/test/integration/editors/SMVSubscriberLaterBinding.test.ts @@ -2,6 +2,7 @@ import { expect, fixture, html } from '@open-wc/testing'; import { Wizarding } from '../../../src/Wizarding.js'; import { Editing } from '../../../src/Editing.js'; +import { Logging } from '../../../src/Logging.js'; import SMVSubscribeLaterBindingPlugin from '../../../src/editors/SMVSubscriberLaterBinding.js'; import { @@ -15,7 +16,7 @@ import { ExtRefLaterBindingList } from '../../../src/editors/subscription/later- describe('SMV Subscribe Later Binding plugin', () => { customElements.define( 'smv-subscribe-later-binding-plugin', - Wizarding(Editing(SMVSubscribeLaterBindingPlugin)) + Wizarding(Editing(Logging(SMVSubscribeLaterBindingPlugin))) ); let element: SMVSubscribeLaterBindingPlugin; let doc: XMLDocument; diff --git a/test/integration/editors/SMVSubscriberMessageBinding.test.ts b/test/integration/editors/SMVSubscriberMessageBinding.test.ts index e2f7b09313..5d16b54654 100644 --- a/test/integration/editors/SMVSubscriberMessageBinding.test.ts +++ b/test/integration/editors/SMVSubscriberMessageBinding.test.ts @@ -4,13 +4,14 @@ import '../../mock-wizard.js'; import SMVSubscriberMessageBindingPlugin from '../../../src/editors/SMVSubscriberMessageBinding.js'; import { Editing } from '../../../src/Editing.js'; +import { Logging } from '../../../src/Logging.js'; import { Wizarding } from '../../../src/Wizarding.js'; import { ListItem } from '@material/mwc-list/mwc-list-item.js'; describe('Sampled Values Plugin', () => { customElements.define( 'smv-plugin', - Wizarding(Editing(SMVSubscriberMessageBindingPlugin)) + Wizarding(Editing(Logging(SMVSubscriberMessageBindingPlugin))) ); let element: SMVSubscriberMessageBindingPlugin; let doc: XMLDocument; diff --git a/test/integration/editors/__snapshots__/GooseSubscriberMessageBinding.test.snap.js b/test/integration/editors/__snapshots__/GooseSubscriberMessageBinding.test.snap.js index e1306fe71b..19efe457a0 100644 --- a/test/integration/editors/__snapshots__/GooseSubscriberMessageBinding.test.snap.js +++ b/test/integration/editors/__snapshots__/GooseSubscriberMessageBinding.test.snap.js @@ -27,6 +27,162 @@ snapshots["GOOSE subscriber plugin in Publisher view per default the plugin itse + + + + + + + + + + + + + [log.placeholder] + + + info + + + + + + + + + [close] + + + + + + + [diag.placeholder] + + + info + + + + + [close] + + + + + + + + + [log.snackbar.show] + + + + + + + [log.snackbar.show] + + + + + + + [log.snackbar.show] + + + + `; @@ -547,7 +703,7 @@ snapshots["GOOSE subscriber plugin in Publisher view with a selected GOOSE messa aria-selected="false" graphic="avatar" mwc-list-item="" - tabindex="-1" + tabindex="0" > IED1 @@ -615,7 +771,7 @@ snapshots["GOOSE subscriber plugin in Publisher view with a selected GOOSE messa graphic="avatar" hasmeta="" mwc-list-item="" - tabindex="-1" + tabindex="0" > IED1 @@ -732,6 +888,162 @@ snapshots["GOOSE subscriber plugin in Subscriber view per default the plugin its + + + + + + + + + + + + + [log.placeholder] + + + info + + + + + + + + + [close] + + + + + + + [diag.placeholder] + + + info + + + + + [close] + + + + + + + + + [log.snackbar.show] + + + + + + + [log.snackbar.show] + + + + + + + [log.snackbar.show] + + + + `; diff --git a/test/integration/editors/__snapshots__/SMVSubscriberMessageBinding.test.snap.js b/test/integration/editors/__snapshots__/SMVSubscriberMessageBinding.test.snap.js index 69ab0b7e52..57786c37a7 100644 --- a/test/integration/editors/__snapshots__/SMVSubscriberMessageBinding.test.snap.js +++ b/test/integration/editors/__snapshots__/SMVSubscriberMessageBinding.test.snap.js @@ -27,6 +27,162 @@ snapshots["Sampled Values Plugin in Publisher view initially the plugin looks li + + + + + + + + + + + + + [log.placeholder] + + + info + + + + + + + + + [close] + + + + + + + [diag.placeholder] + + + info + + + + + [close] + + + + + + + + + [log.snackbar.show] + + + + + + + [log.snackbar.show] + + + + + + + [log.snackbar.show] + + + + `; @@ -333,8 +489,10 @@ snapshots["Sampled Values Plugin in Publisher view when selecting a Sampled Valu IED2 @@ -360,6 +518,7 @@ snapshots["Sampled Values Plugin in Publisher view when selecting a Sampled Valu [subscription.none] @@ -430,8 +591,10 @@ snapshots["Sampled Values Plugin in Publisher view when selecting a Sampled Valu > [subscription.none] @@ -454,6 +617,7 @@ snapshots["Sampled Values Plugin in Publisher view when selecting a Sampled Valu IED2 @@ -560,9 +726,12 @@ snapshots["Sampled Values Plugin in Publisher view when selecting a Sampled Valu IED4 @@ -593,8 +762,10 @@ snapshots["Sampled Values Plugin in Publisher view when selecting a Sampled Valu > [subscription.none] @@ -663,6 +834,162 @@ snapshots["Sampled Values Plugin in Subscriber view initially the plugin looks l + + + + + + + + + + + + + [log.placeholder] + + + info + + + + + + + + + [close] + + + + + + + [diag.placeholder] + + + info + + + + + [close] + + + + + + + + + [log.snackbar.show] + + + + + + + [log.snackbar.show] + + + + + + + [log.snackbar.show] + + + + `; @@ -871,7 +1198,7 @@ snapshots["Sampled Values Plugin in Subscriber view when selecting an IED and su aria-disabled="false" graphic="avatar" mwc-list-item="" - tabindex="-1" + tabindex="0" > MSVCB01 (IED3) @@ -926,7 +1253,7 @@ snapshots["Sampled Values Plugin in Subscriber view when selecting an IED and su graphic="avatar" mwc-list-item="" selected="" - tabindex="0" + tabindex="-1" > MSVCB02 (IED4) @@ -964,8 +1291,10 @@ snapshots["Sampled Values Plugin in Subscriber view when selecting an IED and un > [subscription.none] @@ -1026,8 +1355,10 @@ snapshots["Sampled Values Plugin in Subscriber view when selecting an IED and un MSVCB02 (IED4) @@ -1065,8 +1396,11 @@ snapshots["Sampled Values Plugin in Subscriber view when selecting an IED and su > MSVCB02 (IED4) @@ -1091,8 +1425,10 @@ snapshots["Sampled Values Plugin in Subscriber view when selecting an IED and su > [subscription.none] diff --git a/test/unit/Logging.test.ts b/test/unit/Logging.test.ts index 46fbd86610..5331aa193d 100644 --- a/test/unit/Logging.test.ts +++ b/test/unit/Logging.test.ts @@ -44,8 +44,8 @@ describe('LoggingElement', () => { it('has no previous action', () => expect(element).to.have.property('previousAction', -1)); - it('has no current action', () => - expect(element).to.have.property('currentAction', -1)); + it('has no edit count', () => + expect(element).to.have.property('editCount', -1)); it('has no next action', () => expect(element).to.have.property('nextAction', -1)); @@ -118,8 +118,8 @@ describe('LoggingElement', () => { it('has no previous action', () => expect(element).to.have.property('previousAction', -1)); - it('has a current action', () => - expect(element).to.have.property('currentAction', 0)); + it('has an edit count', () => + expect(element).to.have.property('editCount', 0)); it('has no next action', () => expect(element).to.have.property('nextAction', -1)); @@ -138,7 +138,7 @@ describe('LoggingElement', () => { it('can reset its history', () => { element.dispatchEvent(newLogEvent({ kind: 'reset' })); expect(element).property('history').to.be.empty; - expect(element).to.have.property('currentAction', -1); + expect(element).to.have.property('editCount', -1); }); it('renders a log message for the action', () => @@ -163,8 +163,8 @@ describe('LoggingElement', () => { it('has a previous action', () => expect(element).to.have.property('previousAction', 0)); - it('has a current action', () => - expect(element).to.have.property('currentAction', 2)); + it('has an edit count', () => + expect(element).to.have.property('editCount', 2)); it('has no next action', () => expect(element).to.have.property('nextAction', -1)); @@ -173,8 +173,8 @@ describe('LoggingElement', () => { it('has no previous action', () => expect(element).to.have.property('previousAction', -1)); - it('has a current action', () => - expect(element).to.have.property('currentAction', 0)); + it('has an edit count', () => + expect(element).to.have.property('editCount', 0)); it('has a next action', () => expect(element).to.have.property('nextAction', 2)); @@ -189,7 +189,7 @@ describe('LoggingElement', () => { }) ); expect(element).property('history').to.have.lengthOf(3); - expect(element).to.have.property('currentAction', 2); + expect(element).to.have.property('editCount', 2); expect(element).to.have.property('nextAction', -1); }); @@ -205,8 +205,8 @@ describe('LoggingElement', () => { it('has a previous action', () => expect(element).to.have.property('previousAction', 0)); - it('has a current action', () => - expect(element).to.have.property('currentAction', 2)); + it('has an edit count', () => + expect(element).to.have.property('editCount', 2)); it('has no next action', () => expect(element).to.have.property('nextAction', -1)); diff --git a/test/unit/mock-plugger.ts b/test/unit/mock-plugger.ts index a14b4b226f..656d3d5b0b 100644 --- a/test/unit/mock-plugger.ts +++ b/test/unit/mock-plugger.ts @@ -1,6 +1,7 @@ import { LitElement, customElement } from 'lit-element'; import { Plugging } from '../../src/Plugging.js'; import { Editing } from '../../src/Editing.js'; +import { Logging } from '../../src/Logging.js'; @customElement('mock-plugger') -export class MockPlugger extends Plugging(Editing(LitElement)) {} +export class MockPlugger extends Plugging(Editing(Logging(LitElement))) {} From fd94619e192be4462d531903c9c8ed07382a3f78 Mon Sep 17 00:00:00 2001 From: Stef3st Date: Wed, 31 May 2023 13:51:55 +0200 Subject: [PATCH 2/4] chore: added request updates to test Signed-off-by: Stef3st --- test/unit/Plugging.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/unit/Plugging.test.ts b/test/unit/Plugging.test.ts index fd88cef0cb..9954582e45 100644 --- a/test/unit/Plugging.test.ts +++ b/test/unit/Plugging.test.ts @@ -139,6 +139,7 @@ describe('PluggingElement', () => { await src.updateComplete; await name.updateComplete; primaryAction.click(); + await element.requestUpdate(); await element.updateComplete; expect(element.editors).to.have.lengthOf(7); }); @@ -150,6 +151,7 @@ describe('PluggingElement', () => { await src.updateComplete; await name.updateComplete; primaryAction.click(); + await element.requestUpdate('menuEntries'); await element.updateComplete; expect(element.menuEntries).to.have.lengthOf(lengthMenuKindPlugins + 1); }); @@ -160,7 +162,9 @@ describe('PluggingElement', () => { await src.updateComplete; await name.updateComplete; primaryAction.click(); + await element.performUpdate(); await element.updateComplete; + expect( element.menuEntries[element.menuEntries.length - 1] ).to.have.property('requireDoc'); @@ -176,6 +180,7 @@ describe('PluggingElement', () => { await src.updateComplete; await name.updateComplete; primaryAction.click(); + await element.requestUpdate('validators'); await element.updateComplete; expect(element.validators).to.have.lengthOf(3); }); From 50085d74f203ca1f6ac62dbb3830224f04373597 Mon Sep 17 00:00:00 2001 From: Stef3st Date: Tue, 6 Jun 2023 11:17:56 +0200 Subject: [PATCH 3/4] chore: add timeout after each Signed-off-by: Stef3st --- test/unit/Plugging.test.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/unit/Plugging.test.ts b/test/unit/Plugging.test.ts index 9954582e45..cbd9b6dfe2 100644 --- a/test/unit/Plugging.test.ts +++ b/test/unit/Plugging.test.ts @@ -9,7 +9,10 @@ describe('PluggingElement', () => { let element: MockPlugger; let doc: XMLDocument; - afterEach(() => localStorage.clear()); + afterEach(async () => { + await new Promise(resolve => setTimeout(resolve, 50)); // await animation + localStorage.clear(); + }); beforeEach(async () => { doc = await fetch('/test/testfiles/valid2007B4.scd') .then(response => response.text()) @@ -139,7 +142,6 @@ describe('PluggingElement', () => { await src.updateComplete; await name.updateComplete; primaryAction.click(); - await element.requestUpdate(); await element.updateComplete; expect(element.editors).to.have.lengthOf(7); }); @@ -151,7 +153,6 @@ describe('PluggingElement', () => { await src.updateComplete; await name.updateComplete; primaryAction.click(); - await element.requestUpdate('menuEntries'); await element.updateComplete; expect(element.menuEntries).to.have.lengthOf(lengthMenuKindPlugins + 1); }); @@ -162,7 +163,6 @@ describe('PluggingElement', () => { await src.updateComplete; await name.updateComplete; primaryAction.click(); - await element.performUpdate(); await element.updateComplete; expect( @@ -180,7 +180,6 @@ describe('PluggingElement', () => { await src.updateComplete; await name.updateComplete; primaryAction.click(); - await element.requestUpdate('validators'); await element.updateComplete; expect(element.validators).to.have.lengthOf(3); }); From 6c9169a5bde8a2eef305e557abce4c575fb2a866 Mon Sep 17 00:00:00 2001 From: Stef3st Date: Tue, 6 Jun 2023 14:31:52 +0200 Subject: [PATCH 4/4] chore: added edit count to missing editors Signed-off-by: Stef3st --- src/editors/ied/da-container.ts | 1 + src/editors/substation/process-editor.ts | 9 +++++++++ src/editors/substation/zeroline-pane.ts | 1 + 3 files changed, 11 insertions(+) diff --git a/src/editors/ied/da-container.ts b/src/editors/ied/da-container.ts index b56a854d28..ee3d7f4cbf 100644 --- a/src/editors/ied/da-container.ts +++ b/src/editors/ied/da-container.ts @@ -203,6 +203,7 @@ export class DAContainer extends Container { ? this.getBDAElements().map( bdaElement => html` html` html` html` html` html` html` html`` diff --git a/src/editors/substation/zeroline-pane.ts b/src/editors/substation/zeroline-pane.ts index d264435122..3b79df1fd9 100644 --- a/src/editors/substation/zeroline-pane.ts +++ b/src/editors/substation/zeroline-pane.ts @@ -192,6 +192,7 @@ export class ZerolinePane extends LitElement { .map( process => html`