Skip to content

Commit d5f4d7d

Browse files
refactor: Action buttons to use in CancelAlert and minor refactors (#377)
Co-authored-by: tumms2021389 <[email protected]>
1 parent 0b5bcda commit d5f4d7d

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

packages/angular-sdk-components/src/lib/_components/field/cancel-alert/cancel-alert.component.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ <h3>{{ localizedVal('Discard unsaved changes?', localeCategory) }}</h3>
44
<div>
55
<p>{{ localizedVal('You have unsaved changes. You can discard them or go back to keep working.', localeCategory) }}</p>
66
</div>
7-
<mat-grid-list cols="2" rowHeight="6.25rem">
8-
<mat-grid-tile>
9-
<button mat-raised-button color="secondary" (click)="buttonClick('continue')">{{ localizedVal('Go back', localeCategory) }}</button>
10-
</mat-grid-tile>
11-
<mat-grid-tile>
12-
<button mat-raised-button color="primary" (click)="buttonClick('discard')">{{ localizedVal('Discard', localeCategory) }}</button>
13-
</mat-grid-tile>
14-
</mat-grid-list>
7+
<component-mapper
8+
name="ActionButtons"
9+
[props]="{ arMainButtons$: [discardButton], arSecondaryButtons$: [goBackButton] }"
10+
[parent]="this"
11+
[outputEvents]="{ actionButtonClick: buttonClick }"
12+
></component-mapper>
1513
</div>
1614
</div>

packages/angular-sdk-components/src/lib/_components/field/cancel-alert/cancel-alert.component.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
}
1414

1515
.psdk-cancel-alert-top {
16-
display: table;
1716
margin: auto;
1817
min-width: 550px;
1918
border: 1px solid var(--app-inverse-form-color);

packages/angular-sdk-components/src/lib/_components/field/cancel-alert/cancel-alert.component.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import { Component, Input, Output, EventEmitter, OnChanges } from '@angular/core';
1+
import { Component, Input, Output, EventEmitter, OnChanges, forwardRef } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { MatButtonModule } from '@angular/material/button';
44
import { MatGridListModule } from '@angular/material/grid-list';
55
import { ProgressSpinnerService } from '../../../_messages/progress-spinner.service';
6+
import { ComponentMapperComponent } from 'packages/angular-sdk-components/src/public-api';
67

78
@Component({
89
selector: 'app-cancel-alert',
910
templateUrl: './cancel-alert.component.html',
1011
styleUrls: ['./cancel-alert.component.scss'],
11-
imports: [CommonModule, MatGridListModule, MatButtonModule]
12+
imports: [CommonModule, MatGridListModule, MatButtonModule, forwardRef(() => ComponentMapperComponent)]
1213
})
1314
export class CancelAlertComponent implements OnChanges {
1415
@Input() pConn$: typeof PConnect;
@@ -18,6 +19,8 @@ export class CancelAlertComponent implements OnChanges {
1819
itemKey: string;
1920
localizedVal: Function;
2021
localeCategory = 'ModalContainer';
22+
discardButton: any;
23+
goBackButton: any;
2124

2225
constructor(private psService: ProgressSpinnerService) {}
2326
ngOnChanges() {
@@ -26,6 +29,7 @@ export class CancelAlertComponent implements OnChanges {
2629
const contextName = this.pConn$.getContextName();
2730
this.localizedVal = PCore.getLocaleUtils().getLocaleValue;
2831
this.itemKey = contextName;
32+
this.createCancelAlertButtons();
2933
}
3034
}
3135

@@ -43,11 +47,24 @@ export class CancelAlertComponent implements OnChanges {
4347
alert(sMessage);
4448
}
4549

46-
buttonClick(sAction) {
50+
createCancelAlertButtons() {
51+
this.discardButton = {
52+
actionID: 'discard',
53+
jsAction: 'discard',
54+
name: this.pConn$.getLocalizedValue('Discard', '', '')
55+
};
56+
this.goBackButton = {
57+
actionID: 'continue',
58+
jsAction: 'continue',
59+
name: this.pConn$.getLocalizedValue('Go back', '', '')
60+
};
61+
}
62+
63+
buttonClick({ action }) {
4764
const actionsAPI = this.pConn$.getActionsApi();
4865
this.localizedVal = PCore.getLocaleUtils().getLocaleValue;
4966

50-
switch (sAction) {
67+
switch (action) {
5168
case 'continue':
5269
this.dismissAlertOnly();
5370
break;

packages/angular-sdk-components/src/lib/_components/field/check-box/check-box.component.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
transform: translateY(-1.28125em) scale(0.75) perspective(100px) translateZ(0.001px);
1212
-ms-transform: translateY(-1.28125em) scale(0.75);
1313
width: 133.33333%;
14-
color: rgba(0, 0, 0, 0.6);
1514
}
1615

1716
.psdk-data-readonly {

projects/angular-test-app/tests/e2e/MediaCo/portal.spec.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,7 @@ test.describe('E2E test', () => {
1515

1616
await common.verifyHomePage(page);
1717

18-
const navbar = page.locator('app-navbar');
19-
await navbar.locator('div[class="psdk-appshell-nav"]').hover();
20-
21-
const createCase = page.locator('mat-list-item[id="create-case-button"]');
22-
await createCase.click();
23-
24-
const newServiceCase = await page.locator('mat-list-item[id="case-list-item"] > span:has-text("New Service")');
25-
await newServiceCase.click();
18+
await common.createCase('New Service', page);
2619

2720
const firstNameInput = page.locator('input[data-test-id="BC910F8BDF70F29374F496F05BE0330C"]');
2821
await firstNameInput.click();

0 commit comments

Comments
 (0)