Skip to content

Commit

Permalink
Merge branch 'PIDP-1094-User-feedback-button-on-PIDP' of https://gith…
Browse files Browse the repository at this point in the history
…ub.com/bcgov/moh-pidp into PIDP-1094-User-feedback-button-on-PIDP
  • Loading branch information
kakarlavinodkumar committed Jan 8, 2025
2 parents 08248ea + dd4ed7e commit bdbc759
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { DialogBcproviderCreateComponent } from '../components/dialog-bcprovider-create.component';
import { DialogBcproviderEditComponent } from '../components/dialog-bcprovider-edit.component';
import { FeedbackSendComponent } from '../components/feedback-send.component';

export type SuccessDialogComponentClass =
| DialogBcproviderCreateComponent
| DialogBcproviderEditComponent
| FeedbackSendComponent;
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { TestBed } from '@angular/core/testing';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';

import { NavigationService } from '@pidp/presentation';
import { provideAutoSpy } from 'jest-auto-spies';

import { SuccessDialogComponent } from './success-dialog.component';
Expand All @@ -12,11 +11,7 @@ describe('SuccessDialogComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule],
providers: [
SuccessDialogComponent,
provideAutoSpy(NavigationService),
provideAutoSpy(MatDialog),
],
providers: [SuccessDialogComponent, provideAutoSpy(MatDialog)],
}).compileComponents();

component = TestBed.inject(SuccessDialogComponent);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NgClass, NgIf } from '@angular/common';
import {
Component,
Input,
Expand All @@ -7,17 +8,15 @@ import {
ViewContainerRef,
} from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { NgClass, NgIf } from '@angular/common';

import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { faCircleCheck, faXmark } from '@fortawesome/free-solid-svg-icons';
import { NavigationService } from '@pidp/presentation';

import { InjectViewportCssClassDirective } from '@bcgov/shared/ui';

import { SuccessDialogComponentClass } from './classes/success-dialog-component.class';
import { DialogBcproviderCreateComponent } from './components/dialog-bcprovider-create.component';
import { DialogBcproviderEditComponent } from './components/dialog-bcprovider-edit.component';
import { FeedbackSendComponent } from './components/feedback-send.component';

@Component({
selector: 'app-success-dialog',
Expand All @@ -33,37 +32,34 @@ export class SuccessDialogComponent implements OnInit {

@Input() public username!: string;
@Input() public title!: string;
@Input() public componentType!: Type<
DialogBcproviderCreateComponent | DialogBcproviderEditComponent | FeedbackSendComponent
>;
@Input() public componentType!: Type<SuccessDialogComponentClass>;

@ViewChild('dialogParagraphHost', { static: true, read: ViewContainerRef })
public dialogParagraphHost!: ViewContainerRef;

public constructor(
public dialog: MatDialog,
private navigationService: NavigationService,
) {}
public constructor(public dialog: MatDialog) {}

public onSuccessDialogClose(): void {
this.dialog.closeAll();
}

public ngOnInit(): void {
this.loadDialogParagraphComponent(this.componentType);
if(this.componentType instanceof DialogBcproviderCreateComponent || this.componentType instanceof DialogBcproviderEditComponent) {
if (
this.componentType instanceof DialogBcproviderCreateComponent ||
this.componentType instanceof DialogBcproviderEditComponent
) {
this.showHeader = true;
}
}

private loadDialogParagraphComponent(
componentType: Type<
DialogBcproviderCreateComponent | DialogBcproviderEditComponent | FeedbackSendComponent
>,
componentType: Type<SuccessDialogComponentClass>,
): void {
const componentRef = this.dialogParagraphHost.createComponent<
DialogBcproviderCreateComponent | DialogBcproviderEditComponent | FeedbackSendComponent
>(componentType);
const componentRef =
this.dialogParagraphHost.createComponent<SuccessDialogComponentClass>(
componentType,
);
componentRef.instance.username = this.username;
}
}

0 comments on commit bdbc759

Please sign in to comment.