Skip to content

Commit 1cd6fb7

Browse files
authored
feat(wizards/ied): added new textfields for IED properties (openscd#822)
* chore(translations): adding helpers for additional IED wizard-textfields * feat(wizards/ied): added new textfields for IED properties * test(wizard/ied): verifying correct render of IED properties as texfields * test(wizard/ied): generated new snapshot with textfields * feat(wizard/ied): updated IED prop texfields to match other readonly fields in the app (DO wizard) * test(wizard/ied): updated tests to match changes in ied wizard implementation * chore(wizard/ied): removed unused helper translations * test(wizard/ied): fixed bug of using wrong comparative fn in tests and replaced old snapshot * feat(wizard/ied): updated validatedVersionAttribute() with suggestion from @dlabordus * test(wizard/ied): using ied's attributes in the XML doc instead of fixed values for comparissons
1 parent 04329d9 commit 1cd6fb7

File tree

3 files changed

+114
-1
lines changed

3 files changed

+114
-1
lines changed

src/wizards/ied.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ const iedNamePattern =
3636
export function renderIEDWizard(
3737
name: string | null,
3838
desc: string | null,
39+
type: string | null,
40+
manufacturer: string | null,
41+
configVersion: string | null,
42+
originalSclVersion: string,
43+
engRight: string | null,
44+
owner: string | null,
3945
reservedNames: string[]
4046
): TemplateResult[] {
4147
return [
@@ -56,6 +62,42 @@ export function renderIEDWizard(
5662
helper="${translate('ied.wizard.descHelper')}"
5763
pattern="${patterns.normalizedString}"
5864
></wizard-textfield>`,
65+
html`<wizard-textfield
66+
label="type"
67+
.maybeValue=${type || "-"}
68+
readOnly
69+
disabled
70+
></wizard-textfield>`,
71+
html`<wizard-textfield
72+
label="manufacturer"
73+
.maybeValue=${manufacturer || "-"}
74+
readOnly
75+
disabled
76+
></wizard-textfield>`,
77+
html`<wizard-textfield
78+
label="configVersion"
79+
.maybeValue=${configVersion || "-"}
80+
readOnly
81+
disabled
82+
></wizard-textfield>`,
83+
html`<wizard-textfield
84+
label="originalSclVersion"
85+
.maybeValue=${originalSclVersion || "-"}
86+
readOnly
87+
disabled
88+
></wizard-textfield>`,
89+
html`<wizard-textfield
90+
label="engRight"
91+
.maybeValue=${engRight || "-"}
92+
readOnly
93+
disabled
94+
></wizard-textfield>`,
95+
html`<wizard-textfield
96+
label="owner"
97+
.maybeValue=${owner || "-"}
98+
readOnly
99+
disabled
100+
></wizard-textfield>`
59101
];
60102
}
61103

@@ -78,6 +120,12 @@ function renderIEDReferencesWizard(references: Delete[]): TemplateResult[] {
78120
];
79121
}
80122

123+
function validatedVersionAttribute(element: Element): string {
124+
return (element.getAttribute('originalSclVersion') ?? '')
125+
.concat(element.getAttribute('originalSclRevision') ?? '')
126+
.concat(element.getAttribute('originalSclRelease') ?? '')
127+
}
128+
81129
export function reservedNamesIED(currentElement: Element): string[] {
82130
return Array.from(currentElement.parentNode!.querySelectorAll('IED'))
83131
.filter(isPublic)
@@ -169,6 +217,12 @@ export function editIEDWizard(element: Element): Wizard {
169217
content: renderIEDWizard(
170218
element.getAttribute('name'),
171219
element.getAttribute('desc'),
220+
element.getAttribute('type'),
221+
element.getAttribute('manufacturer'),
222+
element.getAttribute('configVersion'),
223+
validatedVersionAttribute(element),
224+
element.getAttribute('engRight'),
225+
element.getAttribute('owner'),
172226
reservedNamesIED(element)
173227
),
174228
},

test/unit/wizards/__snapshots__/ied.test.snap.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,42 @@ snapshots["Wizards for SCL element IED edit IED looks like the latest snapshot"]
4949
pattern="([ -~]|[…]|[ -퟿]|[-�])*"
5050
>
5151
</wizard-textfield>
52+
<wizard-textfield
53+
disabled=""
54+
label="type"
55+
readonly=""
56+
>
57+
</wizard-textfield>
58+
<wizard-textfield
59+
disabled=""
60+
label="manufacturer"
61+
readonly=""
62+
>
63+
</wizard-textfield>
64+
<wizard-textfield
65+
disabled=""
66+
label="configVersion"
67+
readonly=""
68+
>
69+
</wizard-textfield>
70+
<wizard-textfield
71+
disabled=""
72+
label="originalSclVersion"
73+
readonly=""
74+
>
75+
</wizard-textfield>
76+
<wizard-textfield
77+
disabled=""
78+
label="engRight"
79+
readonly=""
80+
>
81+
</wizard-textfield>
82+
<wizard-textfield
83+
disabled=""
84+
label="owner"
85+
readonly=""
86+
>
87+
</wizard-textfield>
5288
</div>
5389
<mwc-button
5490
dialogaction="close"

test/unit/wizards/ied.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,30 @@ describe('Wizards for SCL element IED', () => {
4646
await element.requestUpdate();
4747
inputs = Array.from(element.wizardUI.inputs);
4848
});
49-
49+
it('contains a wizard-textfield with a non-empty "type" value', async () => {
50+
expect((<WizardTextField[]>inputs).find(textField => textField.label == 'type')?.value).to
51+
.be.equal(ied.getAttribute('type') || '-');
52+
});
53+
it('contains a wizard-textfield with a non-empty "manufacturer" value', async () => {
54+
expect((<WizardTextField[]>inputs).find(textField => textField.label == 'manufacturer')?.value).to
55+
.be.equal(ied.getAttribute('manufacturer') || '-');
56+
});
57+
it('contains a wizard-textfield with a non-empty "configVersion" value', async () => {
58+
expect((<WizardTextField[]>inputs).find(textField => textField.label == 'configVersion')?.value).to
59+
.be.equal(ied.getAttribute('configVersion') || '-');
60+
});
61+
it('contains a wizard-textfield with a non-empty "originalSclVersion" value', async () => {
62+
expect((<WizardTextField[]>inputs).find(textField => textField.label == 'originalSclVersion')?.value).to
63+
.contain(ied.getAttribute('originalSclVersion') || '-');
64+
});
65+
it('contains a wizard-textfield with an empty "engRight" value', async () => {
66+
expect((<WizardTextField[]>inputs).find(textField => textField.label == 'engRight')?.value).to
67+
.be.equal(ied.getAttribute('engRight') || '-');
68+
});
69+
it('contains a wizard-textfield with a non-empty "owner" value', async () => {
70+
expect((<WizardTextField[]>inputs).find(textField => textField.label == 'owner')?.value).to
71+
.be.equal(ied.getAttribute('owner') || '-');
72+
});
5073
it('update name should be updated in document', async function () {
5174
await setWizardTextFieldValue(<WizardTextField>inputs[0], 'OtherIED3');
5275

0 commit comments

Comments
 (0)