@hmcts/opal-frontend-common 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/abstract/abstract-form-base/index.d.ts +5 -5
- package/components/govuk/govuk-tabs/govuk-tabs-list-item/README.md +64 -0
- package/components/govuk/govuk-tabs/govuk-tabs-list-item/index.d.ts +21 -0
- package/components/govuk/govuk-tabs/govuk-tabs-panel/README.md +52 -0
- package/components/govuk/govuk-tabs/govuk-tabs-panel/index.d.ts +8 -0
- package/components/govuk/govuk-tabs/index.d.ts +20 -32
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-array-base.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-base.mjs +16 -13
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-base.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-tab-data.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-alphagov-alphagov-accessible-autocomplete.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-accordion.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-back-link.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-button.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-cancel-link.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-checkboxes.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-date-input.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-details.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-footer.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-header.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-heading-with-caption.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-pagination.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-panel.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-radio.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-select.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-summary-card-list.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-summary-list.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-table.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.mjs +56 -0
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.mjs +18 -0
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs.mjs +34 -75
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tag.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-task-list.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-text-area.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-text-input-prefix-suffix.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-text-input.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-alert.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-badge.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-button-menu.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-date-picker.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-header.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-notification-badge.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-page-header.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-pagination.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-primary-navigation.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-sortable-table.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-sub-navigation.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-ticket-panel.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-timeline.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-constants.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-directives-capitalisation.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-guards-can-deactivate.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-guards-helpers.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-guards-route-permissions.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-pages-access-denied.component-hjYG8Hhi.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-pages-routing-constants.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-pages-sign-in-stub.component-CMgQc0uF.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-pages-sign-in.component-UHSDf5ya.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-pages.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-pipes-date-format.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-resolvers-title.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-resolvers-user-state.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-services-auth-service-constants.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-services-date-service-interfaces.mjs +4 -0
- package/fesm2022/hmcts-opal-frontend-common-services-date-service-interfaces.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-services-date-service.mjs +15 -0
- package/fesm2022/hmcts-opal-frontend-common-services-date-service.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-services-launch-darkly-service-mocks.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-services-session-service-constants.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-services-session-service-mocks.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-services-transfer-state-service-mocks.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-services-transfer-state-service.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-services-transformation-service.mjs +23 -0
- package/fesm2022/hmcts-opal-frontend-common-services-transformation-service.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-services-utils-service.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-stores-global.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-validators-amount.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-validators-driving-licence-number.mjs +23 -0
- package/fesm2022/hmcts-opal-frontend-common-validators-driving-licence-number.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-validators-future-date.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-validators-over-eighteen.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-validators-past-date.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-validators-pattern-validator.mjs +28 -0
- package/fesm2022/hmcts-opal-frontend-common-validators-pattern-validator.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-validators-time-format.mjs +20 -0
- package/fesm2022/hmcts-opal-frontend-common-validators-time-format.mjs.map +1 -0
- package/package.json +29 -1
- package/services/date-service/index.d.ts +10 -0
- package/services/date-service/interfaces/index.d.ts +10 -0
- package/services/transformation-service/index.d.ts +11 -0
- package/validators/driving-licence-number/index.d.ts +12 -0
- package/validators/pattern-validator/index.d.ts +14 -0
- package/validators/time-format/index.d.ts +9 -0
|
@@ -164,12 +164,12 @@ declare abstract class AbstractFormBaseComponent implements OnInit, OnDestroy {
|
|
|
164
164
|
*/
|
|
165
165
|
protected hasUnsavedChanges(): boolean;
|
|
166
166
|
/**
|
|
167
|
-
* Sets the value of a
|
|
167
|
+
* Sets the value of a form control specified by its path and marks it as touched.
|
|
168
168
|
*
|
|
169
|
-
* @param
|
|
170
|
-
* @param
|
|
169
|
+
* @param value - The value to set for the form control.
|
|
170
|
+
* @param controlPath - The dot-delimited path to the form control within the form group.
|
|
171
171
|
*/
|
|
172
|
-
protected setInputValue(value: string,
|
|
172
|
+
protected setInputValue(value: string, controlPath: string): void;
|
|
173
173
|
/**
|
|
174
174
|
* Handles the form errors for the date input fields.
|
|
175
175
|
* @param formErrors - An array of form errors.
|
|
@@ -229,7 +229,7 @@ declare abstract class AbstractFormBaseComponent implements OnInit, OnDestroy {
|
|
|
229
229
|
* @param route string of route
|
|
230
230
|
* @param nonRelative boolean indicating if route is relative to the parent
|
|
231
231
|
*/
|
|
232
|
-
handleRoute(route: string, nonRelative?: boolean, event?: Event): void;
|
|
232
|
+
handleRoute(route: string, nonRelative?: boolean, event?: Event, routeData?: any): void;
|
|
233
233
|
/**
|
|
234
234
|
* Handles the form submission event.
|
|
235
235
|
*
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# GOV.UK Tab List Item Component
|
|
2
|
+
|
|
3
|
+
This Angular component renders a single `<li>` element with the appropriate GOV.UK class for use within a tabbed navigation structure. It wraps a projected `<a>` tag that acts as the tab link.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Testing](#testing)
|
|
10
|
+
- [Contributing](#contributing)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Each component in the `govuk-tabs` group is exported individually:
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { GovukTabListItemComponent } from 'opal-frontend-common/components/govuk/govuk-tabs/govuk-tab-list-item';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
This component renders a `<li>` with appropriate GOV.UK classes for use within a tabs list. It wraps a projected `<a>` element.
|
|
23
|
+
|
|
24
|
+
You must provide the following inputs:
|
|
25
|
+
|
|
26
|
+
- `tabItemFragment` — a unique string fragment to identify this tab
|
|
27
|
+
- `activeTabItemFragment` — the currently selected fragment (e.g. from the route or state)
|
|
28
|
+
- `tabItemId` — the unique ID for accessibility
|
|
29
|
+
|
|
30
|
+
The link text inside the `<a>` is projected using `<ng-content>`.
|
|
31
|
+
|
|
32
|
+
### Example
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<opal-lib-govuk-tabs-list-item
|
|
36
|
+
[tabItemFragment]="'panel-individuals'"
|
|
37
|
+
[activeTabItemFragment]="activeTabFragment"
|
|
38
|
+
[tabItemId]="'tab-individuals'"
|
|
39
|
+
>
|
|
40
|
+
<ng-content [linkText]>Individuals</ng-content>
|
|
41
|
+
</opal-lib-govuk-tabs-list-item>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This results in:
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<li class="govuk-tabs__list-item govuk-tabs__list-item--selected" id="tab-individuals">
|
|
48
|
+
<a id="tab-individuals" href="#panel-individuals" class="govuk-tabs__tab">Individuals</a>
|
|
49
|
+
</li>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The `govuk-tabs__list-item--selected` class is applied automatically when `tabItemFragment` matches `activeTabItemFragment`.
|
|
53
|
+
|
|
54
|
+
## Testing
|
|
55
|
+
|
|
56
|
+
Unit tests for this component can be found in the `govuk-tab-list-item.component.spec.ts` file. To run the tests:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
ng test
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Contributing
|
|
63
|
+
|
|
64
|
+
Feel free to submit issues or pull requests to improve this component.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
|
|
3
|
+
declare class GovukTabsListItemComponent {
|
|
4
|
+
private readonly router;
|
|
5
|
+
private readonly route;
|
|
6
|
+
tabItemId: string;
|
|
7
|
+
tabItemFragment: string;
|
|
8
|
+
activeTabItemFragment: string;
|
|
9
|
+
get hostClass(): string;
|
|
10
|
+
get hostId(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Handles the click event of a sub-navigation item.
|
|
13
|
+
* @param event - The click event.
|
|
14
|
+
* @param item - The item string.
|
|
15
|
+
*/
|
|
16
|
+
handleItemClick(event: Event, item: string): void;
|
|
17
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GovukTabsListItemComponent, never>;
|
|
18
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<GovukTabsListItemComponent, "opal-lib-govuk-tabs-list-item, [opal-lib-govuk-tabs-list-item]", never, { "tabItemId": { "alias": "tabItemId"; "required": true; }; "tabItemFragment": { "alias": "tabItemFragment"; "required": true; }; "activeTabItemFragment": { "alias": "activeTabItemFragment"; "required": true; }; }, {}, never, ["*"], true, never>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { GovukTabsListItemComponent };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# GOV.UK Tab Panel Component
|
|
2
|
+
|
|
3
|
+
This Angular component renders a GOV.UK-styled tab panel, used in conjunction with `govuk-tabs` and `govuk-tab-list-item`. It wraps content in a `<div>` with the appropriate GOV.UK class.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Testing](#testing)
|
|
10
|
+
- [Contributing](#contributing)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Each component in the `govuk-tabs` group is exported individually:
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { GovukTabPanelComponent } from 'opal-frontend-common/components/govuk/govuk-tabs/govuk-tab-panel';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
Wrap your tab content in this component and provide a unique ID to link it with the corresponding tab.
|
|
23
|
+
|
|
24
|
+
### Example
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<opal-lib-govuk-tab-panel id="panel-individuals">
|
|
28
|
+
<h2 class="govuk-heading-m">Individuals</h2>
|
|
29
|
+
<p>This is content for the Individuals tab.</p>
|
|
30
|
+
</opal-lib-govuk-tab-panel>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This renders:
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<div class="govuk-tabs__panel" id="panel-individuals">
|
|
37
|
+
<h2 class="govuk-heading-m">Individuals</h2>
|
|
38
|
+
<p>This is content for the Individuals tab.</p>
|
|
39
|
+
</div>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Testing
|
|
43
|
+
|
|
44
|
+
Unit tests for this component can be found in the `govuk-tab-panel.component.spec.ts` file. To run the tests:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
ng test
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Contributing
|
|
51
|
+
|
|
52
|
+
Feel free to submit issues or pull requests to improve this component.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
|
|
3
|
+
declare class GovukTabsPanelComponent {
|
|
4
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GovukTabsPanelComponent, never>;
|
|
5
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<GovukTabsPanelComponent, "opal-lib-govuk-tabs-panel", never, {}, {}, never, ["*"], true, never>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { GovukTabsPanelComponent };
|
|
@@ -1,39 +1,27 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { OnInit, OnDestroy, EventEmitter } from '@angular/core';
|
|
3
3
|
|
|
4
|
-
declare class
|
|
5
|
-
private readonly
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
private readonly utilService;
|
|
19
|
-
_tabsPanelId: string;
|
|
20
|
-
tabsId: string;
|
|
21
|
-
set tabsPanelId(tabsPanelId: string);
|
|
22
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<GovukTabPanelComponent, never>;
|
|
23
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<GovukTabPanelComponent, "opal-lib-govuk-tab-panel", never, { "tabsId": { "alias": "tabsId"; "required": true; }; "tabsPanelId": { "alias": "tabsPanelId"; "required": true; }; }, {}, never, ["*"], true, never>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
declare class GovukTabsComponent implements AfterViewInit {
|
|
27
|
-
private readonly platformId;
|
|
28
|
-
tabsId: string;
|
|
4
|
+
declare class GovukTabsComponent implements OnInit, OnDestroy {
|
|
5
|
+
private readonly route;
|
|
6
|
+
private readonly ngUnsubscribe;
|
|
7
|
+
tabId: string;
|
|
8
|
+
activeTabFragmentChange: EventEmitter<string>;
|
|
9
|
+
private setupListeners;
|
|
10
|
+
/**
|
|
11
|
+
* Angular lifecycle hook that is called after the component's data-bound properties have been initialized.
|
|
12
|
+
* Initializes the component by setting up necessary event listeners.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* This method is part of the Angular OnInit lifecycle interface.
|
|
16
|
+
*/
|
|
17
|
+
ngOnInit(): void;
|
|
29
18
|
/**
|
|
30
|
-
* Lifecycle hook that is called
|
|
31
|
-
*
|
|
32
|
-
* We use it to initialize the govuk-frontend component.
|
|
19
|
+
* Lifecycle hook that is called when the component is about to be destroyed.
|
|
20
|
+
* Unsubscribes from the route fragment subscription.
|
|
33
21
|
*/
|
|
34
|
-
|
|
22
|
+
ngOnDestroy(): void;
|
|
35
23
|
static ɵfac: i0.ɵɵFactoryDeclaration<GovukTabsComponent, never>;
|
|
36
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<GovukTabsComponent, "opal-lib-govuk-tabs", never, { "
|
|
24
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<GovukTabsComponent, "opal-lib-govuk-tabs", never, { "tabId": { "alias": "tabId"; "required": true; }; }, { "activeTabFragmentChange": "activeTabFragmentChange"; }, never, ["[tab-list-items]", "[tab-panels]"], true, never>;
|
|
37
25
|
}
|
|
38
26
|
|
|
39
|
-
export {
|
|
27
|
+
export { GovukTabsComponent };
|
package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.mjs","sources":["../../../projects/opal-frontend-common/components/abstract/abstract-form-alias-base/abstract-form-alias-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-alias-base/hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.ts"],"sourcesContent":["import { FormArray, FormControl, FormGroup, ValidatorFn } from '@angular/forms';\nimport { takeUntil } from 'rxjs';\nimport { Component, OnDestroy, OnInit } from '@angular/core';\nimport { IAbstractFormAliasBaseAliasControls } from '@hmcts/opal-frontend-common/components/abstract/abstract-form-alias-base/interfaces';\nimport { AbstractFormBaseComponent } from '@hmcts/opal-frontend-common/components/abstract/abstract-form-base';\nimport {\n IAbstractFormArrayControlValidation,\n IAbstractFormArrayControls,\n IAbstractFormArrayControl,\n} from '@hmcts/opal-frontend-common/components/abstract/interfaces';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormAliasBaseComponent extends AbstractFormBaseComponent implements OnInit, OnDestroy {\n public aliasControls: IAbstractFormAliasBaseAliasControls[] = [];\n public aliasControlsValidation: IAbstractFormArrayControlValidation[] = [];\n public aliasFields: string[] = [];\n\n /**\n * Builds an array of form controls for the given form array.\n *\n * @param formControlCount - An array of numbers representing the number of form controls to create.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - An array of field names.\n * @param controlValidation - An array of control validation objects.\n * @returns An array of form controls for the given form array.\n */\n private buildFormAliasControls(\n formControlCount: number[],\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): IAbstractFormArrayControls[] {\n // Directly map each index to a control\n return formControlCount.map((_element, index) =>\n this.addAliasControls(index, formArrayName, fieldNames, controlValidation),\n );\n }\n\n /**\n * Adds alias controls to the form array.\n *\n * @param index - The index of the form array.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - The names of the fields for the alias controls.\n * @param controlValidation - The validation rules for the alias controls.\n * @returns An object containing the form controls.\n */\n private addAliasControls(\n index: number,\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): { [key: string]: IAbstractFormArrayControl } {\n const formAliases = this.form.get(formArrayName) as FormArray;\n const formAliasesFormGroup = new FormGroup({});\n\n // Create the form controls...\n const controls = this.createAliasControls(fieldNames, index);\n\n // Add the controls to the form group...\n this.addControlsToFormGroup(formAliasesFormGroup, controlValidation, index);\n\n // Add the form group to the form array...\n formAliases.push(formAliasesFormGroup);\n\n // Return the form controls...\n return controls;\n }\n\n /**\n * Removes all form alias controls from a FormArray and clears any associated error messages.\n *\n * @param formArrayControls - An array of form array controls.\n * @param formArrayName - The name of the FormArray.\n * @param fieldNames - An array of field names associated with the form array controls.\n * @returns An empty array of form array controls.\n */\n private removeAllFormAliasControls(\n formArrayControls: IAbstractFormArrayControls[],\n formArrayName: string,\n fieldNames: string[],\n ): [] {\n const control = this.form.get(formArrayName) as FormArray;\n\n // Clear the error messages...\n [...formArrayControls].forEach((_element, index) => {\n this.removeFormAliasControlsErrors(index, formArrayControls, fieldNames);\n });\n\n // Reset the form array controls...\n control.clear();\n\n // Return en empty array of form array controls...\n return [];\n }\n\n /**\n * Creates a FormArray with the specified validators and controls.\n *\n * @param validators - An array of validators to apply to the FormArray.\n * @param controls - An optional array of initial FormControl instances to add to the FormArray.\n * @returns A new FormArray instance.\n */\n protected createFormAlias(validators: ValidatorFn[], controls: FormControl[] = []): FormArray {\n return new FormArray(controls, { validators: [...validators] });\n }\n\n /**\n * Removes a form alias control at the specified index from the given form array controls.\n *\n * @param index - The index of the form alias control to remove.\n * @param formArrayControls - The array of form array controls.\n * @returns The updated array of form array controls after removing the specified control.\n */\n protected removeFormAliasControl(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n ): IAbstractFormArrayControls[] {\n formArrayControls.splice(index, 1);\n return formArrayControls;\n }\n\n /**\n * Sets up the alias form controls based on the provided alias count array and form array name.\n * If there are any aliases, the alias controls will be re-populated.\n *\n * @param aliasCountArray - An array containing the count of aliases.\n * @param formArrayName - The name of the form array.\n */\n protected setupAliasFormControls(aliasCountArray: number[], formArrayName: string): void {\n // Re-populate the alias controls if there are any aliases\n if (aliasCountArray.length) {\n this.aliasControls = this.buildFormAliasControls(\n aliasCountArray,\n formArrayName,\n this.aliasFields,\n this.aliasControlsValidation,\n );\n }\n }\n\n /**\n * Removes the form alias controls errors for a specific index in a form array.\n *\n * @param index - The index of the form array control.\n * @param formArrayControls - An array of form array controls.\n * @param fieldNames - An array of field names to remove errors from.\n */\n protected removeFormAliasControlsErrors(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): void {\n const formArrayControl = formArrayControls[index];\n\n if (formArrayControl) {\n fieldNames.forEach((field) => {\n delete this.formControlErrorMessages?.[formArrayControl[field].controlName];\n });\n }\n }\n\n /**\n * Creates alias controls for the given fields and index.\n * @param fields - The list of fields for which alias controls need to be created.\n * @param index - The index value used to generate unique identifiers for the controls.\n * @returns An object containing the alias controls.\n */\n protected createAliasControls(fields: string[], index: number): { [key: string]: IAbstractFormArrayControl } {\n return fields.reduce(\n (controls, field) => ({\n ...controls,\n [field]: {\n inputId: `${field}_${index}`,\n inputName: `${field}_${index}`,\n controlName: `${field}_${index}`,\n },\n }),\n {},\n );\n }\n\n /**\n * Sets up the alias checkbox listener.\n *\n * @param formCheckboxName - The name of the checkbox control in the form.\n * @param formArrayName - The name of the form array control in the form.\n */\n protected setUpAliasCheckboxListener(formCheckboxName: string, formArrayName: string): void {\n // Ensure any existing subscription is cleared to avoid memory leaks\n this['ngUnsubscribe'].next();\n this['ngUnsubscribe'].complete();\n\n const addAliasControl = this.form.get(formCheckboxName);\n if (!addAliasControl) {\n return;\n }\n\n addAliasControl.valueChanges.pipe(takeUntil(this['ngUnsubscribe'])).subscribe((shouldAddAlias) => {\n this.aliasControls = shouldAddAlias\n ? this.buildFormAliasControls([0], formArrayName, this.aliasFields, this.aliasControlsValidation)\n : this.removeAllFormAliasControls(this.aliasControls, formArrayName, this.aliasFields);\n });\n }\n\n /**\n * Removes a form alias control from a form array and updates the list of form array controls.\n * @param index - The index of the form alias control to be removed.\n * @param formArrayName - The name of the form array.\n * @param formArrayControls - The list of form array controls.\n * @param fieldNames - The names of the fields associated with the form array controls.\n * @returns The updated list of form array controls after removing the specified control.\n */\n public removeFormAliasControls(\n index: number,\n formArrayName: string,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): IAbstractFormArrayControls[] {\n // Get the form array...\n const control = this.form.get(formArrayName) as FormArray;\n\n // Remove the form array control based on index\n control.removeAt(index);\n\n // Then remove the form array controls errors...\n this.removeFormAliasControlsErrors(index, formArrayControls, fieldNames);\n\n // Return the new list of form array controls...\n return this.removeFormAliasControl(index, formArrayControls);\n }\n\n /**\n * Adds an alias to the specified index of the form array.\n *\n * @param index - The index at which to add the alias.\n * @param formArrayName - The name of the form array.\n */\n public addAlias(index: number, formArrayName: string): void {\n this.aliasControls.push(\n this.addAliasControls(index, formArrayName, this.aliasFields, this.aliasControlsValidation),\n );\n }\n\n /**\n * Removes an alias from the form array.\n *\n * @param index - The index of the alias to remove.\n * @param formArrayName - The name of the form array.\n */\n public removeAlias(index: number, formArrayName: string): void {\n this.aliasControls = this.removeFormAliasControls(index, formArrayName, this.aliasControls, this.aliasFields);\n }\n\n public override ngOnInit(): void {\n super.ngOnInit();\n }\n\n public override ngOnDestroy(): void {\n this['ngUnsubscribe'].next();\n this['ngUnsubscribe'].complete();\n super.ngOnDestroy();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAcM,MAAgB,8BAA+B,SAAQ,yBAAyB,CAAA;IAC7E,aAAa,GAA0C,EAAE;IACzD,uBAAuB,GAA0C,EAAE;IACnE,WAAW,GAAa,EAAE;AAEjC;;;;;;;;AAQG;AACK,IAAA,sBAAsB,CAC5B,gBAA0B,EAC1B,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;;QAGxD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,KAC1C,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAC3E;;AAGH;;;;;;;;AAQG;AACK,IAAA,gBAAgB,CACtB,KAAa,EACb,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;QAExD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,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E;AAC5B,QAAA,IAAI,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE;QAChC,KAAK,CAAC,WAAW,EAAE;;wGAzPD,8BAA8B,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAA9B,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,8BAA8B,+FAFxC,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA;;4FAEQ,8BAA8B,EAAA,UAAA,EAAA,CAAA;kBAHnD,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,EAAE;AACb,iBAAA;;;ACbD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.mjs","sources":["../../../projects/opal-frontend-common/components/abstract/abstract-form-alias-base/abstract-form-alias-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-alias-base/hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.ts"],"sourcesContent":["import { FormArray, FormControl, FormGroup, ValidatorFn } from '@angular/forms';\nimport { takeUntil } from 'rxjs';\nimport { Component, OnDestroy, OnInit } from '@angular/core';\nimport { IAbstractFormAliasBaseAliasControls } from '@hmcts/opal-frontend-common/components/abstract/abstract-form-alias-base/interfaces';\nimport { AbstractFormBaseComponent } from '@hmcts/opal-frontend-common/components/abstract/abstract-form-base';\nimport {\n IAbstractFormArrayControlValidation,\n IAbstractFormArrayControls,\n IAbstractFormArrayControl,\n} from '@hmcts/opal-frontend-common/components/abstract/interfaces';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormAliasBaseComponent extends AbstractFormBaseComponent implements OnInit, OnDestroy {\n public aliasControls: IAbstractFormAliasBaseAliasControls[] = [];\n public aliasControlsValidation: IAbstractFormArrayControlValidation[] = [];\n public aliasFields: string[] = [];\n\n /**\n * Builds an array of form controls for the given form array.\n *\n * @param formControlCount - An array of numbers representing the number of form controls to create.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - An array of field names.\n * @param controlValidation - An array of control validation objects.\n * @returns An array of form controls for the given form array.\n */\n private buildFormAliasControls(\n formControlCount: number[],\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): IAbstractFormArrayControls[] {\n // Directly map each index to a control\n return formControlCount.map((_element, index) =>\n this.addAliasControls(index, formArrayName, fieldNames, controlValidation),\n );\n }\n\n /**\n * Adds alias controls to the form array.\n *\n * @param index - The index of the form array.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - The names of the fields for the alias controls.\n * @param controlValidation - The validation rules for the alias controls.\n * @returns An object containing the form controls.\n */\n private addAliasControls(\n index: number,\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): { [key: string]: IAbstractFormArrayControl } {\n const formAliases = this.form.get(formArrayName) as FormArray;\n const formAliasesFormGroup = new FormGroup({});\n\n // Create the form controls...\n const controls = this.createAliasControls(fieldNames, index);\n\n // Add the controls to the form group...\n this.addControlsToFormGroup(formAliasesFormGroup, controlValidation, index);\n\n // Add the form group to the form array...\n formAliases.push(formAliasesFormGroup);\n\n // Return the form controls...\n return controls;\n }\n\n /**\n * Removes all form alias controls from a FormArray and clears any associated error messages.\n *\n * @param formArrayControls - An array of form array controls.\n * @param formArrayName - The name of the FormArray.\n * @param fieldNames - An array of field names associated with the form array controls.\n * @returns An empty array of form array controls.\n */\n private removeAllFormAliasControls(\n formArrayControls: IAbstractFormArrayControls[],\n formArrayName: string,\n fieldNames: string[],\n ): [] {\n const control = this.form.get(formArrayName) as FormArray;\n\n // Clear the error messages...\n [...formArrayControls].forEach((_element, index) => {\n this.removeFormAliasControlsErrors(index, formArrayControls, fieldNames);\n });\n\n // Reset the form array controls...\n control.clear();\n\n // Return en empty array of form array controls...\n return [];\n }\n\n /**\n * Creates a FormArray with the specified validators and controls.\n *\n * @param validators - An array of validators to apply to the FormArray.\n * @param controls - An optional array of initial FormControl instances to add to the FormArray.\n * @returns A new FormArray instance.\n */\n protected createFormAlias(validators: ValidatorFn[], controls: FormControl[] = []): FormArray {\n return new FormArray(controls, { validators: [...validators] });\n }\n\n /**\n * Removes a form alias control at the specified index from the given form array controls.\n *\n * @param index - The index of the form alias control to remove.\n * @param formArrayControls - The array of form array controls.\n * @returns The updated array of form array controls after removing the specified control.\n */\n protected removeFormAliasControl(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n ): IAbstractFormArrayControls[] {\n formArrayControls.splice(index, 1);\n return formArrayControls;\n }\n\n /**\n * Sets up the alias form controls based on the provided alias count array and form array name.\n * If there are any aliases, the alias controls will be re-populated.\n *\n * @param aliasCountArray - An array containing the count of aliases.\n * @param formArrayName - The name of the form array.\n */\n protected setupAliasFormControls(aliasCountArray: number[], formArrayName: string): void {\n // Re-populate the alias controls if there are any aliases\n if (aliasCountArray.length) {\n this.aliasControls = this.buildFormAliasControls(\n aliasCountArray,\n formArrayName,\n this.aliasFields,\n this.aliasControlsValidation,\n );\n }\n }\n\n /**\n * Removes the form alias controls errors for a specific index in a form array.\n *\n * @param index - The index of the form array control.\n * @param formArrayControls - An array of form array controls.\n * @param fieldNames - An array of field names to remove errors from.\n */\n protected removeFormAliasControlsErrors(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): void {\n const formArrayControl = formArrayControls[index];\n\n if (formArrayControl) {\n fieldNames.forEach((field) => {\n delete this.formControlErrorMessages?.[formArrayControl[field].controlName];\n });\n }\n }\n\n /**\n * Creates alias controls for the given fields and index.\n * @param fields - The list of fields for which alias controls need to be created.\n * @param index - The index value used to generate unique identifiers for the controls.\n * @returns An object containing the alias controls.\n */\n protected createAliasControls(fields: string[], index: number): { [key: string]: IAbstractFormArrayControl } {\n return fields.reduce(\n (controls, field) => ({\n ...controls,\n [field]: {\n inputId: `${field}_${index}`,\n inputName: `${field}_${index}`,\n controlName: `${field}_${index}`,\n },\n }),\n {},\n );\n }\n\n /**\n * Sets up the alias checkbox listener.\n *\n * @param formCheckboxName - The name of the checkbox control in the form.\n * @param formArrayName - The name of the form array control in the form.\n */\n protected setUpAliasCheckboxListener(formCheckboxName: string, formArrayName: string): void {\n // Ensure any existing subscription is cleared to avoid memory leaks\n this['ngUnsubscribe'].next();\n this['ngUnsubscribe'].complete();\n\n const addAliasControl = this.form.get(formCheckboxName);\n if (!addAliasControl) {\n return;\n }\n\n addAliasControl.valueChanges.pipe(takeUntil(this['ngUnsubscribe'])).subscribe((shouldAddAlias) => {\n this.aliasControls = shouldAddAlias\n ? this.buildFormAliasControls([0], formArrayName, this.aliasFields, this.aliasControlsValidation)\n : this.removeAllFormAliasControls(this.aliasControls, formArrayName, this.aliasFields);\n });\n }\n\n /**\n * Removes a form alias control from a form array and updates the list of form array controls.\n * @param index - The index of the form alias control to be removed.\n * @param formArrayName - The name of the form array.\n * @param formArrayControls - The list of form array controls.\n * @param fieldNames - The names of the fields associated with the form array controls.\n * @returns The updated list of form array controls after removing the specified control.\n */\n public removeFormAliasControls(\n index: number,\n formArrayName: string,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): IAbstractFormArrayControls[] {\n // Get the form array...\n const control = this.form.get(formArrayName) as FormArray;\n\n // Remove the form array control based on index\n control.removeAt(index);\n\n // Then remove the form array controls errors...\n this.removeFormAliasControlsErrors(index, formArrayControls, fieldNames);\n\n // Return the new list of form array controls...\n return this.removeFormAliasControl(index, formArrayControls);\n }\n\n /**\n * Adds an alias to the specified index of the form array.\n *\n * @param index - The index at which to add the alias.\n * @param formArrayName - The name of the form array.\n */\n public addAlias(index: number, formArrayName: string): void {\n this.aliasControls.push(\n this.addAliasControls(index, formArrayName, this.aliasFields, this.aliasControlsValidation),\n );\n }\n\n /**\n * Removes an alias from the form array.\n *\n * @param index - The index of the alias to remove.\n * @param formArrayName - The name of the form array.\n */\n public removeAlias(index: number, formArrayName: string): void {\n this.aliasControls = this.removeFormAliasControls(index, formArrayName, this.aliasControls, this.aliasFields);\n }\n\n public override ngOnInit(): void {\n super.ngOnInit();\n }\n\n public override ngOnDestroy(): void {\n this['ngUnsubscribe'].next();\n this['ngUnsubscribe'].complete();\n super.ngOnDestroy();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAcM,MAAgB,8BAA+B,SAAQ,yBAAyB,CAAA;IAC7E,aAAa,GAA0C,EAAE;IACzD,uBAAuB,GAA0C,EAAE;IACnE,WAAW,GAAa,EAAE;AAEjC;;;;;;;;AAQG;AACK,IAAA,sBAAsB,CAC5B,gBAA0B,EAC1B,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;;QAGxD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,KAC1C,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAC3E;;AAGH;;;;;;;;AAQG;AACK,IAAA,gBAAgB,CACtB,KAAa,EACb,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;QAExD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAc;AAC7D,QAAA,MAAM,oBAAoB,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC;;QAG9C,MAAM,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,KAAK,CAAC;;QAG5D,IAAI,CAAC,sBAAsB,CAAC,oBAAoB,EAAE,iBAAiB,EAAE,KAAK,CAAC;;AAG3E,QAAA,WAAW,CAAC,IAAI,CAAC,oBAAoB,CAAC;;AAGtC,QAAA,OAAO,QAAQ;;AAGjB;;;;;;;AAOG;AACK,IAAA,0BAA0B,CAChC,iBAA+C,EAC/C,aAAqB,EACrB,UAAoB,EAA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CAAA;kBAHnD,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,EAAE;AACb,iBAAA;;;ACbD;;AAEG;;;;"}
|
package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-array-base.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmcts-opal-frontend-common-components-abstract-abstract-form-array-base.mjs","sources":["../../../projects/opal-frontend-common/components/abstract/abstract-form-array-base/abstract-form-array-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-array-base/hmcts-opal-frontend-common-components-abstract-abstract-form-array-base.ts"],"sourcesContent":["import { Component, OnDestroy, OnInit } from '@angular/core';\nimport { AbstractFormBaseComponent } from '@hmcts/opal-frontend-common/components/abstract/abstract-form-base';\nimport {\n IAbstractFormArrayControls,\n IAbstractFormArrayControlValidation,\n IAbstractFormArrayControl,\n} from '@hmcts/opal-frontend-common/components/abstract/interfaces';\nimport { AbstractControl, FormArray, FormControl, FormGroup, ValidatorFn } from '@angular/forms';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormArrayBaseComponent extends AbstractFormBaseComponent implements OnInit, OnDestroy {\n public formArrayControls: IAbstractFormArrayControls[] = [];\n public formArrayControlsValidation: IAbstractFormArrayControlValidation[] = [];\n public formArrayFields: string[] = [];\n\n /**\n * Builds an array of form controls for a form array.\n *\n * @param formControlCount - An array of numbers representing the number of form controls to create.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - An array of field names for the form controls.\n * @param controlValidation - An array of control validation configurations.\n * @returns An array of form controls for the form array.\n */\n private buildFormArrayControls(\n formControlCount: number[],\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): IAbstractFormArrayControls[] {\n // Directly map each index to a control\n return formControlCount.map((_element, index) =>\n this.addFormArrayControls(index, formArrayName, fieldNames, controlValidation),\n );\n }\n\n /**\n * Adds form array controls to the specified form array.\n *\n * @param index - The index at which the form array controls should be added.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - The names of the form controls to be created.\n * @param controlValidation - The validation rules for the form controls.\n * @returns An object containing the form controls that were added.\n */\n private addFormArrayControls(\n index: number,\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): { [key: string]: IAbstractFormArrayControl } {\n const formArray = this.form.get(formArrayName) as FormArray;\n const formArrayFormGroup = new FormGroup({});\n\n // Create the form controls...\n const controls = this.createFormArrayControls(fieldNames, index);\n\n // Add the controls to the form group...\n this.addControlsToFormGroup(formArrayFormGroup, controlValidation, index);\n\n // Add the form group to the form array...\n formArray.push(formArrayFormGroup);\n\n // Return the form controls...\n return controls;\n }\n\n /**\n * Creates a new instance of FormArray with the specified validators and controls.\n *\n * @param validators - An array of validator functions to be applied to the form array.\n * @param controls - An optional array of form controls to initialize the form array with.\n * @returns A new instance of FormArray.\n */\n protected createFormArray(validators: ValidatorFn[], controls: FormControl[] = []): FormArray {\n return new FormArray(controls, { validators: [...validators] });\n }\n\n /**\n * Sets up the form array form controls based on the provided parameters.\n *\n * @param formArrayCountArray - An array of numbers representing the count of form array controls.\n * @param formArrayName - The name of the form array.\n */\n protected setupFormArrayFormControls(formArrayCountArray: number[], formArrayName: string): void {\n if (formArrayCountArray.length) {\n this.formArrayControls = this.buildFormArrayControls(\n formArrayCountArray,\n formArrayName,\n this.formArrayFields,\n this.formArrayControlsValidation,\n );\n }\n }\n\n /**\n * Creates an object with form array controls based on the given fields and index.\n *\n * @param fields - An array of field names.\n * @param index - The index of the form array.\n * @returns An object with form array controls.\n */\n protected createFormArrayControls(fields: string[], index: number): { [key: string]: IAbstractFormArrayControl } {\n return fields.reduce(\n (controls, field) => ({\n ...controls,\n [field]: {\n inputId: `${field}_${index}`,\n inputName: `${field}_${index}`,\n controlName: `${field}_${index}`,\n },\n }),\n {},\n );\n }\n\n /**\n * Removes form array controls errors for a specific index.\n *\n * @param index - The index of the form array control.\n * @param formArrayControls - An array of form array controls.\n * @param fieldNames - An array of field names to remove errors from.\n */\n protected removeFormArrayControlsErrors(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): void {\n const formArrayControl = formArrayControls[index];\n\n if (formArrayControl) {\n fieldNames.forEach((field) => {\n delete this.formControlErrorMessages?.[formArrayControl[field].controlName];\n });\n }\n }\n\n /**\n * Adds controls to the form array at the specified index.\n *\n * @param index - The index at which the controls should be added.\n * @param formArrayName - The name of the form array.\n */\n public addControlsToFormArray(index: number, formArrayName: string): void {\n this.formArrayControls.push(\n this.addFormArrayControls(index, formArrayName, this.formArrayFields, this.formArrayControlsValidation),\n );\n }\n\n /**\n * Removes a form array control at the specified index from the given array of form array controls.\n *\n * @param index - The index of the form array control to be removed.\n * @param formArrayControls - The array of form array controls.\n * @returns The updated array of form array controls after removing the specified control.\n */\n protected removeFormArrayControl(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n ): IAbstractFormArrayControls[] {\n formArrayControls.splice(index, 1);\n return formArrayControls;\n }\n\n /**\n * Retrieves the value of a form control or returns a default value if the control is null or undefined.\n *\n * @param control - The form control to retrieve the value from.\n * @param defaultValue - The default value to return if the control is null or undefined.\n * @returns The value of the control if it exists, otherwise the default value.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected getControlValueOrDefault(control: AbstractControl | null, defaultValue: any): any {\n return control?.value ?? defaultValue;\n }\n\n /**\n * Removes a form array control at the specified index and updates the form array controls and errors.\n *\n * @param index - The index of the form array control to remove.\n * @param formArrayName - The name of the form array.\n * @param formArrayControls - The list of form array controls.\n * @param fieldNames - The names of the fields associated with the form array controls.\n * @returns The updated list of form array controls.\n */\n public removeFormArrayControls(\n index: number,\n formArrayName: string,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): IAbstractFormArrayControls[] {\n // Get the form array...\n const control = this.form.get(formArrayName) as FormArray;\n\n // Remove the form array control based on index\n control.removeAt(index);\n\n // Then remove the form array controls errors...\n this.removeFormArrayControlsErrors(index, formArrayControls, fieldNames);\n\n // Return the new list of form array controls...\n return this.removeFormArrayControl(index, formArrayControls);\n }\n\n /**\n * Removes controls from a form array at the specified index.\n *\n * @param index - The index at which to remove the controls.\n * @param formArrayName - The name of the form array.\n */\n public removeControlsFromFormArray(index: number, formArrayName: string): void {\n this.formArrayControls = this.removeFormArrayControls(\n index,\n formArrayName,\n this.formArrayControls,\n this.formArrayFields,\n );\n }\n\n /**\n * Removes a form array control from the specified form array.\n *\n * @param formArrayControl - The form array control to remove.\n * @param formArrayName - The name of the form array.\n */\n public removeFormArrayControlFromArray(formArrayControl: IAbstractFormArrayControls, formArrayName: string): void {\n const formArrayControlIndex = this.formArrayControls.findIndex((control) => control === formArrayControl);\n this.removeFormArrayControls(formArrayControlIndex, formArrayName, this.formArrayControls, this.formArrayFields);\n }\n\n /**\n * Retrieves the FormGroup at the specified index from a FormArray.\n *\n * @param index - The index of the FormGroup to retrieve.\n * @param formArrayName - The name of the FormArray.\n * @returns The FormGroup at the specified index.\n */\n public getFormArrayFormGroup(index: number, formArrayName: string): FormGroup {\n const formArray = this.form.get(formArrayName) as FormArray;\n return formArray.controls[index] as FormGroup;\n }\n\n /**\n * Retrieves the FormControl from a FormGroup within a FormArray at the specified index.\n *\n * @param formGroup - The FormGroup containing the FormControl.\n * @param controlName - The name of the FormControl.\n * @param index - The index of the FormArray.\n * @returns The FormControl at the specified index.\n */\n public getFormArrayFormGroupControl(formGroup: FormGroup, controlName: string, index: number): FormControl {\n return formGroup.controls[`${controlName}_${index}`] as FormControl;\n }\n\n /**\n * Adds validators to a specific form control within a form array group.\n *\n * @param formGroup - The form group containing the form array.\n * @param controlName - The name of the form control within the form array group.\n * @param index - The index of the form array group within the form array.\n * @param validators - An array of validator functions to be added to the form control.\n */\n public addFormArrayFormGroupControlValidators(formControl: FormControl, validators: ValidatorFn[]): void {\n formControl.setValidators(validators);\n formControl.updateValueAndValidity({ emitEvent: false });\n }\n\n /**\n * Removes validators from a specific form control within a form array group.\n * @param formGroup - The form group containing the form array.\n * @param controlName - The name of the form control within the form array group.\n * @param index - The index of the form array group within the form array.\n */\n public removeFormArrayFormGroupControlValidators(formControl: FormControl): void {\n formControl.clearValidators();\n formControl.setErrors(null);\n formControl.setValue(null, { emitEvent: false });\n formControl.updateValueAndValidity({ emitEvent: false });\n }\n\n /**\n * Reverses the form array data by appending the index to each key in the objects.\n *\n * @param data - An array of objects containing form data.\n * @returns An array of objects with keys modified to include their index in the original array.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public addIndexToFormArrayData(data: any[]): { [key: string]: any }[] {\n return data.map((item, index) =>\n Object.entries(item).reduce(\n (indexedObject, [key, value]) => {\n if (value !== undefined) {\n indexedObject[`${key}_${index}`] = value;\n }\n return indexedObject;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {} as { [key: string]: any },\n ),\n );\n }\n\n public override ngOnInit(): void {\n super.ngOnInit();\n }\n\n public override ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n super.ngOnDestroy();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAYM,MAAgB,8BAA+B,SAAQ,yBAAyB,CAAA;IAC7E,iBAAiB,GAAiC,EAAE;IACpD,2BAA2B,GAA0C,EAAE;IACvE,eAAe,GAAa,EAAE;AAErC;;;;;;;;AAQG;AACK,IAAA,sBAAsB,CAC5B,gBAA0B,EAC1B,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;;QAGxD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,KAC1C,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAC/E;;AAGH;;;;;;;;AAQG;AACK,IAAA,oBAAoB,CAC1B,KAAa,EACb,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;QAExD,MAAM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","sources":["../../../projects/opal-frontend-common/components/abstract/abstract-form-array-base/abstract-form-array-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-array-base/hmcts-opal-frontend-common-components-abstract-abstract-form-array-base.ts"],"sourcesContent":["import { Component, OnDestroy, OnInit } from '@angular/core';\nimport { AbstractFormBaseComponent } from '@hmcts/opal-frontend-common/components/abstract/abstract-form-base';\nimport {\n IAbstractFormArrayControls,\n IAbstractFormArrayControlValidation,\n IAbstractFormArrayControl,\n} from '@hmcts/opal-frontend-common/components/abstract/interfaces';\nimport { AbstractControl, FormArray, FormControl, FormGroup, ValidatorFn } from '@angular/forms';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormArrayBaseComponent extends AbstractFormBaseComponent implements OnInit, OnDestroy {\n public formArrayControls: IAbstractFormArrayControls[] = [];\n public formArrayControlsValidation: IAbstractFormArrayControlValidation[] = [];\n public formArrayFields: string[] = [];\n\n /**\n * Builds an array of form controls for a form array.\n *\n * @param formControlCount - An array of numbers representing the number of form controls to create.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - An array of field names for the form controls.\n * @param controlValidation - An array of control validation configurations.\n * @returns An array of form controls for the form array.\n */\n private buildFormArrayControls(\n formControlCount: number[],\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): IAbstractFormArrayControls[] {\n // Directly map each index to a control\n return formControlCount.map((_element, index) =>\n this.addFormArrayControls(index, formArrayName, fieldNames, controlValidation),\n );\n }\n\n /**\n * Adds form array controls to the specified form array.\n *\n * @param index - The index at which the form array controls should be added.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - The names of the form controls to be created.\n * @param controlValidation - The validation rules for the form controls.\n * @returns An object containing the form controls that were added.\n */\n private addFormArrayControls(\n index: number,\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): { [key: string]: IAbstractFormArrayControl } {\n const formArray = this.form.get(formArrayName) as FormArray;\n const formArrayFormGroup = new FormGroup({});\n\n // Create the form controls...\n const controls = this.createFormArrayControls(fieldNames, index);\n\n // Add the controls to the form group...\n this.addControlsToFormGroup(formArrayFormGroup, controlValidation, index);\n\n // Add the form group to the form array...\n formArray.push(formArrayFormGroup);\n\n // Return the form controls...\n return controls;\n }\n\n /**\n * Creates a new instance of FormArray with the specified validators and controls.\n *\n * @param validators - An array of validator functions to be applied to the form array.\n * @param controls - An optional array of form controls to initialize the form array with.\n * @returns A new instance of FormArray.\n */\n protected createFormArray(validators: ValidatorFn[], controls: FormControl[] = []): FormArray {\n return new FormArray(controls, { validators: [...validators] });\n }\n\n /**\n * Sets up the form array form controls based on the provided parameters.\n *\n * @param formArrayCountArray - An array of numbers representing the count of form array controls.\n * @param formArrayName - The name of the form array.\n */\n protected setupFormArrayFormControls(formArrayCountArray: number[], formArrayName: string): void {\n if (formArrayCountArray.length) {\n this.formArrayControls = this.buildFormArrayControls(\n formArrayCountArray,\n formArrayName,\n this.formArrayFields,\n this.formArrayControlsValidation,\n );\n }\n }\n\n /**\n * Creates an object with form array controls based on the given fields and index.\n *\n * @param fields - An array of field names.\n * @param index - The index of the form array.\n * @returns An object with form array controls.\n */\n protected createFormArrayControls(fields: string[], index: number): { [key: string]: IAbstractFormArrayControl } {\n return fields.reduce(\n (controls, field) => ({\n ...controls,\n [field]: {\n inputId: `${field}_${index}`,\n inputName: `${field}_${index}`,\n controlName: `${field}_${index}`,\n },\n }),\n {},\n );\n }\n\n /**\n * Removes form array controls errors for a specific index.\n *\n * @param index - The index of the form array control.\n * @param formArrayControls - An array of form array controls.\n * @param fieldNames - An array of field names to remove errors from.\n */\n protected removeFormArrayControlsErrors(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): void {\n const formArrayControl = formArrayControls[index];\n\n if (formArrayControl) {\n fieldNames.forEach((field) => {\n delete this.formControlErrorMessages?.[formArrayControl[field].controlName];\n });\n }\n }\n\n /**\n * Adds controls to the form array at the specified index.\n *\n * @param index - The index at which the controls should be added.\n * @param formArrayName - The name of the form array.\n */\n public addControlsToFormArray(index: number, formArrayName: string): void {\n this.formArrayControls.push(\n this.addFormArrayControls(index, formArrayName, this.formArrayFields, this.formArrayControlsValidation),\n );\n }\n\n /**\n * Removes a form array control at the specified index from the given array of form array controls.\n *\n * @param index - The index of the form array control to be removed.\n * @param formArrayControls - The array of form array controls.\n * @returns The updated array of form array controls after removing the specified control.\n */\n protected removeFormArrayControl(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n ): IAbstractFormArrayControls[] {\n formArrayControls.splice(index, 1);\n return formArrayControls;\n }\n\n /**\n * Retrieves the value of a form control or returns a default value if the control is null or undefined.\n *\n * @param control - The form control to retrieve the value from.\n * @param defaultValue - The default value to return if the control is null or undefined.\n * @returns The value of the control if it exists, otherwise the default value.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected getControlValueOrDefault(control: AbstractControl | null, defaultValue: any): any {\n return control?.value ?? defaultValue;\n }\n\n /**\n * Removes a form array control at the specified index and updates the form array controls and errors.\n *\n * @param index - The index of the form array control to remove.\n * @param formArrayName - The name of the form array.\n * @param formArrayControls - The list of form array controls.\n * @param fieldNames - The names of the fields associated with the form array controls.\n * @returns The updated list of form array controls.\n */\n public removeFormArrayControls(\n index: number,\n formArrayName: string,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): IAbstractFormArrayControls[] {\n // Get the form array...\n const control = this.form.get(formArrayName) as FormArray;\n\n // Remove the form array control based on index\n control.removeAt(index);\n\n // Then remove the form array controls errors...\n this.removeFormArrayControlsErrors(index, formArrayControls, fieldNames);\n\n // Return the new list of form array controls...\n return this.removeFormArrayControl(index, formArrayControls);\n }\n\n /**\n * Removes controls from a form array at the specified index.\n *\n * @param index - The index at which to remove the controls.\n * @param formArrayName - The name of the form array.\n */\n public removeControlsFromFormArray(index: number, formArrayName: string): void {\n this.formArrayControls = this.removeFormArrayControls(\n index,\n formArrayName,\n this.formArrayControls,\n this.formArrayFields,\n );\n }\n\n /**\n * Removes a form array control from the specified form array.\n *\n * @param formArrayControl - The form array control to remove.\n * @param formArrayName - The name of the form array.\n */\n public removeFormArrayControlFromArray(formArrayControl: IAbstractFormArrayControls, formArrayName: string): void {\n const formArrayControlIndex = this.formArrayControls.findIndex((control) => control === formArrayControl);\n this.removeFormArrayControls(formArrayControlIndex, formArrayName, this.formArrayControls, this.formArrayFields);\n }\n\n /**\n * Retrieves the FormGroup at the specified index from a FormArray.\n *\n * @param index - The index of the FormGroup to retrieve.\n * @param formArrayName - The name of the FormArray.\n * @returns The FormGroup at the specified index.\n */\n public getFormArrayFormGroup(index: number, formArrayName: string): FormGroup {\n const formArray = this.form.get(formArrayName) as FormArray;\n return formArray.controls[index] as FormGroup;\n }\n\n /**\n * Retrieves the FormControl from a FormGroup within a FormArray at the specified index.\n *\n * @param formGroup - The FormGroup containing the FormControl.\n * @param controlName - The name of the FormControl.\n * @param index - The index of the FormArray.\n * @returns The FormControl at the specified index.\n */\n public getFormArrayFormGroupControl(formGroup: FormGroup, controlName: string, index: number): FormControl {\n return formGroup.controls[`${controlName}_${index}`] as FormControl;\n }\n\n /**\n * Adds validators to a specific form control within a form array group.\n *\n * @param formGroup - The form group containing the form array.\n * @param controlName - The name of the form control within the form array group.\n * @param index - The index of the form array group within the form array.\n * @param validators - An array of validator functions to be added to the form control.\n */\n public addFormArrayFormGroupControlValidators(formControl: FormControl, validators: ValidatorFn[]): void {\n formControl.setValidators(validators);\n formControl.updateValueAndValidity({ emitEvent: false });\n }\n\n /**\n * Removes validators from a specific form control within a form array group.\n * @param formGroup - The form group containing the form array.\n * @param controlName - The name of the form control within the form array group.\n * @param index - The index of the form array group within the form array.\n */\n public removeFormArrayFormGroupControlValidators(formControl: FormControl): void {\n formControl.clearValidators();\n formControl.setErrors(null);\n formControl.setValue(null, { emitEvent: false });\n formControl.updateValueAndValidity({ emitEvent: false });\n }\n\n /**\n * Reverses the form array data by appending the index to each key in the objects.\n *\n * @param data - An array of objects containing form data.\n * @returns An array of objects with keys modified to include their index in the original array.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public addIndexToFormArrayData(data: any[]): { [key: string]: any }[] {\n return data.map((item, index) =>\n Object.entries(item).reduce(\n (indexedObject, [key, value]) => {\n if (value !== undefined) {\n indexedObject[`${key}_${index}`] = value;\n }\n return indexedObject;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {} as { [key: string]: any },\n ),\n );\n }\n\n public override ngOnInit(): void {\n super.ngOnInit();\n }\n\n public override ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n super.ngOnDestroy();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAYM,MAAgB,8BAA+B,SAAQ,yBAAyB,CAAA;IAC7E,iBAAiB,GAAiC,EAAE;IACpD,2BAA2B,GAA0C,EAAE;IACvE,eAAe,GAAa,EAAE;AAErC;;;;;;;;AAQG;AACK,IAAA,sBAAsB,CAC5B,gBAA0B,EAC1B,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;;QAGxD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,KAC1C,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAC/E;;AAGH;;;;;;;;AAQG;AACK,IAAA,oBAAoB,CAC1B,KAAa,EACb,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;QAExD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAc;AAC3D,QAAA,MAAM,kBAAkB,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC;;QAG5C,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,UAAU,EAAE,KAAK,CAAC;;QAGhE,IAAI,CAAC,sBAAsB,CAAC,kBAAkB,EAAE,iBAAiB,E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AAI,CAAC,CAAC,MAAM,CACzB,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AAC9B,YAAA,IAAI,KAAK,KAAK,SAAS,EAAE;gBACvB,aAAa,CAAC,GAAG,GAAG,CAAA,CAAA,EAAI,KAAK,CAAA,CAAE,CAAC,GAAG,KAAK;;AAE1C,YAAA,OAAO,aAAa;SACrB;;QAED,EAA4B,CAC7B,CACF;;IAGa,QAAQ,GAAA;QACtB,KAAK,CAAC,QAAQ,EAAE;;IAGF,WAAW,GAAA;AACzB,QAAA,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE;AACzB,QAAA,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE;QAC7B,KAAK,CAAC,WAAW,EAAE;;wGA3SD,8BAA8B,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAA9B,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,8BAA8B,+FAFxC,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA;;4FAEQ,8BAA8B,EAAA,UAAA,EAAA,CAAA;kBAHnD,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,EAAE;AACb,iBAAA;;;ACXD;;AAEG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base.mjs","sources":["../../../projects/opal-frontend-common/components/abstract/abstract-form-array-removal-base/abstract-form-array-removal-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-array-removal-base/hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base.ts"],"sourcesContent":["import { FormArray, FormGroup } from '@angular/forms';\nimport { Component, inject } from '@angular/core';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { IAbstractFormArrayRemovalBaseControlValue } from './interfaces/abstract-form-array-removal-base-control-value.interface';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormArrayRemovalComponent {\n private readonly router = inject(Router);\n private readonly activatedRoute = inject(ActivatedRoute);\n\n protected getFormArrayControlValue(\n formArray: FormArray,\n controlName: string,\n rowIndex: number,\n defaultValue: IAbstractFormArrayRemovalBaseControlValue[keyof IAbstractFormArrayRemovalBaseControlValue],\n ): IAbstractFormArrayRemovalBaseControlValue[keyof IAbstractFormArrayRemovalBaseControlValue] {\n const value = formArray.controls[rowIndex]?.get(controlName)?.value;\n\n if (typeof value === 'string' && !isNaN(Number(value))) {\n return Number(value);\n }\n\n return value ?? defaultValue;\n }\n\n /**\n * Removes a control from the given form array at the specified index and renumbers the remaining controls.\n *\n * @param formArray - The form array from which to remove the control.\n * @param removeIndex - The index of the control to remove.\n * @param fieldNames - The names of the fields associated with the controls.\n * @param dynamicFieldPrefix - The prefix used for dynamically generated field names.\n */\n protected removeControlAndRenumber(\n formArray: FormArray,\n removeIndex: number,\n fieldNames: string[],\n dynamicFieldPrefix: string,\n ): void {\n formArray.removeAt(removeIndex);\n this.renumberControls(formArray, removeIndex, fieldNames, dynamicFieldPrefix);\n }\n\n /**\n * Renumber the controls in a FormArray starting from a specific index.\n * This method updates the control keys of each FormGroup within the FormArray.\n *\n * @param formArray - The FormArray to renumber the controls for.\n * @param startIndex - The index to start renumbering the controls from.\n * @param fieldNames - The names of the fields in the FormGroup.\n * @param dynamicFieldPrefix - The prefix to use for dynamic field names.\n */\n protected renumberControls(\n formArray: FormArray,\n startIndex: number,\n fieldNames: string[],\n dynamicFieldPrefix: string,\n ): void {\n const formGroups = formArray.controls.slice(startIndex);\n for (const [index, formGroup] of formGroups.entries()) {\n this.updateControlKeys(formGroup as FormGroup, index + startIndex, fieldNames, dynamicFieldPrefix);\n }\n }\n\n /**\n * Updates the control keys in a form group based on the provided parameters.\n * @param formGroup - The form group to update.\n * @param index - The index of the form group within an array.\n * @param fieldNames - An array of field names to update.\n * @param dynamicFieldPrefix - The prefix to use for dynamic field keys.\n */\n protected updateControlKeys(\n formGroup: FormGroup,\n index: number,\n fieldNames: string[],\n dynamicFieldPrefix: string,\n ): void {\n fieldNames.forEach((field) => {\n const currentKey = `${dynamicFieldPrefix}_${field}_${index + 1}`;\n const newKey = `${dynamicFieldPrefix}_${field}_${index}`;\n\n // Retrieve the current control, if it exists\n const control = formGroup.get(currentKey);\n\n if (control) {\n // Remove the old control first, then add it with the new key\n formGroup.removeControl(currentKey);\n\n // Add the control with the updated key\n formGroup.addControl(newKey, control);\n }\n });\n }\n\n /**\n * Handles route with the supplied route\n *\n * @param route string of route\n * @param nonRelative boolean indicating if route is relative to the parent\n */\n public handleRoute(route: string, nonRelative: boolean = false, event?: Event): void {\n if (event) {\n event.preventDefault();\n }\n if (nonRelative) {\n this.router.navigate([route]);\n } else {\n this.router.navigate([route], { relativeTo: this.activatedRoute.parent });\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAQsB,iCAAiC,CAAA;AACpC,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACvB,IAAA,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;AAE9C,IAAA,wBAAwB,CAChC,SAAoB,EACpB,WAAmB,EACnB,QAAgB,EAChB,YAAwG,EAAA;AAExG,QAAA,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,EAAE,KAAK;AAEnE,QAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;AACtD,YAAA,OAAO,MAAM,CAAC,KAAK,CAAC;;QAGtB,OAAO,KAAK,IAAI,YAAY;;AAG9B;;;;;;;AAOG;AACO,IAAA,wBAAwB,CAChC,SAAoB,EACpB,WAAmB,EACnB,UAAoB,EACpB,kBAA0B,EAAA;AAE1B,QAAA,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC/B,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,CAAC;;AAG/E;;;;;;;;AAQG;AACO,IAAA,gBAAgB,CACxB,SAAoB,EACpB,UAAkB,EAClB,UAAoB,EACpB,kBAA0B,EAAA;QAE1B,MAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;AACvD,QAAA,KAAK,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE;AACrD,YAAA,IAAI,CAAC,iBAAiB,CAAC,SAAsB,EAAE,KAAK,GAAG,UAAU,EAAE,UAAU,EAAE,kBAAkB,CAAC;;;AAItG;;;;;;AAMG;AACO,IAAA,iBAAiB,CACzB,SAAoB,EACpB,KAAa,EACb,UAAoB,EACpB,kBAA0B,EAAA;AAE1B,QAAA,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,KAAI;YAC3B,MAAM,UAAU,GAAG,CAAA,EAAG,kBAAkB,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA,EAAI,KAAK,GAAG,CAAC,CAAA,CAAE;YAChE,MAAM,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base.mjs","sources":["../../../projects/opal-frontend-common/components/abstract/abstract-form-array-removal-base/abstract-form-array-removal-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-array-removal-base/hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base.ts"],"sourcesContent":["import { FormArray, FormGroup } from '@angular/forms';\nimport { Component, inject } from '@angular/core';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { IAbstractFormArrayRemovalBaseControlValue } from './interfaces/abstract-form-array-removal-base-control-value.interface';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormArrayRemovalComponent {\n private readonly router = inject(Router);\n private readonly activatedRoute = inject(ActivatedRoute);\n\n protected getFormArrayControlValue(\n formArray: FormArray,\n controlName: string,\n rowIndex: number,\n defaultValue: IAbstractFormArrayRemovalBaseControlValue[keyof IAbstractFormArrayRemovalBaseControlValue],\n ): IAbstractFormArrayRemovalBaseControlValue[keyof IAbstractFormArrayRemovalBaseControlValue] {\n const value = formArray.controls[rowIndex]?.get(controlName)?.value;\n\n if (typeof value === 'string' && !isNaN(Number(value))) {\n return Number(value);\n }\n\n return value ?? defaultValue;\n }\n\n /**\n * Removes a control from the given form array at the specified index and renumbers the remaining controls.\n *\n * @param formArray - The form array from which to remove the control.\n * @param removeIndex - The index of the control to remove.\n * @param fieldNames - The names of the fields associated with the controls.\n * @param dynamicFieldPrefix - The prefix used for dynamically generated field names.\n */\n protected removeControlAndRenumber(\n formArray: FormArray,\n removeIndex: number,\n fieldNames: string[],\n dynamicFieldPrefix: string,\n ): void {\n formArray.removeAt(removeIndex);\n this.renumberControls(formArray, removeIndex, fieldNames, dynamicFieldPrefix);\n }\n\n /**\n * Renumber the controls in a FormArray starting from a specific index.\n * This method updates the control keys of each FormGroup within the FormArray.\n *\n * @param formArray - The FormArray to renumber the controls for.\n * @param startIndex - The index to start renumbering the controls from.\n * @param fieldNames - The names of the fields in the FormGroup.\n * @param dynamicFieldPrefix - The prefix to use for dynamic field names.\n */\n protected renumberControls(\n formArray: FormArray,\n startIndex: number,\n fieldNames: string[],\n dynamicFieldPrefix: string,\n ): void {\n const formGroups = formArray.controls.slice(startIndex);\n for (const [index, formGroup] of formGroups.entries()) {\n this.updateControlKeys(formGroup as FormGroup, index + startIndex, fieldNames, dynamicFieldPrefix);\n }\n }\n\n /**\n * Updates the control keys in a form group based on the provided parameters.\n * @param formGroup - The form group to update.\n * @param index - The index of the form group within an array.\n * @param fieldNames - An array of field names to update.\n * @param dynamicFieldPrefix - The prefix to use for dynamic field keys.\n */\n protected updateControlKeys(\n formGroup: FormGroup,\n index: number,\n fieldNames: string[],\n dynamicFieldPrefix: string,\n ): void {\n fieldNames.forEach((field) => {\n const currentKey = `${dynamicFieldPrefix}_${field}_${index + 1}`;\n const newKey = `${dynamicFieldPrefix}_${field}_${index}`;\n\n // Retrieve the current control, if it exists\n const control = formGroup.get(currentKey);\n\n if (control) {\n // Remove the old control first, then add it with the new key\n formGroup.removeControl(currentKey);\n\n // Add the control with the updated key\n formGroup.addControl(newKey, control);\n }\n });\n }\n\n /**\n * Handles route with the supplied route\n *\n * @param route string of route\n * @param nonRelative boolean indicating if route is relative to the parent\n */\n public handleRoute(route: string, nonRelative: boolean = false, event?: Event): void {\n if (event) {\n event.preventDefault();\n }\n if (nonRelative) {\n this.router.navigate([route]);\n } else {\n this.router.navigate([route], { relativeTo: this.activatedRoute.parent });\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAQsB,iCAAiC,CAAA;AACpC,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACvB,IAAA,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;AAE9C,IAAA,wBAAwB,CAChC,SAAoB,EACpB,WAAmB,EACnB,QAAgB,EAChB,YAAwG,EAAA;AAExG,QAAA,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,EAAE,KAAK;AAEnE,QAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;AACtD,YAAA,OAAO,MAAM,CAAC,KAAK,CAAC;;QAGtB,OAAO,KAAK,IAAI,YAAY;;AAG9B;;;;;;;AAOG;AACO,IAAA,wBAAwB,CAChC,SAAoB,EACpB,WAAmB,EACnB,UAAoB,EACpB,kBAA0B,EAAA;AAE1B,QAAA,SAAS,CAAC,QAAQ,CAAC,WAAW,C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MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC;;aACxB;AACL,YAAA,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;;;wGArGzD,iCAAiC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAjC,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,iCAAiC,wEAF3C,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA;;4FAEQ,iCAAiC,EAAA,UAAA,EAAA,CAAA;kBAHtD,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,EAAE;AACb,iBAAA;;;ACPD;;AAEG;;;;"}
|
|
@@ -311,14 +311,17 @@ class AbstractFormBaseComponent {
|
|
|
311
311
|
return this.form.dirty && !this.formSubmitted;
|
|
312
312
|
}
|
|
313
313
|
/**
|
|
314
|
-
* Sets the value of a
|
|
314
|
+
* Sets the value of a form control specified by its path and marks it as touched.
|
|
315
315
|
*
|
|
316
|
-
* @param
|
|
317
|
-
* @param
|
|
316
|
+
* @param value - The value to set for the form control.
|
|
317
|
+
* @param controlPath - The dot-delimited path to the form control within the form group.
|
|
318
318
|
*/
|
|
319
|
-
setInputValue(value,
|
|
320
|
-
this.form.
|
|
321
|
-
|
|
319
|
+
setInputValue(value, controlPath) {
|
|
320
|
+
const control = this.form.get(controlPath);
|
|
321
|
+
if (control) {
|
|
322
|
+
control.patchValue(value);
|
|
323
|
+
control.markAsTouched();
|
|
324
|
+
}
|
|
322
325
|
}
|
|
323
326
|
/**
|
|
324
327
|
* Handles the form errors for the date input fields.
|
|
@@ -422,17 +425,17 @@ class AbstractFormBaseComponent {
|
|
|
422
425
|
* @param route string of route
|
|
423
426
|
* @param nonRelative boolean indicating if route is relative to the parent
|
|
424
427
|
*/
|
|
425
|
-
|
|
428
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
429
|
+
handleRoute(route, nonRelative = false, event, routeData) {
|
|
426
430
|
if (event) {
|
|
427
431
|
event.preventDefault();
|
|
428
432
|
}
|
|
429
433
|
this.unsavedChanges.emit(this.hasUnsavedChanges());
|
|
430
|
-
|
|
431
|
-
this.
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
434
|
+
const navigationExtras = {
|
|
435
|
+
...(nonRelative ? {} : { relativeTo: this.activatedRoute.parent }),
|
|
436
|
+
...(routeData !== undefined ? { state: routeData } : {}),
|
|
437
|
+
};
|
|
438
|
+
this.router.navigate([route], navigationExtras);
|
|
436
439
|
}
|
|
437
440
|
/**
|
|
438
441
|
* Handles the form submission event.
|