Skip to content

Commit 7a2c3de

Browse files
author
Dennis Labordus
committed
First steps changing code to support uninitialized DO structures.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent 7f9683a commit 7a2c3de

File tree

15 files changed

+750
-487
lines changed

15 files changed

+750
-487
lines changed

src/editors/protocol104/doi-container.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import '../../action-pane.js';
2424

2525
import {
2626
get104DetailsLine,
27-
getCdcValue,
27+
getCdcValueFromDOIElement,
2828
getFullPath,
29-
PRIVATE_TYPE_104,
3029
} from './foundation/foundation.js';
3130
import { editAddressWizard } from './wizards/address.js';
3231
import { showDOIInfoWizard } from './wizards/doi.js';
32+
import { PROTOCOL_104_PRIVATE } from './foundation/private.js';
3333

3434
/**
3535
* Container showing all the DAI Elements, related to the 104 Protocol, of the passed DOI Element in a list.
@@ -48,8 +48,9 @@ export class Doi104Container extends LitElement {
4848
return Array.from(this.element.querySelectorAll(`DAI`))
4949
.filter(
5050
daiElement =>
51-
daiElement.querySelector(`Private[type="${PRIVATE_TYPE_104}"]`) !==
52-
null
51+
daiElement.querySelector(
52+
`Private[type="${PROTOCOL_104_PRIVATE}"] > Address`
53+
) !== null
5354
)
5455
.sort((dai1, dai2) =>
5556
getFullPath(dai1, 'DOI').localeCompare(getFullPath(dai2, 'DOI'))
@@ -59,7 +60,7 @@ export class Doi104Container extends LitElement {
5960
private getAddressElements(daiElement: Element): Element[] {
6061
return Array.from(
6162
daiElement.querySelectorAll(
62-
`Private[type="${PRIVATE_TYPE_104}"] > Address`
63+
`Private[type="${PROTOCOL_104_PRIVATE}"] > Address`
6364
)
6465
).sort((addr1, addr2) =>
6566
(addr1.getAttribute('ioa') ?? '').localeCompare(
@@ -88,7 +89,7 @@ export class Doi104Container extends LitElement {
8889
@property()
8990
get header(): TemplateResult {
9091
const fullPath = getFullPath(this.element, 'IED');
91-
const cdc = getCdcValue(this.element);
92+
const cdc = getCdcValueFromDOIElement(this.element);
9293

9394
return html`${fullPath}${cdc ? html` (${cdc})` : nothing}`;
9495
}
Lines changed: 27 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,65 @@
1-
import { Create, newWizardEvent } from '../../../foundation.js';
2-
3-
import { editAddressWizard } from '../wizards/address.js';
1+
import { Create } from '../../../foundation.js';
42
import { TiInformation } from './cdc.js';
53

64
/**
75
* Create a list of Create Actions using the parameters passed. First search for the DAI Elements
86
* that can be effected. Next create the action and add it to this list, also start the Edit
97
* Address Element wizard for all Address Elements created.
108
*
11-
* @param doiElement - The DOI Element.
9+
* @param lnElement - The LN Element.
10+
* @param doElement - The DO Element.
1211
* @param wizard - The Wizard to dispatch the Open Wizard event on.
1312
* @param ti - The TI Value set on the new Address Elements.
1413
* @param inverted - Indicates if the Engineer want to create inverted Address Elements, if applicable.
1514
* @param tiInformation - Information about how to create the Address Elements for the passed TI.
1615
* @returns A list of Create Action that will be added to the complex action.
1716
*/
1817
export function createActions(
19-
doiElement: Element,
18+
lnElement: Element,
19+
doElement: Element,
2020
wizard: Element,
2121
ti: string,
2222
inverted: boolean,
2323
tiInformation: TiInformation
2424
): Create[] {
25-
const actions: Create[] = [];
26-
const daiElements = doiElement.querySelectorAll(tiInformation.filter);
27-
if (daiElements.length > 0) {
28-
daiElements.forEach(daiElement => {
29-
const createActions = tiInformation.create(
30-
daiElement,
31-
ti,
32-
tiInformation.inverted ? inverted : false // If the TI Allows it and the Engineer selected it, true will be passed.
33-
);
34-
actions.push(...createActions);
35-
36-
createActions.forEach(createAction => {
37-
const privateElement = <Element>createAction.new.element;
38-
Array.from(privateElement.querySelectorAll('Address')).forEach(
39-
addressElement => {
40-
wizard.dispatchEvent(
41-
newWizardEvent(() =>
42-
editAddressWizard(daiElement, addressElement)
43-
)
44-
);
45-
}
46-
);
47-
});
48-
});
49-
}
50-
return actions;
25+
return tiInformation.create(
26+
lnElement,
27+
doElement,
28+
wizard,
29+
ti,
30+
tiInformation.daPaths,
31+
// If the TI Allows inverted and the Engineer selected it, true will be passed.
32+
tiInformation.inverted ? inverted : false
33+
);
5134
}
5235

5336
/**
5437
* Create a list of Create Actions using the parameters passed. First search for the DAI Elements [name="Check"].
5538
* Next create the action and add it to this list, also start the Edit Address Element wizard for all Address Elements
5639
* created.
5740
*
58-
* @param doiElement - The DOI Element.
41+
* @param lnElement - The LN Element.
42+
* @param doElement - The DO Element.
5943
* @param wizard - The Wizard to dispatch the Open Wizard event on.
6044
* @param ti - The TI Value set on the new Address Elements.
6145
* @param tiInformation - Information about how to create the Address Elements for the passed TI.
6246
* @returns A list of Create Action that will be added to the complex action.
6347
*/
6448
export function createCheckActions(
65-
doiElement: Element,
49+
lnElement: Element,
50+
doElement: Element,
6651
wizard: Element,
6752
ti: string,
6853
tiInformation: TiInformation
6954
): Create[] {
70-
const actions: Create[] = [];
71-
if (tiInformation.checkFilter) {
72-
const daiElements = doiElement.querySelectorAll(tiInformation.checkFilter);
73-
if (daiElements.length > 0) {
74-
daiElements.forEach(daiElement => {
75-
if (tiInformation.checkCreate) {
76-
const createActions = tiInformation.checkCreate(daiElement, ti);
77-
actions.push(...createActions);
78-
79-
createActions.forEach(createAction => {
80-
const privateElement = <Element>createAction.new.element;
81-
Array.from(privateElement.querySelectorAll('Address')).forEach(
82-
addressElement => {
83-
wizard.dispatchEvent(
84-
newWizardEvent(() =>
85-
editAddressWizard(daiElement, addressElement)
86-
)
87-
);
88-
}
89-
);
90-
});
91-
}
92-
});
93-
}
55+
if (tiInformation.checkDaPaths && tiInformation.checkCreate) {
56+
return tiInformation.checkCreate(
57+
lnElement,
58+
doElement,
59+
wizard,
60+
ti,
61+
tiInformation.checkDaPaths
62+
);
9463
}
95-
return actions;
64+
return [];
9665
}

0 commit comments

Comments
 (0)