forked from thoth-tech/doubtfire-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate the confirmation-model component
- Loading branch information
1 parent
5e81bc1
commit 6c4434a
Showing
8 changed files
with
69 additions
and
42 deletions.
There are no files selected for viewing
35 changes: 0 additions & 35 deletions
35
src/app/common/modals/confirmation-modal/confirmation-modal.coffee
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...onfirmation-modal/confirmation-modal.scss → ...n-modal/confirmation-modal.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.confirmation-modal .modal-body { | ||
font-size: 1.5em; | ||
} | ||
font-size: 1.5em; | ||
} |
41 changes: 41 additions & 0 deletions
41
src/app/common/modals/confirmation-modal/confirmation-modal.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Component, OnInit, Input, Inject} from '@angular/core'; | ||
import { alertService } from 'src/app/ajs-upgraded-providers'; | ||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; | ||
|
||
@Component({ | ||
selector: 'confirmation-modal', | ||
templateUrl: './confirmation-modal.component.html', | ||
styleUrls: ['./confirmation-modal.component.scss'], | ||
}) | ||
export class ConfirmationModalComponent implements OnInit { | ||
@Input() title: string; | ||
@Input() message: string; | ||
@Input() action: () => void; | ||
|
||
constructor( | ||
@Inject(alertService) private alertService: any, | ||
public dialogRef: MatDialogRef<ConfirmationModalComponent>, | ||
@Inject(MAT_DIALOG_DATA) public data: any, | ||
) {} | ||
|
||
ngOnInit(): void { | ||
console.log('confirmation-model ngOnInit()'); | ||
} | ||
|
||
public confirmAction() { | ||
console.log('confirmAction'); | ||
if (typeof this.action === 'function') { | ||
this.action(); | ||
} else { | ||
this.alertService.add("danger", `${this.title} action failed`, 3000); | ||
} | ||
/** note - page reload after closing **/ | ||
this.dialogRef.close(); | ||
} | ||
|
||
public cancelAction() { | ||
console.log('cancelAction'); | ||
this.alertService.add("info", `${this.title} action cancelled`, 3000); | ||
this.dialogRef.close(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/app/common/modals/confirmation-modal/confirmation-modal.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog'; | ||
import { ConfirmationModalComponent } from './confirmation-modal.component'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class ConfirmationModalService { | ||
constructor(public dialog: MatDialog) {} | ||
|
||
public show(title: string, message: string, action?: any) { | ||
let dialogRef: MatDialogRef<ConfirmationModalComponent, any>; | ||
dialogRef = this.dialog.open(ConfirmationModalComponent, {position: {top: '2.5%'}}); | ||
dialogRef.updateSize("42.5%", ""); | ||
dialogRef.componentInstance.title = title; | ||
dialogRef.componentInstance.message = message; | ||
dialogRef.componentInstance.action = action; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
angular.module("doubtfire.common.modals", [ | ||
'doubtfire.common.modals.csv-result-modal' | ||
'doubtfire.common.modals.confirmation-modal' | ||
'doubtfire.common.modals.comments-modal' | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters