Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate/comments-modal component #869

Open
wants to merge 11 commits into
base: 8.0.x
Choose a base branch
from
32 changes: 0 additions & 32 deletions src/app/common/modals/comments-modal/comments-modal.coffee

This file was deleted.

11 changes: 11 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,11 @@
<div class="p-6">
@if (taskComment.commentType === 'image') {
<img class="w-full h-full p-0 rounded border-none" [src]="commentResourceUrl" />
} @else if (taskComment.commentType === 'pdf') {
<iframe
b0ink marked this conversation as resolved.
Show resolved Hide resolved
class="w-full h-[80vh]"
[src]="commentResourceUrl | safe"
type="application/pdf"
></iframe>
}
</div>
Empty file.
25 changes: 25 additions & 0 deletions src/app/common/modals/comments-modal/comments-modal.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {Component, Input, Inject, OnInit} from '@angular/core';
import {MAT_DIALOG_DATA} from '@angular/material/dialog';
import {TaskComment} from 'src/app/api/models/doubtfire-model';

export interface CommentsModalData {
comment: TaskComment;
commentResourceUrl: string;
}

@Component({
selector: 'comments-modal',
templateUrl: './comments-modal.component.html',
styleUrls: ['./comments-modal.component.scss'],
})
export class CommentsModalComponent implements OnInit {
@Input() taskComment: TaskComment;
@Input() commentResourceUrl: string;

constructor(@Inject(MAT_DIALOG_DATA) public data: CommentsModalData) {}

ngOnInit(): void {
this.taskComment = this.data.comment;
this.commentResourceUrl = this.data.commentResourceUrl;
}
}
15 changes: 0 additions & 15 deletions src/app/common/modals/comments-modal/comments-modal.scss

This file was deleted.

20 changes: 20 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,20 @@
import {Injectable} from '@angular/core';
import {MatDialog} from '@angular/material/dialog';
import {TaskComment} from 'src/app/api/models/doubtfire-model';
import {CommentsModalComponent, CommentsModalData} from './comments-modal.component';

@Injectable({
providedIn: 'root',
})
export class CommentsModalService {
constructor(public dialog: MatDialog) {}

public show(commentResourceUrl: string, comment: TaskComment) {
this.dialog.open<CommentsModalComponent, CommentsModalData>(CommentsModalComponent, {
data: {commentResourceUrl, comment},
width: '100%',
maxWidth: '900px',
panelClass: 'overflow-y-auto',
});
}
}
10 changes: 0 additions & 10 deletions src/app/common/modals/comments-modal/comments-modal.tpl.html

This file was deleted.

1 change: 0 additions & 1 deletion src/app/common/modals/modals.coffee
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'
])
2 changes: 2 additions & 0 deletions src/app/doubtfire-angular.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ import {FTaskSheetViewComponent} from './units/states/tasks/viewer/directives/f-
import {TasksViewerComponent} from './units/states/tasks/tasks-viewer/tasks-viewer.component';
import {UnitCodeComponent} from './common/unit-code/unit-code.component';
import {GradeService} from './common/services/grade.service';
import {CommentsModalComponent} from './common/modals/comments-modal/comments-modal.component';

@NgModule({
// Components we declare
Expand Down Expand Up @@ -325,6 +326,7 @@ import {GradeService} from './common/services/grade.service';
FUsersComponent,
FTaskBadgeComponent,
FUnitsComponent,
CommentsModalComponent,
],
// Services we provide
providers: [
Expand Down
5 changes: 3 additions & 2 deletions src/app/doubtfire-angularjs.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ import 'build/src/app/units/states/analytics/analytics.js';
import 'build/src/app/common/filters/filters.js';
import 'build/src/app/common/content-editable/content-editable.js';
import 'build/src/app/common/modals/confirmation-modal/confirmation-modal.js';
import 'build/src/app/common/modals/comments-modal/comments-modal.js';
import 'build/src/app/common/modals/csv-result-modal/csv-result-modal.js';
import 'build/src/app/common/modals/modals.js';
import 'build/src/app/common/grade-icon/grade-icon.js';
Expand Down Expand Up @@ -220,11 +219,12 @@ import {FUnitTaskListComponent} from './units/states/tasks/viewer/directives/f-u
import {FTaskDetailsViewComponent} from './units/states/tasks/viewer/directives/f-task-details-view/f-task-details-view.component';
import {FTaskSheetViewComponent} from './units/states/tasks/viewer/directives/f-task-sheet-view/f-task-sheet-view.component';
import {TasksViewerComponent} from './units/states/tasks/tasks-viewer/tasks-viewer.component';

import {FUnitsComponent} from './admin/states/f-units/f-units.component';
import {MarkedPipe} from './common/pipes/marked.pipe';
import {AlertService} from './common/services/alert.service';
import {GradeService} from './common/services/grade.service';
import {CommentsModalService} from './common/modals/comments-modal/comments-modal.service';

export const DoubtfireAngularJSModule = angular.module('doubtfire', [
'doubtfire.config',
'doubtfire.sessions',
Expand Down Expand Up @@ -306,6 +306,7 @@ DoubtfireAngularJSModule.factory(
downgradeInjectable(EditProfileDialogService),
);
DoubtfireAngularJSModule.factory('CreateNewUnitModal', downgradeInjectable(CreateNewUnitModal));
DoubtfireAngularJSModule.factory('CommentsModal', downgradeInjectable(CommentsModalService));

// directive -> component
DoubtfireAngularJSModule.directive(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component, OnInit, Input, Inject, OnDestroy } from '@angular/core';
import { commentsModal } from 'src/app/ajs-upgraded-providers';
import { Project, TaskComment, Task } from 'src/app/api/models/doubtfire-model';
import { FileDownloaderService } from 'src/app/common/file-downloader/file-downloader.service';
import { AlertService } from 'src/app/common/services/alert.service';
import {Component, OnInit, Input, Inject, OnDestroy} from '@angular/core';
import {commentsModal} from 'src/app/ajs-upgraded-providers';
import {Project, TaskComment, Task} from 'src/app/api/models/doubtfire-model';
import {FileDownloaderService} from 'src/app/common/file-downloader/file-downloader.service';
import {CommentsModalService} from 'src/app/common/modals/comments-modal/comments-modal.service';
import {AlertService} from 'src/app/common/services/alert.service';

@Component({
selector: 'pdf-image-comment',
Expand All @@ -18,7 +19,7 @@ export class PdfImageCommentComponent implements OnInit, OnDestroy {

constructor(
private alerts: AlertService,
@Inject(commentsModal) private commentsModalRef: any,
@Inject(commentsModal) private commentsModalRef: CommentsModalService,
private fileDownloaderService: FileDownloaderService,
) {}

Expand Down Expand Up @@ -48,7 +49,7 @@ export class PdfImageCommentComponent implements OnInit, OnDestroy {

public openCommentsModal() {
if (this.resourceUrl) {
this.commentsModalRef.show(this.resourceUrl, this.comment.commentType);
this.commentsModalRef.show(this.resourceUrl, this.comment);
} else {
this.downloadCommentResource(this.openCommentsModal.bind(this));
}
Expand Down