Skip to content

Commit

Permalink
refactor: migrate the comments-modal - get variables commentResourceU…
Browse files Browse the repository at this point in the history
…rl and commentType
  • Loading branch information
s223749059 committed Apr 4, 2024
1 parent a4da9ff commit 53f10d6
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/app/common/modals/comments-modal/comments-modal.component.html
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>
15 changes: 15 additions & 0 deletions src/app/common/modals/comments-modal/comments-modal.component.scss
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 src/app/common/modals/comments-modal/comments-modal.component.ts
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()');
}
}
18 changes: 18 additions & 0 deletions src/app/common/modals/comments-modal/comments-modal.service.ts
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;
}
}

0 comments on commit 53f10d6

Please sign in to comment.