forked from doubtfire-lms/doubtfire-web
-
Notifications
You must be signed in to change notification settings - Fork 82
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 comments-modal - get variables commentResourceU…
…rl and commentType
- Loading branch information
1 parent
a4da9ff
commit 53f10d6
Showing
4 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
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,10 @@ | ||
<div class="modal-comment"> | ||
<div class="modal-body"> | ||
<div *ngIf="commentType == 'image'"> | ||
<img class="image-comment" [src]="commentResourceUrl" /> | ||
</div> | ||
<div *ngIf="commentType == 'pdf'"> | ||
<iframe class="pdf-comment" [src]="commentResourceUrl" type="application/pdf"></iframe> | ||
</div> | ||
</div> | ||
</div> |
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,15 @@ | ||
.modal-comment { | ||
.image-comment { | ||
width: 100%; | ||
height: 100%; | ||
align-content: center; | ||
border-radius: 5px; | ||
padding: 0; | ||
border: none; | ||
} | ||
.pdf-comment { | ||
width: 100%; | ||
height: 80vh; | ||
align-content: center; | ||
} | ||
} |
19 changes: 16 additions & 3 deletions
19
src/app/common/modals/comments-modal/comments-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 |
---|---|---|
@@ -1,10 +1,23 @@ | ||
import { Component, Input, Inject } from '@angular/core'; | ||
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: 'comments-modal', | ||
templateUrl: './comments-modal.component.html', | ||
styleUrls: ['./comments-modal.component.scss'], | ||
}) | ||
export class CommentsModalComponent { | ||
constructor() {} | ||
export class CommentsModalComponent implements OnInit { | ||
@Input() commentResourceUrl: string; | ||
@Input() commentType: string; | ||
|
||
constructor( | ||
@Inject(alertService) private alertService: any, | ||
public dialogRef: MatDialogRef<CommentsModalComponent>, | ||
@Inject(MAT_DIALOG_DATA) public data: any, | ||
) {} | ||
|
||
ngOnInit(): void { | ||
console.log('comments-model ngOnInit()'); | ||
} | ||
} |
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,18 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog'; | ||
import { CommentsModalComponent } from './comments-modal.component'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class CommentsModalService { | ||
constructor(public dialog: MatDialog) {} | ||
|
||
public show(commentResourceUrl: string, commentType: string) { | ||
let dialogRef: MatDialogRef<CommentsModalComponent, any>; | ||
dialogRef = this.dialog.open(CommentsModalComponent); | ||
dialogRef.updateSize('100%', '100%'); | ||
dialogRef.componentInstance.commentResourceUrl = commentResourceUrl; | ||
dialogRef.componentInstance.commentType = commentType; | ||
} | ||
} |