diff --git a/apps/red-ui/src/app/dialogs/dialog.service.ts b/apps/red-ui/src/app/dialogs/dialog.service.ts index 701c3908f..31e6fa6e7 100644 --- a/apps/red-ui/src/app/dialogs/dialog.service.ts +++ b/apps/red-ui/src/app/dialogs/dialog.service.ts @@ -5,8 +5,10 @@ import { FileStatus, FileUploadControllerService, Project } from '@redaction/red import { ConfirmationDialogComponent } from '../common/confirmation-dialog/confirmation-dialog.component'; import { NotificationService, NotificationType } from '../notification/notification.service'; import { TranslateService } from '@ngx-translate/core'; -import { AppStateService } from '../state/app-state.service'; +import { AppStateService, ProjectWrapper } from '../state/app-state.service'; import { AddEditProjectDialogComponent } from './add-edit-project-dialog/add-edit-project-dialog.component'; +import { AssignOwnerDialogComponent } from './assign-owner-dialog/assign-owner-dialog.component'; +import { ProjectDetailsDialogComponent } from './project-details-dialog/project-details-dialog.component'; const dialogConfig = { width: '600px', @@ -75,4 +77,27 @@ export class DialogService { } }); } + + public openAssignProjectOwnerDialog($event: MouseEvent, project: Project) { + $event.stopPropagation(); + this._dialog.open(AssignOwnerDialogComponent, { + ...dialogConfig, + data: { type: 'project', projectId: project.projectId } + }); + } + + public openProjectDetailsDialog($event: MouseEvent, project: ProjectWrapper) { + $event.stopPropagation(); + this._dialog.open(ProjectDetailsDialogComponent, { + ...dialogConfig, + data: project + }); + } + + public openAddProjectDialog(cb?: Function): void { + const dialogRef = this._dialog.open(AddEditProjectDialogComponent, dialogConfig); + dialogRef.afterClosed().subscribe(result => { + if (result && cb) cb(); + }); + } } diff --git a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html index c90a8fc62..9bbf8a2cd 100644 --- a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html +++ b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html @@ -69,7 +69,7 @@
- @@ -85,7 +85,7 @@ [matTooltip]="'project-listing.delete.action.label'|translate"> - diff --git a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.ts b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.ts index 8bcab7658..8c3f463ca 100644 --- a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.ts +++ b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.ts @@ -1,16 +1,10 @@ import { Component, OnInit } from '@angular/core'; -import { Project, ProjectControllerService } from '@redaction/red-ui-http'; -import { MatDialog } from '@angular/material/dialog'; -import { AddEditProjectDialogComponent } from '../../dialogs/add-edit-project-dialog/add-edit-project-dialog.component'; -import { TranslateService } from '@ngx-translate/core'; -import { NotificationService } from '../../notification/notification.service'; +import { Project } from '@redaction/red-ui-http'; import { AppStateService, ProjectWrapper } from '../../state/app-state.service'; import { UserService } from '../../user/user.service'; -import { ProjectDetailsDialogComponent } from '../../dialogs/project-details-dialog/project-details-dialog.component'; import { DoughnutChartConfig } from '../../components/simple-doughnut-chart/simple-doughnut-chart.component'; import { SortingOption } from '../../utils/types'; import { groupBy } from '../../utils/functions'; -import { AssignOwnerDialogComponent } from '../../dialogs/assign-owner-dialog/assign-owner-dialog.component'; import { DialogService } from '../../dialogs/dialog.service'; @Component({ @@ -30,11 +24,8 @@ export class ProjectListingScreenComponent implements OnInit { constructor( public readonly appStateService: AppStateService, private readonly _userService: UserService, - private readonly _dialogService: DialogService, - private readonly _projectControllerService: ProjectControllerService, - private readonly _translateService: TranslateService, - private readonly _notificationService: NotificationService, - private readonly _dialog: MatDialog) { + private readonly _dialogService: DialogService + ) { } ngOnInit(): void { @@ -74,6 +65,10 @@ export class ProjectListingScreenComponent implements OnInit { return this.appStateService.allProjects.length - this.activeProjects; } + public getOwnerName(pw: ProjectWrapper) { + return this._userService.getNameForId(pw.project.ownerId); + } + public documentCount(project: ProjectWrapper) { return project.files.length; } @@ -82,17 +77,9 @@ export class ProjectListingScreenComponent implements OnInit { return 1; } - public openAddProjectDialog(project?: Project): void { - const dialogRef = this._dialog.open(AddEditProjectDialogComponent, { - width: '400px', - maxWidth: '90vw', - data: project - }); - - dialogRef.afterClosed().subscribe(result => { - if (result) { - this._calculateData(); - } + public openAddProjectDialog(): void { + this._dialogService.openAddProjectDialog(() => { + this._calculateData(); }); } @@ -102,21 +89,11 @@ export class ProjectListingScreenComponent implements OnInit { }); } - public openDetailsDialog($event: MouseEvent, project: ProjectWrapper) { - $event.stopPropagation(); - this._dialog.open(ProjectDetailsDialogComponent, { - width: '600px', - maxWidth: '90vw', - data: project - }); + public openProjectDetailsDialog($event: MouseEvent, project: ProjectWrapper) { + this._dialogService.openProjectDetailsDialog($event, project); } public openAssignProjectOwnerDialog($event: MouseEvent, project: Project) { - $event.stopPropagation(); - this._dialog.open(AssignOwnerDialogComponent, { - width: '400px', - maxWidth: '90vw', - data: { type: 'project', projectId: project.projectId } - }); + this._dialogService.openAssignProjectOwnerDialog($event, project); } }