Skip to content

Commit c94826d

Browse files
feat(wizards/dataset): delete deselected FCDA (#358)
* refactor(wizards/fcda): select all FCDA of wizard initialization * fix(foundation): fCDAIndentity * feat(wizards/fcda): remove unselected FCDA with update action
1 parent 1b054b6 commit c94826d

File tree

5 files changed

+207
-70
lines changed

5 files changed

+207
-70
lines changed

__snapshots__/dataset wizards.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
aria-disabled="false"
3636
graphic="control"
3737
mwc-list-item=""
38+
selected=""
3839
tabindex="0"
3940
value="IED2>>CBSW>GooseDataSet1>CBSW/ XSWI 2.Pos stVal (ST)"
4041
>
@@ -44,11 +45,22 @@
4445
aria-disabled="false"
4546
graphic="control"
4647
mwc-list-item=""
48+
selected=""
4749
tabindex="-1"
4850
value="IED2>>CBSW>GooseDataSet1>CBSW/ XSWI 2.Pos q (ST)"
4951
>
5052
CBSW/ XSWI 2.Pos q (ST)
5153
</mwc-check-list-item>
54+
<mwc-check-list-item
55+
aria-disabled="false"
56+
graphic="control"
57+
mwc-list-item=""
58+
selected=""
59+
tabindex="-1"
60+
value="IED2>>CBSW>GooseDataSet1>CBSW/ XSWI 2.OpSlc.dsd sasd.ads.asd (ST)"
61+
>
62+
CBSW/ XSWI 2.OpSlc.dsd sasd.ads.asd (ST)
63+
</mwc-check-list-item>
5264
</filtered-list>
5365
</div>
5466
<mwc-button

src/foundation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ function fCDASelector(tagName: SCLTag, identity: string): string {
592592
const [ldInst, prefix, lnClass, lnInst] = childIdentity.split(/[ /.]/);
593593

594594
const matchDoDa = childIdentity.match(
595-
/.([A-Z][a-z0-9.]*) ([A-Za-z0-9.]*) \(/
595+
/.([A-Z][A-Za-z0-9.]*) ([A-Za-z0-9.]*) \(/
596596
);
597597
const doName = matchDoDa && matchDoDa[1] ? matchDoDa[1] : '';
598598
const daName = matchDoDa && matchDoDa[2] ? matchDoDa[2] : '';

src/wizards/dataset.ts

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CheckListItem } from '@material/mwc-list/mwc-check-list-item';
12
import { html } from 'lit-element';
23
import { get, translate } from 'lit-translate';
34

@@ -6,40 +7,67 @@ import {
67
getValue,
78
identity,
89
newWizardEvent,
10+
selector,
11+
Update,
912
Wizard,
1013
WizardAction,
1114
WizardActor,
1215
WizardInput,
1316
} from '../foundation.js';
1417
import { wizards } from './wizard-library.js';
1518

16-
export function updateDataSetAction(element: Element): WizardActor {
17-
return (inputs: WizardInput[]): WizardAction[] => {
19+
function updateDataSetAction(element: Element): WizardActor {
20+
return (inputs: WizardInput[], wizard: Element): WizardAction[] => {
1821
const name = inputs.find(i => i.label === 'name')!.value!;
1922
const desc = getValue(inputs.find(i => i.label === 'desc')!);
20-
2123
const oldName = element.getAttribute('name');
22-
if (name === oldName && desc === element.getAttribute('desc')) return [];
2324

24-
const newElement = cloneElement(element, { name, desc });
25+
const dataSetUpdateAction: Update[] = [];
26+
if (!(name === oldName && desc === element.getAttribute('desc'))) {
27+
const newElement = cloneElement(element, { name, desc });
2528

26-
const dataSetUpdateAction = [
27-
{ old: { element }, new: { element: newElement } },
28-
];
29+
dataSetUpdateAction.push({
30+
old: { element },
31+
new: { element: newElement },
32+
});
33+
}
2934

30-
const cbUpdateAction =
35+
const controlBlockUpdateActions =
3136
name !== oldName
3237
? Array.from(
3338
element.parentElement?.querySelectorAll(
3439
`ReportControlBock[datSet=${oldName}], GSEControl[datSet=${oldName}],SampledValueControl[datSet=${oldName}] `
3540
) ?? []
3641
).map(cb => {
37-
const newCb = cloneElement(element, { datSet: name });
42+
const newCb = cloneElement(cb, { datSet: name });
3843
return { old: { element: cb }, new: { element: newCb } };
3944
})
4045
: [];
4146

42-
return dataSetUpdateAction.concat(cbUpdateAction);
47+
const fCDARemoveActions = Array.from(
48+
wizard.shadowRoot!.querySelectorAll(
49+
'filtered-list > mwc-check-list-item:not([selected])'
50+
)
51+
)
52+
.map(listItem =>
53+
element.querySelector(selector('FCDA', (<CheckListItem>listItem).value))
54+
)
55+
.filter(fcda => fcda)
56+
.map(fcda => {
57+
return {
58+
old: {
59+
parent: element,
60+
element: fcda!,
61+
reference: fcda!.nextSibling,
62+
},
63+
};
64+
});
65+
66+
return [
67+
...fCDARemoveActions,
68+
...dataSetUpdateAction,
69+
...controlBlockUpdateActions,
70+
];
4371
};
4472
}
4573

@@ -86,7 +114,7 @@ export function editDataSetWizard(element: Element): Wizard {
86114
html`<filtered-list multi
87115
>${Array.from(element.querySelectorAll('FCDA')).map(
88116
fcda =>
89-
html`<mwc-check-list-item value="${identity(fcda)}"
117+
html`<mwc-check-list-item selected value="${identity(fcda)}"
90118
>${(<string>identity(fcda)).split('>')[4]}</mwc-check-list-item
91119
>`
92120
)}</filtered-list

test/testfiles/wizards/gsecontrol.scd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@
251251
<DataSet name="GooseDataSet1">
252252
<FCDA ldInst="CBSW" prefix="" lnClass="XSWI" lnInst="2" doName="Pos" daName="stVal" fc="ST"/>
253253
<FCDA ldInst="CBSW" prefix="" lnClass="XSWI" lnInst="2" doName="Pos" daName="q" fc="ST"/>
254+
<FCDA ldInst="CBSW" prefix="" lnClass="XSWI" lnInst="2" doName="OpSlc.dsd" daName="sasd.ads.asd" fc="ST"/>
254255
</DataSet>
255256
<GSEControl type="GOOSE" appID="0002" fixedOffs="false" confRev="1" name="GCB" datSet="GooseDataSet1">
256257
</GSEControl>

0 commit comments

Comments
 (0)