Skip to content

Commit 281b8a5

Browse files
Fixed missing functions
1 parent ff9a453 commit 281b8a5

File tree

2 files changed

+43
-40
lines changed

2 files changed

+43
-40
lines changed

src/menu/CompasImportIEDs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ export default class CompasImportIEDSMenuPlugin extends ImportingIedPlugin {
3737
}
3838

3939
protected onLoadCompasFiles(event: DocRetrievedEvent): void {
40-
this.importDoc = event.detail.doc;
41-
this.prepareImport();
40+
this.prepareImport(event.detail.doc, event.detail.docName!);
4241
this.compasOpen.close();
4342
}
4443

src/menu/UpdateSubstation.ts

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -79,50 +79,53 @@ export function isValidReference(
7979
);
8080
}
8181

82+
export function mergeSubstation(
83+
element: Element,
84+
currentDoc: Document,
85+
docWithSubstation: Document
86+
): void {
87+
element.dispatchEvent(
88+
newWizardEvent(
89+
mergeWizard(
90+
// FIXME: doesn't work with multiple Substations!
91+
currentDoc.documentElement,
92+
docWithSubstation.documentElement,
93+
{
94+
title: get('updatesubstation.title'),
95+
selected: (diff: Diff<Element | string>): boolean =>
96+
diff.theirs instanceof Element
97+
? diff.theirs.tagName === 'LNode'
98+
? find(currentDoc, 'LNode', identity(diff.theirs)) === null &&
99+
isValidReference(docWithSubstation, identity(diff.theirs))
100+
: diff.theirs.tagName === 'Substation' ||
101+
!tags['SCL'].children.includes(<SCLTag>diff.theirs.tagName)
102+
: diff.theirs !== null,
103+
disabled: (diff: Diff<Element | string>): boolean =>
104+
diff.theirs instanceof Element &&
105+
diff.theirs.tagName === 'LNode' &&
106+
(find(currentDoc, 'LNode', identity(diff.theirs)) !== null ||
107+
!isValidReference(docWithSubstation, identity(diff.theirs))),
108+
auto: (): boolean => true,
109+
}
110+
)
111+
)
112+
);
113+
}
82114
export default class UpdateSubstationPlugin extends LitElement {
83115
doc!: XMLDocument;
84116

85117
@query('#update-substation-plugin-input') pluginFileUI!: HTMLInputElement;
86118

87-
updateSubstation(event: Event): void {
119+
async updateSubstation(event: Event): Promise<void> {
88120
const file =
89121
(<HTMLInputElement | null>event.target)?.files?.item(0) ?? false;
90-
if (file)
91-
file.text().then(text => {
92-
const doc = new DOMParser().parseFromString(text, 'application/xml');
93-
this.dispatchEvent(
94-
newWizardEvent(
95-
mergeWizard(
96-
// FIXME: doesn't work with multiple Substations!
97-
this.doc.documentElement,
98-
doc.documentElement,
99-
{
100-
title: get('updatesubstation.title'),
101-
selected: (diff: Diff<Element | string>): boolean =>
102-
diff.theirs instanceof Element
103-
? diff.theirs.tagName === 'LNode'
104-
? this.doc.querySelector(
105-
find('LNode', identity(diff.theirs))
106-
) === null &&
107-
isValidReference(doc, identity(diff.theirs))
108-
: diff.theirs.tagName === 'Substation' ||
109-
!tags['SCL'].children.includes(
110-
<SCLTag>diff.theirs.tagName
111-
)
112-
: diff.theirs !== null,
113-
disabled: (diff: Diff<Element | string>): boolean =>
114-
diff.theirs instanceof Element &&
115-
diff.theirs.tagName === 'LNode' &&
116-
(this.doc.querySelector(
117-
find('LNode', identity(diff.theirs))
118-
) !== null ||
119-
!isValidReference(doc, identity(diff.theirs))),
120-
auto: (): boolean => true,
121-
}
122-
)
123-
)
124-
);
125-
});
122+
if (!file) {
123+
return;
124+
}
125+
const text = await file.text();
126+
const doc = new DOMParser().parseFromString(text, 'application/xml');
127+
128+
mergeSubstation(this, this.doc, doc);
126129
this.pluginFileUI.onchange = null;
127130
}
128131

@@ -131,7 +134,8 @@ export default class UpdateSubstationPlugin extends LitElement {
131134
}
132135

133136
render(): TemplateResult {
134-
return html`<input @click=${(event: MouseEvent) => ((<HTMLInputElement>event.target).value = '')}
137+
return html`<input @click=${(event: MouseEvent) =>
138+
((<HTMLInputElement>event.target).value = '')}
135139
@change=${this.updateSubstation}
136140
id="update-substation-plugin-input" accept=".sed,.scd,.ssd,.iid,.cid" type="file"></input>`;
137141
}

0 commit comments

Comments
 (0)