Removed all dialogs from project listing

This commit is contained in:
Adina Țeudan 2020-10-22 00:27:16 +03:00
parent a8727c1d5b
commit 68039dc366
3 changed files with 41 additions and 39 deletions

View File

@ -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();
});
}
}

View File

@ -69,7 +69,7 @@
</div>
</div>
<div class="flex-1">
<redaction-initials-avatar [username]="_userService.getNameForId(pw.project.ownerId)"
<redaction-initials-avatar [username]="getOwnerName(pw)"
color="lightgray-red"
withName="true"
></redaction-initials-avatar>
@ -85,7 +85,7 @@
[matTooltip]="'project-listing.delete.action.label'|translate">
<mat-icon svgIcon="red:trash"></mat-icon>
</button>
<button mat-icon-button color="accent" (click)="openDetailsDialog($event,pw)"
<button mat-icon-button color="accent" (click)="openProjectDetailsDialog($event,pw)"
[matTooltip]="'project-listing.report.action.label'|translate">
<mat-icon svgIcon="red:report"></mat-icon>
</button>

View File

@ -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);
}
}