Home-myDmps-myDatasetDescriptions buttons updated according to dmp&dataset overview

This commit is contained in:
gpapavgeri 2020-07-22 11:23:20 +03:00
parent 5fc779a172
commit 9494e5b618
12 changed files with 99 additions and 33 deletions

View File

@ -2,7 +2,7 @@ import { RecentActivityType } from '@app/core/common/enum/recent-activity-type';
import { UserInfoListingModel } from '../user/user-info-listing'; import { UserInfoListingModel } from '../user/user-info-listing';
export class RecentActivityModel { export class RecentActivityModel {
id: String; id: string;
title: String; title: String;
description: String; description: String;
created: Date; created: Date;

View File

@ -51,9 +51,9 @@
</div> </div>
<div class="dmp-card-actions"> <div class="dmp-card-actions">
<a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DMP-LISTING.ACTIONS.EXPORT' | translate}}</a> <a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DMP-LISTING.ACTIONS.EXPORT' | translate}}</a>
<a class="col-auto border-right pointer" (click)="addDataset(activity.id)"><span class="material-icons icon-align">add</span>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}</a> <a class="col-auto border-right pointer" *ngIf="isDraftDmp(activity) && isUserOwner" (click)="addDataset(activity.id)"><span class="material-icons icon-align">add</span>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}</a>
<a class="col-auto border-right pointer" (click)="openShareDialog(activity.id, activity.title)"><span class="material-icons icon-align pr-2">group_add</span>{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a> <a class="col-auto border-right pointer" *ngIf="isUserOwner"(click)="openShareDialog(activity.id, activity.title)"><span class="material-icons icon-align pr-2">group_add</span>{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a>
<a class="col-auto border-right pointer" (click)="cloneClicked(activity)"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a> <a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="cloneClicked(activity)"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a>
<a class="col-auto pointer" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a> <a class="col-auto pointer" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a>
</div> </div>
@ -82,7 +82,7 @@
<button mat-menu-item (click)="viewVersions(getGroupId(activity), activity.title)"> <button mat-menu-item (click)="viewVersions(getGroupId(activity), activity.title)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}} <mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
</button> </button>
<button mat-menu-item *ngIf="isDraftDmp(activity) && isUserOwner(activity)" (click)="deleteClicked()" class="menu-item"> <button mat-menu-item *ngIf="isUserOwner(activity)" (click)="deleteClicked()" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }} <mat-icon>delete</mat-icon>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }}
</button> </button>
</mat-menu> </mat-menu>

View File

@ -138,7 +138,8 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
} }
cloneClicked(dmp: DmpListingModel) { cloneClicked(dmp: DmpListingModel) {
this.router.navigate(['/plans/clone/' + dmp.id]); let url = this.router.createUrlTree(['/plans/clone/', dmp.id]);
window.open(url.toString(), '_blank');
} }
deleteClicked(dmp: DmpListingModel) { deleteClicked(dmp: DmpListingModel) {

View File

@ -46,15 +46,15 @@
</div> </div>
<div class="dataset-card-actions"> <div class="dataset-card-actions">
<a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DATASET-LISTING.ACTIONS.EXPORT' | translate}}</a> <a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DATASET-LISTING.ACTIONS.EXPORT' | translate}}</a>
<a class="col-auto border-right pointer" (click)="openShareDialog(activity.dmpId, activity.dmp)"><span class="material-icons icon-align pr-2">group_add</span>{{'DATASET-LISTING.ACTIONS.INVITE-COLLABORATORS' | translate}}</a> <a class="col-auto border-right pointer" *ngIf="isUserOwner(activity)" (click)="openShareDialog(activity.dmpId, activity.dmp)"><span class="material-icons icon-align pr-2">group_add</span>{{'DATASET-LISTING.ACTIONS.INVITE-COLLABORATORS' | translate}}</a>
<a class="col-auto pointer" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a> <a class="col-auto pointer" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a>
<!-- <a class="col-auto" [matMenuTriggerFor]="actionsMenu" *ngIf="!publicMode"><span class="material-icons icon-align pl-2">more_horiz</span></a> --> <!-- <a class="col-auto" [matMenuTriggerFor]="actionsMenu" *ngIf="!publicMode"><span class="material-icons icon-align pl-2">more_horiz</span></a> -->
</div> </div>
<mat-menu #actionsMenu="matMenu"> <mat-menu #actionsMenu="matMenu">
<button mat-menu-item (click)="openDmpSearchDialogue(activity.id)" class="menu-item"> <button mat-menu-item *ngIf="isAuthenticated()" (click)="openDmpSearchDialogue(activity.id)" class="menu-item">
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}} <mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
</button> </button>
<button mat-menu-item (click)="openConfirm(activity.id)" class="menu-item"> <button mat-menu-item *ngIf="isUserOwner" (click)="openConfirm(activity.id)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }} <mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}
</button> </button>
<!-- <button mat-menu-item *ngIf="needsUpdate(activity)" class="menu-item" (click)="openUpdateDatasetProfileDialogue(activity.id);"> <!-- <button mat-menu-item *ngIf="needsUpdate(activity)" class="menu-item" (click)="openUpdateDatasetProfileDialogue(activity.id);">

View File

@ -22,6 +22,7 @@ import { SnackBarNotificationLevel } from '@common/modules/notification/ui-notif
import { DatasetStatus } from '@app/core/common/enum/dataset-status'; import { DatasetStatus } from '@app/core/common/enum/dataset-status';
import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component'; import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component';
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
import { Role } from '@app/core/common/enum/role';
@Component({ @Component({
selector: 'app-recent-edited-dataset-activity', selector: 'app-recent-edited-dataset-activity',
@ -117,6 +118,11 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen
return !!this.authentication.current(); return !!this.authentication.current();
} }
isUserOwner(activity: DatasetListingModel): boolean {
const principal: Principal = this.authentication.current();
if (principal) return principal.id === activity.users.find(x => x.role === Role.Owner).id;
}
roleDisplay(value: any) { roleDisplay(value: any) {
const principal: Principal = this.authentication.current(); const principal: Principal = this.authentication.current();
let role: number; let role: number;
@ -156,8 +162,9 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)) dialogRef.afterClosed().pipe(takeUntil(this._destroyed))
.subscribe(result => { .subscribe(result => {
if (result && result.datasetProfileExist) { if (result && result.datasetProfileExist) {
const newDmpId = result.formControl.value.id const newDmpId = result.formControl.value.id;
this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } }); let url = this.router.createUrlTree(['/datasets/copy/', result.datasetId, { newDmpId: newDmpId } ])
window.open(url.toString(), '_blank')
} }
}); });
} }

View File

@ -50,9 +50,9 @@
</div> </div>
<div class="dmp-card-actions"> <div class="dmp-card-actions">
<a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DMP-LISTING.ACTIONS.EXPORT' | translate}}</a> <a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DMP-LISTING.ACTIONS.EXPORT' | translate}}</a>
<a class="col-auto border-right pointer" (click)="addDataset(activity.id)"><span class="material-icons icon-align">add</span>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}</a> <a class="col-auto border-right pointer" *ngIf="isDraftDmp(activity) && isUserOwner" (click)="addDataset(activity.id)"><span class="material-icons icon-align">add</span>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}</a>
<a class="col-auto border-right pointer" (click)="openShareDialog(activity.id, activity.label)"><span class="material-icons icon-align pr-2">group_add</span>{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a> <a class="col-auto border-right pointer" *ngIf="isUserOwner" (click)="openShareDialog(activity.id, activity.label)"><span class="material-icons icon-align pr-2">group_add</span>{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a>
<a class="col-auto border-right pointer" (click)="cloneClicked(activity)"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a> <a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="cloneClicked(activity)"><span class="material-icons icon-align pr-2">filter_none</span>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}</a>
<a class="col-auto pointer" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a> <a class="col-auto pointer" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a>
</div> </div>
@ -81,7 +81,7 @@
<button mat-menu-item (click)="viewVersions(activity.groupId, activity.label)"> <button mat-menu-item (click)="viewVersions(activity.groupId, activity.label)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}} <mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
</button> </button>
<button mat-menu-item *ngIf="isDraftDmp(activity) && isUserOwner(activity)" (click)="deleteClicked()" class="menu-item"> <button mat-menu-item *ngIf="isUserOwner(activity)" (click)="deleteClicked()" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }} <mat-icon>delete</mat-icon>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }}
</button> </button>
</mat-menu> </mat-menu>

View File

@ -123,7 +123,8 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
} }
cloneClicked(dmp: DmpListingModel) { cloneClicked(dmp: DmpListingModel) {
this.router.navigate(['/plans/clone/' + dmp.id]); let url = this.router.createUrlTree(['/plans/clone/', dmp.id]);
window.open(url.toString(), '_blank');
} }
deleteClicked(dmp: DmpListingModel) { deleteClicked(dmp: DmpListingModel) {

View File

@ -24,15 +24,15 @@
</a> </a>
<div class="dataset-card-actions"> <div class="dataset-card-actions">
<a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DATASET-LISTING.ACTIONS.EXPORT' | translate}}</a> <a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DATASET-LISTING.ACTIONS.EXPORT' | translate}}</a>
<a class="col-auto border-right pointer" (click)="openShareDialog(dataset.dmpId, dataset.dmp)"><span class="material-icons icon-align pr-2">group_add</span>{{'DATASET-LISTING.ACTIONS.INVITE-COLLABORATORS' | translate}}</a> <a class="col-auto border-right pointer" *ngIf="isUserOwner" (click)="openShareDialog(dataset.dmpId, dataset.dmp)"><span class="material-icons icon-align pr-2">group_add</span>{{'DATASET-LISTING.ACTIONS.INVITE-COLLABORATORS' | translate}}</a>
<a class="col-auto pointer" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a> <a class="col-auto pointer" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a>
<!-- <a class="col-auto" [matMenuTriggerFor]="actionsMenu" *ngIf="!publicMode"><span class="material-icons icon-align pl-2">more_horiz</span></a> --> <!-- <a class="col-auto" [matMenuTriggerFor]="actionsMenu" *ngIf="!publicMode"><span class="material-icons icon-align pl-2">more_horiz</span></a> -->
</div> </div>
<mat-menu #actionsMenu="matMenu"> <mat-menu #actionsMenu="matMenu">
<button mat-menu-item (click)="openDmpSearchDialogue(dataset)" class="menu-item"> <button *ngIf="isAuthenticated()" mat-menu-item (click)="openDmpSearchDialogue(dataset)" class="menu-item">
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}} <mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
</button> </button>
<button mat-menu-item (click)="openConfirm(dataset.id)" class="menu-item"> <button *ngIf="isUserOwner && !lockStatus" mat-menu-item (click)="openConfirm(dataset.id)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }} <mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}
</button> </button>
<!-- <button mat-menu-item *ngIf="needsUpdate(activity)" class="menu-item" (click)="openUpdateDatasetProfileDialogue(activity.id);"> <!-- <button mat-menu-item *ngIf="needsUpdate(activity)" class="menu-item" (click)="openUpdateDatasetProfileDialogue(activity.id);">

View File

@ -17,6 +17,8 @@ import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/serv
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
import { Principal } from '@app/core/model/auth/principal'; import { Principal } from '@app/core/model/auth/principal';
import { AuthService } from '@app/core/services/auth/auth.service'; import { AuthService } from '@app/core/services/auth/auth.service';
import { LockService } from '@app/core/services/lock/lock.service';
import { Role } from '@app/core/common/enum/role';
@Component({ @Component({
selector: 'app-dataset-listing-item-component', selector: 'app-dataset-listing-item-component',
@ -32,6 +34,8 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit
isDraft: boolean; isDraft: boolean;
isDeleted: boolean; isDeleted: boolean;
lockStatus: Boolean;
isUserOwner: boolean;
constructor( constructor(
private router: Router, private router: Router,
@ -40,7 +44,8 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit
public dialog: MatDialog, public dialog: MatDialog,
private language: TranslateService, private language: TranslateService,
private authentication: AuthService, private authentication: AuthService,
private uiNotificationService: UiNotificationService private uiNotificationService: UiNotificationService,
private lockService: LockService
) { ) {
super(); super();
} }
@ -49,15 +54,35 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit
if (this.dataset.status === DatasetStatus.Draft) { if (this.dataset.status === DatasetStatus.Draft) {
this.isDraft = true; this.isDraft = true;
this.isDeleted = false; this.isDeleted = false;
this.checkLockStatus(this.dataset.id);
this.setIsUserOwner();
} else if (this.dataset.status === DatasetStatus.Deleted) { } else if (this.dataset.status === DatasetStatus.Deleted) {
this.isDeleted = true; this.isDeleted = true;
} }
else { else {
this.isDraft = false; this.isDraft = false;
this.isDeleted = false; this.isDeleted = false;
this.checkLockStatus(this.dataset.id);
this.setIsUserOwner();
} }
} }
checkLockStatus(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => this.lockStatus = lockStatus);
}
setIsUserOwner() {
if (this.dataset) {
const principal: Principal = this.authentication.current();
if (principal) this.isUserOwner = principal.id === this.dataset.users.find(x => x.role === Role.Owner).id;
}
}
public isAuthenticated(): boolean {
return !(!this.authentication.current());
}
getItemLink(): string[] { getItemLink(): string[] {
return this.isPublic ? [`/datasets/publicEdit/${this.dataset.id}`] : [`/datasets/edit/${this.dataset.id}`]; return this.isPublic ? [`/datasets/publicEdit/${this.dataset.id}`] : [`/datasets/edit/${this.dataset.id}`];
} }
@ -170,18 +195,33 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit
this.datasetWizardService.delete(id) this.datasetWizardService.delete(id)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess(), complete => this.onDeleteCallbackSuccess(),
// error => this.onCallbackError(error) error => this.onDeleteCallbackError(error)
); );
} }
}); });
} }
onCallbackSuccess(id?: String): void { reloadPage(): void {
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => {
id ? this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', id]); }) : this.router.navigate(['/datasets']); this.router.navigate(['/datasets']);
});
} }
onDeleteCallbackSuccess(): void {
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success);
this.reloadPage();
}
onDeleteCallbackError(error) {
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
}
// onCallbackSuccess(id?: String): void {
// this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
// id ? this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', id]); }) : this.router.navigate(['/datasets']);
// }
roleDisplay(value: any) { roleDisplay(value: any) {
const principal: Principal = this.authentication.current(); const principal: Principal = this.authentication.current();
let role: number; let role: number;
@ -203,6 +243,8 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit
} }
} }
// onCallbackError(error: any) { // onCallbackError(error: any) {
// this.setErrorModel(error.error); // this.setErrorModel(error.error);
// } // }

View File

@ -29,7 +29,6 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
public filteredUsers: DmpInvitationUser[]; public filteredUsers: DmpInvitationUser[];
public emails: string[] = []; public emails: string[] = [];
public roles = Role; public roles = Role;
public roleNames: string[];
visible = true; visible = true;
selectable = true; selectable = true;
@ -46,7 +45,6 @@ export class DmpInvitationDialogComponent extends BaseComponent implements OnIni
@Inject(MAT_DIALOG_DATA) public data: any @Inject(MAT_DIALOG_DATA) public data: any
) { ) {
super(); super();
this.roleNames = Object.keys(this.roles).filter(key => key.length > 1);
} }
ngOnInit(): void { ngOnInit(): void {

View File

@ -59,7 +59,8 @@
<button mat-menu-item (click)="viewVersions(dmp.groupId, dmp.label)"> <button mat-menu-item (click)="viewVersions(dmp.groupId, dmp.label)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}} <mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
</button> </button>
<button mat-menu-item *ngIf="isDraftDmp(dmp) && isUserOwner(dmp)" (click)="deleteClicked()" class="menu-item"> <!-- <button mat-menu-item *ngIf="isDraftDmp(dmp) && isUserOwner(dmp)" (click)="deleteClicked()" class="menu-item"> -->
<button mat-menu-item *ngIf="isUserOwner(dmp) && !lockStatus" (click)="deleteClicked(dmp)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }} <mat-icon>delete</mat-icon>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }}
</button> </button>
</mat-menu> </mat-menu>

View File

@ -16,6 +16,7 @@ import * as FileSaver from 'file-saver';
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service'; import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service';
import { Role } from '@app/core/common/enum/role'; import { Role } from '@app/core/common/enum/role';
import { LockService } from '@app/core/services/lock/lock.service';
@Component({ @Component({
selector: 'app-dmp-listing-item-component', selector: 'app-dmp-listing-item-component',
@ -32,6 +33,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
isDraft: boolean; isDraft: boolean;
isFinalized: boolean; isFinalized: boolean;
isPublished: boolean; isPublished: boolean;
lockStatus: Boolean;
constructor( constructor(
private router: Router, private router: Router,
@ -40,7 +42,8 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
public enumUtils: EnumUtils, public enumUtils: EnumUtils,
private dmpService: DmpService, private dmpService: DmpService,
private language: TranslateService, private language: TranslateService,
private uiNotificationService: UiNotificationService) { private uiNotificationService: UiNotificationService,
private lockService: LockService) {
super(); super();
} }
@ -49,15 +52,22 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
this.isDraft = true; this.isDraft = true;
this.isFinalized = false; this.isFinalized = false;
this.isPublished = false; this.isPublished = false;
this.checkLockStatus(this.dmp.id);
} }
else if (this.dmp.status == DmpStatus.Finalized) { else if (this.dmp.status == DmpStatus.Finalized) {
this.isDraft = false; this.isDraft = false;
this.isFinalized = true; this.isFinalized = true;
this.isPublished = false; this.isPublished = false;
this.checkLockStatus(this.dmp.id);
if (this.dmp.public == true) { this.isPublished = true } if (this.dmp.public == true) { this.isPublished = true }
} }
} }
checkLockStatus(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => this.lockStatus = lockStatus);
}
openShareDialog(rowId: any, rowName: any) { openShareDialog(rowId: any, rowName: any) {
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
// height: '250px', // height: '250px',
@ -204,7 +214,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
this.dmpService.delete(dmp.id) this.dmpService.delete(dmp.id)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => { this.onCallbackSuccess() }, complete => this.onDeleteCallbackSuccess(),
error => this.onDeleteCallbackError(error) error => this.onDeleteCallbackError(error)
); );
} }
@ -215,9 +225,15 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
return activity.status == DmpStatus.Draft; return activity.status == DmpStatus.Draft;
} }
onCallbackSuccess(): void { reloadPage(): void {
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => {
this.router.navigate(['/plans']); this.router.navigate(['/plans']);
});
}
onDeleteCallbackSuccess(): void {
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success);
this.reloadPage();
} }
onDeleteCallbackError(error) { onDeleteCallbackError(error) {