|
1 |
| -import { Create, newWizardEvent } from '../../../foundation.js'; |
2 |
| - |
3 |
| -import { editAddressWizard } from '../wizards/address.js'; |
| 1 | +import { Create } from '../../../foundation.js'; |
4 | 2 | import { TiInformation } from './cdc.js';
|
5 | 3 |
|
6 | 4 | /**
|
7 | 5 | * Create a list of Create Actions using the parameters passed. First search for the DAI Elements
|
8 | 6 | * that can be effected. Next create the action and add it to this list, also start the Edit
|
9 | 7 | * Address Element wizard for all Address Elements created.
|
10 | 8 | *
|
11 |
| - * @param doiElement - The DOI Element. |
12 |
| - * @param wizard - The Wizard to dispatch the Open Wizard event on. |
13 |
| - * @param ti - The TI Value set on the new Address Elements. |
14 |
| - * @param inverted - Indicates if the Engineer want to create inverted Address Elements, if applicable. |
15 |
| - * @param tiInformation - Information about how to create the Address Elements for the passed TI. |
| 9 | + * @param lnElement - The LN Element. |
| 10 | + * @param lnClonedElement - The Cloned LN Element, used to create new structure and determine which Create actions are needed. |
| 11 | + * @param doElement - The DO Element. |
| 12 | + * @param wizard - The Wizard to dispatch the Open Wizard event on. |
| 13 | + * @param ti - The TI Value set on the new Address Elements. |
| 14 | + * @param inverted - Indicates if the Engineer want to create inverted Address Elements, if applicable. |
| 15 | + * @param tiInformation - Information about how to create the Address Elements for the passed TI. |
16 | 16 | * @returns A list of Create Action that will be added to the complex action.
|
17 | 17 | */
|
18 | 18 | export function createActions(
|
19 |
| - doiElement: Element, |
| 19 | + lnElement: Element, |
| 20 | + lnClonedElement: Element, |
| 21 | + doElement: Element, |
20 | 22 | wizard: Element,
|
21 | 23 | ti: string,
|
22 | 24 | inverted: boolean,
|
23 | 25 | tiInformation: TiInformation
|
24 | 26 | ): 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; |
| 27 | + return tiInformation.create( |
| 28 | + lnElement, |
| 29 | + lnClonedElement, |
| 30 | + doElement, |
| 31 | + wizard, |
| 32 | + ti, |
| 33 | + tiInformation.daPaths, |
| 34 | + // If the TI Allows inverted and the Engineer selected it, true will be passed. |
| 35 | + tiInformation.inverted ? inverted : false |
| 36 | + ); |
51 | 37 | }
|
52 | 38 |
|
53 | 39 | /**
|
54 | 40 | * Create a list of Create Actions using the parameters passed. First search for the DAI Elements [name="Check"].
|
55 | 41 | * Next create the action and add it to this list, also start the Edit Address Element wizard for all Address Elements
|
56 | 42 | * created.
|
57 | 43 | *
|
58 |
| - * @param doiElement - The DOI Element. |
59 |
| - * @param wizard - The Wizard to dispatch the Open Wizard event on. |
60 |
| - * @param ti - The TI Value set on the new Address Elements. |
61 |
| - * @param tiInformation - Information about how to create the Address Elements for the passed TI. |
| 44 | + * @param lnElement - The LN Element. |
| 45 | + * @param lnClonedElement - The Cloned LN Element, used to create new structure and determine which Create actions are needed. |
| 46 | + * @param doElement - The DO Element. |
| 47 | + * @param wizard - The Wizard to dispatch the Open Wizard event on. |
| 48 | + * @param ti - The TI Value set on the new Address Elements. |
| 49 | + * @param tiInformation - Information about how to create the Address Elements for the passed TI. |
62 | 50 | * @returns A list of Create Action that will be added to the complex action.
|
63 | 51 | */
|
64 | 52 | export function createCheckActions(
|
65 |
| - doiElement: Element, |
| 53 | + lnElement: Element, |
| 54 | + lnClonedElement: Element, |
| 55 | + doElement: Element, |
66 | 56 | wizard: Element,
|
67 | 57 | ti: string,
|
68 | 58 | tiInformation: TiInformation
|
69 | 59 | ): 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 |
| - } |
| 60 | + if (tiInformation.checkDaPaths && tiInformation.checkCreate) { |
| 61 | + return tiInformation.checkCreate( |
| 62 | + lnElement, |
| 63 | + lnClonedElement, |
| 64 | + doElement, |
| 65 | + wizard, |
| 66 | + ti, |
| 67 | + tiInformation.checkDaPaths |
| 68 | + ); |
94 | 69 | }
|
95 |
| - return actions; |
| 70 | + return []; |
96 | 71 | }
|
0 commit comments