Fixes: Permissions of remove collaborator, Dialog bug on add researchers

This commit is contained in:
apapachristou 2019-05-29 10:12:49 +03:00
parent c5fb057bf5
commit f6be85a8f2
4 changed files with 36 additions and 8 deletions

View File

@ -1,11 +1,11 @@
<form *ngIf="formGroup" [formGroup]="formGroup">
<h1 mat-dialog-title>{{'ADDRESEARCHERS-EDITOR.TITLE' | translate}}</h1>
<div mat-dialog-content class="row">
<mat-form-field class="col-6">
<mat-form-field class="col-12">
<input matInput formControlName="firstName" placeholder="{{'ADDRESEARCHERS-EDITOR.FIRST_NAME' | translate}}" required>
<mat-error *ngIf="formGroup.get('firstName').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-6">
<mat-form-field class="col-12">
<input matInput formControlName="lastName" placeholder="{{'ADDRESEARCHERS-EDITOR.LAST_NAME' | translate}}" required>
<mat-error *ngIf="formGroup.get('lastName').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>

View File

@ -8,19 +8,19 @@
</div>
</div>
<div class="table-container">
<table>
<table *ngIf="people">
<tr>
<th>{{'USERS.LISTING.NAME' | translate}}</th>
<th>{{'USERS.LISTING.EMAIL' | translate}}</th>
<th>{{'USERS.LISTING.PERMISSIONS' | translate}}</th>
<th></th>
<th *ngIf="isOwner()"></th>
</tr>
<tr *ngFor="let user of people">
<td>{{user.name}}</td>
<td>{{user.email}}</td>
<td>{{roleDisplay(user)}}</td>
<td>
<div *ngIf="user.role" class="remove_user" (click)="removeUser()">
<td *ngIf="isOwner()">
<div *ngIf="user.role" class="remove_user" (click)="removeCollaborator()">
<mat-icon>delete</mat-icon>
</div>
</td>

View File

@ -5,6 +5,9 @@ import { MatDialog } from '@angular/material';
import { DmpInvitationDialogComponent } from '../../invitation/dmp-invitation.component';
import { UserInfoListingModel } from '../../../../core/model/user/user-info-listing';
import { TranslateService } from '@ngx-translate/core';
import { Principal } from '../../../../core/model/auth/Principal';
import { AuthService } from '../../../../core/services/auth/auth.service';
import { ConfirmationDialogComponent } from '../../../../library/confirmation-dialog/confirmation-dialog.component';
@Component({
selector: 'app-people-tab',
@ -18,7 +21,9 @@ export class PeopleTabComponent implements OnInit {
@Input() dmp: DmpEditorModel;
constructor(
private dialog: MatDialog,
private translate: TranslateService
private translate: TranslateService,
private authentication: AuthService,
private language: TranslateService
) { }
ngOnInit() {
@ -47,8 +52,29 @@ export class PeopleTabComponent implements OnInit {
}
}
removeUser() {
isOwner() {
const principal: Principal = this.authentication.current();
var isOwner: boolean = false;
if (principal) {
this.people.forEach(element => {
if (principal.id === element.id && element.role === 0) {
isOwner = true;
}
});
}
return isOwner;
}
removeCollaborator() {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px',
data: {
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-USER'),
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.REMOVE'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL')
}
});
// dialogRef.afterClosed();
}
}

View File

@ -34,10 +34,12 @@
},
"CONFIRMATION-DIALOG": {
"DELETE-ITEM": "Delete this item?",
"DELETE-USER": "Remove this collaborator?",
"ACTIONS": {
"CONFIRM": "Yes",
"No": "No",
"DELETE": "Delete",
"REMOVE": "Remove",
"CANCEL": "Cancel"
}
},