Skip to content

Commit 3e5c9fb

Browse files
author
Rob Tjalma
authored
Merge pull request #127 from com-pas/upstream-v0.11
Merge Upstream v0.11.0 into CoMPAS
2 parents f2f72d1 + 5b76e80 commit 3e5c9fb

File tree

84 files changed

+4060
-1354
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+4060
-1354
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [0.11.0](https://github.com/openscd/open-scd/compare/v0.10.0...v0.11.0) (2022-03-08)
6+
7+
8+
### Features
9+
10+
* **plugins/IED:** Added Functional Constraint value to DA Container. ([f389c2c](https://github.com/openscd/open-scd/commits/f389c2cf7595f9c2486dff0ef0f40a5feff028fb))
11+
* **wizards/reportcontrol:** add create wizard ([#544](https://github.com/openscd/open-scd/issues/544)) ([546419f](https://github.com/openscd/open-scd/commits/546419f31afe82ebf1315e2acce59e11f97d8ca8))
12+
* **wizards/smvopts:** add edit wizard ([#547](https://github.com/openscd/open-scd/issues/547)) ([10343c6](https://github.com/openscd/open-scd/commits/10343c605bcaf31c59d108b33838990a9615eaa4))
13+
14+
15+
### Bug Fixes
16+
17+
* **editors/template:** create element with NS definition ([#567](https://github.com/openscd/open-scd/issues/567)) ([6fe49d2](https://github.com/openscd/open-scd/commits/6fe49d234df4730bc7838f6e597312e60171b0d5))
18+
* **editors/template:** three minor issues ([#565](https://github.com/openscd/open-scd/issues/565)) ([f00092a](https://github.com/openscd/open-scd/commits/f00092a96d78f2c86c94d4978b2886489e14c952))
19+
* **Settings:** remove 'undefined' when no NSDoc version can be read ([d557d26](https://github.com/openscd/open-scd/commits/d557d264ed7a65370d774f174b0ad77c01ba934d))
20+
* **wizard/foundation/limits:** abstractDataAttributeName ([#573](https://github.com/openscd/open-scd/issues/573)) ([179cad1](https://github.com/openscd/open-scd/commits/179cad1f0d05846111a9d868b800465c7e2bc0a5))
21+
522
## [0.10.0](https://github.com/openscd/open-scd/compare/v0.9.0...v0.10.0) (2022-02-21)
623

724

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@
4040
"purpose": "maskable"
4141
}
4242
],
43-
"version": "0.10.0"
43+
"version": "0.11.0"
4444
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "open-scd",
3-
"version": "0.10.0",
3+
"version": "0.11.0",
44
"repository": "https://github.com/openscd/open-scd.git",
55
"description": "A bottom-up substation configuration designer for projects described using SCL `IEC 61850-6` Edition 2 or greater.",
66
"keywords": [

public/xml/templates.scd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@
789789
</DAType>
790790
<DAType id="OpenSCD_Unit_Hz">
791791
<BDA name="SIUnit" bType="Enum" type="SIUnitKind">
792-
<Val>A</Val>
792+
<Val>Hz</Val>
793793
</BDA>
794794
</DAType>
795795
<DAType id="OpenSCD_ValWithTrans_wo_transInd">

src/Editing.ts

Lines changed: 101 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
isDelete,
1212
isMove,
1313
isSimple,
14-
isUpdate,
14+
isReplace,
1515
LitElementConstructor,
1616
Mixin,
1717
Move,
@@ -20,7 +20,9 @@ import {
2020
OpenDocEvent,
2121
SCLTag,
2222
SimpleAction,
23+
Replace,
2324
Update,
25+
isUpdate,
2426
} from './foundation.js';
2527

2628
/** Mixin that edits an `XML` `doc`, listening to [[`EditorActionEvent`]]s */
@@ -42,12 +44,19 @@ export function Editing<TBase extends LitElementConstructor>(Base: TBase) {
4244
private checkCreateValidity(create: Create): boolean {
4345
if (create.checkValidity !== undefined) return create.checkValidity();
4446

47+
if (
48+
!(create.new.element instanceof Element) ||
49+
!(create.new.parent instanceof Element)
50+
)
51+
return true;
52+
4553
const invalid =
4654
create.new.element.hasAttribute('name') &&
4755
Array.from(create.new.parent.children).some(
4856
elm =>
49-
elm.tagName === create.new.element.tagName &&
50-
elm.getAttribute('name') === create.new.element.getAttribute('name')
57+
elm.tagName === (<Element>create.new.element).tagName &&
58+
elm.getAttribute('name') ===
59+
(<Element>create.new.element).getAttribute('name')
5160
);
5261

5362
if (invalid)
@@ -74,24 +83,32 @@ export function Editing<TBase extends LitElementConstructor>(Base: TBase) {
7483
private onCreate(action: Create) {
7584
if (!this.checkCreateValidity(action)) return false;
7685

77-
if (action.new.reference === undefined)
86+
if (
87+
action.new.reference === undefined &&
88+
action.new.element instanceof Element &&
89+
action.new.parent instanceof Element
90+
)
7891
action.new.reference = getReference(
7992
action.new.parent,
8093
<SCLTag>action.new.element.tagName
8194
);
95+
else action.new.reference = action.new.reference ?? null;
8296

8397
action.new.parent.insertBefore(action.new.element, action.new.reference);
8498
return true;
8599
}
86100

87101
private logCreate(action: Create) {
102+
const name =
103+
action.new.element instanceof Element
104+
? action.new.element.tagName
105+
: get('editing.node');
106+
88107
this.dispatchEvent(
89108
newLogEvent({
90109
kind: 'action',
91-
title: get('editing.created', {
92-
name: action.new.element.tagName,
93-
}),
94-
action: action,
110+
title: get('editing.created', { name }),
111+
action,
95112
})
96113
);
97114
}
@@ -100,18 +117,23 @@ export function Editing<TBase extends LitElementConstructor>(Base: TBase) {
100117
if (!action.old.reference)
101118
action.old.reference = action.old.element.nextSibling;
102119

103-
action.old.element.remove();
120+
if (action.old.element.parentNode !== action.old.parent) return false;
121+
122+
action.old.parent.removeChild(action.old.element);
104123
return true;
105124
}
106125

107126
private logDelete(action: Delete) {
127+
const name =
128+
action.old.element instanceof Element
129+
? action.old.element.tagName
130+
: get('editing.node');
131+
108132
this.dispatchEvent(
109133
newLogEvent({
110134
kind: 'action',
111-
title: get('editing.deleted', {
112-
name: action.old.element.tagName,
113-
}),
114-
action: action,
135+
title: get('editing.deleted', { name }),
136+
action,
115137
})
116138
);
117139
}
@@ -174,68 +196,118 @@ export function Editing<TBase extends LitElementConstructor>(Base: TBase) {
174196
);
175197
}
176198

177-
private checkUpdateValidity(update: Update): boolean {
178-
if (update.checkValidity !== undefined) return update.checkValidity();
199+
private checkReplaceValidity(replace: Replace): boolean {
200+
if (replace.checkValidity !== undefined) return replace.checkValidity();
179201

180202
const invalid =
181-
update.new.element.hasAttribute('name') &&
182-
update.new.element.getAttribute('name') !==
183-
update.old.element.getAttribute('name') &&
184-
Array.from(update.old.element.parentElement?.children ?? []).some(
203+
replace.new.element.hasAttribute('name') &&
204+
replace.new.element.getAttribute('name') !==
205+
replace.old.element.getAttribute('name') &&
206+
Array.from(replace.old.element.parentElement?.children ?? []).some(
185207
elm =>
186-
elm.tagName === update.new.element.tagName &&
187-
elm.getAttribute('name') === update.new.element.getAttribute('name')
208+
elm.tagName === replace.new.element.tagName &&
209+
elm.getAttribute('name') ===
210+
replace.new.element.getAttribute('name')
188211
);
189212

190213
if (invalid)
191214
this.dispatchEvent(
192215
newLogEvent({
193216
kind: 'error',
194217
title: get('editing.error.update', {
195-
name: update.new.element.tagName,
218+
name: replace.new.element.tagName,
196219
}),
197220
message: get('editing.error.nameClash', {
198-
parent: update.old.element.parentElement!.tagName,
199-
child: update.new.element.tagName,
200-
name: update.new.element.getAttribute('name')!,
221+
parent: replace.old.element.parentElement!.tagName,
222+
child: replace.new.element.tagName,
223+
name: replace.new.element.getAttribute('name')!,
201224
}),
202225
})
203226
);
204227

205228
return !invalid;
206229
}
207230

208-
private onUpdate(action: Update) {
209-
if (!this.checkUpdateValidity(action)) return false;
231+
private onReplace(action: Replace) {
232+
if (!this.checkReplaceValidity(action)) return false;
210233

211234
action.new.element.append(...Array.from(action.old.element.children));
212235
action.old.element.replaceWith(action.new.element);
213236
return true;
214237
}
215238

216-
private logUpdate(action: Update) {
239+
private logUpdate(action: Replace | Update) {
240+
const name = isReplace(action)
241+
? action.new.element.tagName
242+
: (action as Update).element.tagName;
243+
217244
this.dispatchEvent(
218245
newLogEvent({
219246
kind: 'action',
220247
title: get('editing.updated', {
221-
name: action.new.element.tagName,
248+
name,
222249
}),
223250
action: action,
224251
})
225252
);
226253
}
227254

255+
private checkUpdateValidity(update: Update): boolean {
256+
if (update.checkValidity !== undefined) return update.checkValidity();
257+
258+
const invalid = Array.from(
259+
update.element.parentElement?.children ?? []
260+
).some(
261+
elm =>
262+
elm.tagName === update.element.tagName &&
263+
elm.getAttribute('name') === update.newAttributes['name']
264+
);
265+
266+
if (invalid)
267+
this.dispatchEvent(
268+
newLogEvent({
269+
kind: 'error',
270+
title: get('editing.error.update', {
271+
name: update.element.tagName,
272+
}),
273+
message: get('editing.error.nameClash', {
274+
parent: update.element.parentElement!.tagName,
275+
child: update.element.tagName,
276+
name: update.newAttributes['name']!,
277+
}),
278+
})
279+
);
280+
281+
return !invalid;
282+
}
283+
284+
private onUpdate(action: Update) {
285+
if (!this.checkUpdateValidity(action)) return false;
286+
287+
Array.from(action.element.attributes).forEach(attr =>
288+
action.element.removeAttributeNode(attr)
289+
);
290+
291+
Object.entries(action.newAttributes).forEach(([key, value]) => {
292+
if (value) action.element.setAttribute(key, value);
293+
});
294+
295+
return true;
296+
}
297+
228298
private onSimpleAction(action: SimpleAction) {
229299
if (isMove(action)) return this.onMove(action as Move);
230300
else if (isCreate(action)) return this.onCreate(action as Create);
231301
else if (isDelete(action)) return this.onDelete(action as Delete);
302+
else if (isReplace(action)) return this.onReplace(action as Replace);
232303
else if (isUpdate(action)) return this.onUpdate(action as Update);
233304
}
234305

235306
private logSimpleAction(action: SimpleAction) {
236307
if (isMove(action)) this.logMove(action as Move);
237308
else if (isCreate(action)) this.logCreate(action as Create);
238309
else if (isDelete(action)) this.logDelete(action as Delete);
310+
else if (isReplace(action)) this.logUpdate(action as Replace);
239311
else if (isUpdate(action)) this.logUpdate(action as Update);
240312
}
241313

src/Setting.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ export function Setting<TBase extends LitElementConstructor>(Base: TBase) {
200200
}
201201
const nsdVersion = nsdVersions[id as keyof NsdVersions];
202202
const nsdocVersion = {
203-
version: nsdocElement!.getAttribute('version') ?? undefined,
204-
revision: nsdocElement!.getAttribute('revision') ?? undefined,
205-
release: nsdocElement!.getAttribute('release') ?? undefined
203+
version: nsdocElement!.getAttribute('version') ?? '',
204+
revision: nsdocElement!.getAttribute('revision') ?? '',
205+
release: nsdocElement!.getAttribute('release') ?? ''
206206
}
207207

208208
if (!this.isEqual(nsdVersion, nsdocVersion)) {

src/compas/CompasAutoAlignment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import '@material/mwc-list';
55
import '@material/mwc-list/mwc-check-list-item';
66

77
import {newLogEvent, newOpenDocEvent, newWizardEvent} from "../foundation.js";
8-
import {dispatchEventOnOpenScd, getOpenScdElement} from "./foundation.js";
8+
import {dispatchEventOnOpenScd} from "./foundation.js";
99

1010
import {CompasSclAutoAlignmentService} from "../compas-services/CompasSclAutoAlignmentService.js";
1111
import {createLogEvent} from "../compas-services/foundation.js";

src/editors/ied/da-container.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Nsdoc } from '../../foundation/nsdoc.js';
2121
@customElement('da-container')
2222
export class DAContainer extends LitElement {
2323
/**
24-
* The DA itself.
24+
* The (B)DA itself.
2525
*/
2626
@property({ attribute: false })
2727
element!: Element;
@@ -40,17 +40,19 @@ export class DAContainer extends LitElement {
4040

4141
@property()
4242
nsdoc!: Nsdoc;
43-
44-
@query('#toggleButton') toggleButton: IconButtonToggle | undefined;
43+
44+
@query('#toggleButton')
45+
toggleButton: IconButtonToggle | undefined;
4546

4647
private header(): TemplateResult {
4748
const name = getNameAttribute(this.element);
48-
const bType = this.element!.getAttribute('bType') ?? nothing;
49+
const bType = this.element.getAttribute('bType') ?? nothing;
50+
const fc = this.element.getAttribute("fc");
4951

5052
if (this.instanceElement) {
51-
return html`<b>${name}</b> &mdash; ${bType}`;
53+
return html`<b>${name}</b> &mdash; ${bType}${fc ? html` [${fc}]`: ``}`;
5254
} else {
53-
return html`${name} &mdash; ${bType}`;
55+
return html`${name} &mdash; ${bType}${fc ? html` [${fc}]`: ``}`;
5456
}
5557
}
5658

@@ -76,6 +78,7 @@ export class DAContainer extends LitElement {
7678
return element.querySelector('Val') ?? null;
7779
}
7880

81+
7982
/**
8083
* Get the nested (B)DA element(s) if available.
8184
* @returns The nested (B)DA element(s) of this (B)DA container.
@@ -132,4 +135,4 @@ export class DAContainer extends LitElement {
132135
padding-left: 0.3em;
133136
}
134137
`;
135-
}
138+
}

0 commit comments

Comments
 (0)