Add "invite Collaborators" on DMP Overview (ref #241)

This commit is contained in:
George Kalampokis 2020-02-14 18:14:48 +02:00
parent 995cb32017
commit dd482f08a3
2 changed files with 38 additions and 14 deletions

View File

@ -11,6 +11,9 @@
<mat-icon class="more-horiz">more_horiz</mat-icon> <mat-icon class="more-horiz">more_horiz</mat-icon>
</button> </button>
<mat-menu #actionsMenu="matMenu" xPosition="before"> <mat-menu #actionsMenu="matMenu" xPosition="before">
<button mat-menu-item (click)="openShareDialog(dmp.id,dmp.label)">
<mat-icon>share</mat-icon>{{'DMP-LISTING.ACTIONS.INVITE' | translate}}
</button>
<button *ngIf="isUserOwner" mat-menu-item (click)="newVersion(dmp.id, dmp.label)"> <button *ngIf="isUserOwner" mat-menu-item (click)="newVersion(dmp.id, dmp.label)">
<mat-icon>queue</mat-icon>{{'DMP-LISTING.ACTIONS.NEW-VERSION' | translate}} <mat-icon>queue</mat-icon>{{'DMP-LISTING.ACTIONS.NEW-VERSION' | translate}}
</button> </button>

View File

@ -21,6 +21,7 @@ import * as FileSaver from 'file-saver';
import { Observable, of as observableOf } from 'rxjs'; import { Observable, of as observableOf } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { Role } from "@app/core/common/enum/role"; import { Role } from "@app/core/common/enum/role";
import { DmpInvitationDialogComponent } from '../invitation/dmp-invitation.component';
@Component({ @Component({
selector: 'app-dmp-overview', selector: 'app-dmp-overview',
@ -64,7 +65,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.dmp = data; this.dmp = data;
this.setIsUserOwner(); this.setIsUserOwnerOrCreator();
const breadCrumbs = []; const breadCrumbs = [];
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DMPS'), url: "/plans" }); breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DMPS'), url: "/plans" });
breadCrumbs.push({ parentComponentName: 'DmpListingComponent', label: this.dmp.label, url: '/plans/overview/' + this.dmp.id }); breadCrumbs.push({ parentComponentName: 'DmpListingComponent', label: this.dmp.label, url: '/plans/overview/' + this.dmp.id });
@ -83,7 +84,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.dmp = data; this.dmp = data;
this.setIsUserOwner(); this.setIsUserOwnerOrCreator();
const breadCrumbs = []; const breadCrumbs = [];
breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC-DMPS'), url: "/explore-plans" }); breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC-DMPS'), url: "/explore-plans" });
breadCrumbs.push({ parentComponentName: 'DmpListingComponent', label: this.dmp.label, url: '/plans/publicOverview/' + this.dmp.id }); breadCrumbs.push({ parentComponentName: 'DmpListingComponent', label: this.dmp.label, url: '/plans/publicOverview/' + this.dmp.id });
@ -102,10 +103,10 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
this.router.navigate([redirectRoot]); this.router.navigate([redirectRoot]);
} }
setIsUserOwner() { setIsUserOwnerOrCreator() {
if (this.dmp) { if (this.dmp) {
const principal: Principal = this.authentication.current(); const principal: Principal = this.authentication.current();
if (principal) this.isUserOwner = principal.id === this.dmp.users.find(x => x.role === Role.Owner).id; if (principal) this.isUserOwner = principal.id === this.dmp.users.find(x => x.role === Role.Owner || x.role === Role.Creator).id;
} }
} }
@ -243,12 +244,15 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
} }
}); });
} }
if (role === Role.Owner) { switch (role) {
return this.translate.instant('DMP-LISTING.OWNER'); case Role.Creator:
} else if (role === Role.Member) { return this.translate.instant('DMP-LISTING.CREATOR');
return this.translate.instant('DMP-LISTING.MEMBER'); case Role.Owner:
} else { return this.translate.instant('DMP-LISTING.OWNER');
return this.translate.instant('DMP-LISTING.OWNER'); case Role.Member:
return this.translate.instant('DMP-LISTING.MEMBER');
default:
return this.translate.instant('DMP-LISTING.OWNER');
} }
} }
@ -266,10 +270,15 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
} }
roleDisplay(value: UserInfoListingModel) { roleDisplay(value: UserInfoListingModel) {
if (value.role === Role.Member) { switch (value.role) {
return this.translate.instant('DMP-LISTING.MEMBER'); case Role.Creator:
} else { return this.translate.instant('DMP-LISTING.CREATOR');
return this.translate.instant('DMP-LISTING.OWNER'); case Role.Owner:
return this.translate.instant('DMP-LISTING.OWNER');
case Role.Member:
return this.translate.instant('DMP-LISTING.MEMBER');
default:
return this.translate.instant('DMP-LISTING.OWNER');
} }
} }
@ -409,6 +418,18 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
return !(!this.authentication.current()); return !(!this.authentication.current());
} }
openShareDialog(rowId: any, rowName: any) {
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
// height: '250px',
// width: '700px',
restoreFocus: false,
data: {
dmpId: rowId,
dmpName: rowName
}
});
}
// advancedClicked() { // advancedClicked() {
// const dialogRef = this.dialog.open(ExportMethodDialogComponent, { // const dialogRef = this.dialog.open(ExportMethodDialogComponent, {
// maxWidth: '500px', // maxWidth: '500px',