Fixed assign members
This commit is contained in:
parent
d0aa83f614
commit
a9fb796ff1
@ -1,5 +0,0 @@
|
|||||||
@import "../../../assets/styles/red-variables";
|
|
||||||
|
|
||||||
.owner {
|
|
||||||
background-color: rgba($primary, 0.1);
|
|
||||||
}
|
|
||||||
@ -3,7 +3,7 @@ import { FileStatus, Project, ProjectControllerService, StatusControllerService
|
|||||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { AppStateService } from '../../state/app-state.service';
|
import { AppStateService } from '../../state/app-state.service';
|
||||||
import { UserService } from '../../user/user.service';
|
import { UserService } from '../../user/user.service';
|
||||||
import { NotificationService } from '../../notification/notification.service';
|
import { NotificationService, NotificationType } from '../../notification/notification.service';
|
||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
|
|
||||||
class DialogData {
|
class DialogData {
|
||||||
@ -36,7 +36,6 @@ export class AssignOwnerDialogComponent {
|
|||||||
private _loadData() {
|
private _loadData() {
|
||||||
if (this.data.type === 'project') {
|
if (this.data.type === 'project') {
|
||||||
const project = this.data.project;
|
const project = this.data.project;
|
||||||
|
|
||||||
this.usersForm = this._formBuilder.group({
|
this.usersForm = this._formBuilder.group({
|
||||||
singleUser: [project?.ownerId, Validators.required],
|
singleUser: [project?.ownerId, Validators.required],
|
||||||
userList: [project?.memberIds]
|
userList: [project?.memberIds]
|
||||||
@ -52,37 +51,40 @@ export class AssignOwnerDialogComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async saveUsers() {
|
async saveUsers() {
|
||||||
if (this.data.type === 'project') {
|
try {
|
||||||
|
if (this.data.type === 'project') {
|
||||||
|
|
||||||
const ownerId = this.usersForm.get('singleUser').value;
|
const ownerId = this.usersForm.get('singleUser').value;
|
||||||
const memberIds = this.usersForm.get('userList').value;
|
const memberIds = this.usersForm.get('userList').value;
|
||||||
const project = this.data.project;
|
const project = this.data.project;
|
||||||
|
await this._projectControllerService.addMembersToProject({ memberIds: memberIds }, project.projectId).toPromise();
|
||||||
|
await this._projectControllerService.assignProjectOwner(project.projectId, ownerId).toPromise();
|
||||||
|
|
||||||
await this._projectControllerService.addMembersToProject({ memberIds: memberIds }, project.projectId).toPromise();
|
const updatedProject = await this._projectControllerService.getProject(project.projectId).toPromise();
|
||||||
await this._projectControllerService.assignProjectOwner(project.projectId, ownerId).toPromise();
|
|
||||||
|
|
||||||
const updatedProject = await this._projectControllerService.getProject(project.projectId).toPromise();
|
const toRemoveMembers = updatedProject.memberIds.filter(m => memberIds.indexOf(m) < 0);
|
||||||
|
if (toRemoveMembers.length > 0) {
|
||||||
|
await this._projectControllerService.deleteMembersToProject({ memberIds: toRemoveMembers }, project.projectId).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
project.ownerId = ownerId;
|
||||||
|
project.memberIds = [...new Set([ownerId, ...memberIds])];
|
||||||
|
|
||||||
|
this._notificationService.showToastNotification('Successfully assigned ' + this.userService.getNameForId(ownerId) + ' to project: ' + project.projectName);
|
||||||
|
|
||||||
const toRemoveMembers = updatedProject.memberIds.filter(m => memberIds.indexOf(m) < 0);
|
|
||||||
if (toRemoveMembers.length > 0) {
|
|
||||||
await this._projectControllerService.deleteMembersToProject({ memberIds: toRemoveMembers }, project.projectId).toPromise();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project.ownerId = ownerId;
|
if (this.data.type === 'file') {
|
||||||
project.memberIds = [...new Set([ownerId, ...memberIds])];
|
|
||||||
|
|
||||||
this._notificationService.showToastNotification('Successfully assigned ' + this.userService.getNameForId(ownerId) + ' to project: ' + project.projectName);
|
const reviewerId = this.usersForm.get('singleUser').value;
|
||||||
//this._notificationService.showToastNotification('Failed: ' + error.error.message, null, NotificationType.ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.data.type === 'file') {
|
await this._statusControllerService.assignProjectOwner1(this._appStateService.activeProjectId, this.data.file.fileId, reviewerId).toPromise();
|
||||||
|
this.data.file.currentReviewer = reviewerId;
|
||||||
const reviewerId = this.usersForm.get('singleUser').value;
|
this._notificationService.showToastNotification('Successfully assigned ' + this.userService.getNameForId(reviewerId) + ' to file: ' + this.data.file.filename);
|
||||||
|
|
||||||
await this._statusControllerService.assignProjectOwner1(this._appStateService.activeProjectId, this.data.file.fileId, reviewerId).toPromise();
|
|
||||||
this.data.file.currentReviewer = reviewerId;
|
|
||||||
this._notificationService.showToastNotification('Successfully assigned ' + this.userService.getNameForId(reviewerId) + ' to file: ' + this.data.file.filename);
|
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this._notificationService.showToastNotification('Failed: ' + error.error.message, null, NotificationType.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
|
|||||||
@ -136,7 +136,7 @@ export class DialogService {
|
|||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
this._dialog.open(AssignOwnerDialogComponent, {
|
this._dialog.open(AssignOwnerDialogComponent, {
|
||||||
...dialogConfig,
|
...dialogConfig,
|
||||||
data: { type: 'project', projectId: project.projectId }
|
data: { type: 'project', project: project }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -103,9 +103,8 @@ export class FilePreviewScreenComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public openAssignFileOwnerDialog($event: MouseEvent) {
|
public openAssignFileOwnerDialog($event: MouseEvent) {
|
||||||
$event.stopPropagation();
|
const file = this.appStateService.getFileById(this.projectId, this.fileId);
|
||||||
// TODO
|
this._dialogService.openAssignFileOwnerDialog($event, file);
|
||||||
console.log('not implemented yet');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public fileReady(viewer: string) {
|
public fileReady(viewer: string) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user