lockStatus check update [on delete click for listing components (listing-item, recent-edited, drafts) - not overview]

This commit is contained in:
gpapavgeri 2020-07-24 17:40:53 +03:00
parent 7f476ccd50
commit ca4525238e
13 changed files with 180 additions and 100 deletions

View File

@ -34,8 +34,6 @@
<span *ngIf="activity.status === 1 && activity.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span *ngIf="activity.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span>.</span>
<span *ngIf="lockStatusMap.get(activity.id)" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatusMap.get(activity.id)">.</span>
<span class="col">{{'DATASET-LISTING.COLUMNS.GRANT' | translate}}: {{activity.grant}}</span>
</div>
<div class="d-flex flex-direction-row pt-3 pb-3">
@ -56,7 +54,7 @@
<button mat-menu-item (click)="openDmpSearchDialogue(activity)" class="menu-item">
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
</button>
<button mat-menu-item *ngIf="!lockStatusMap.get(activity.id)" (click)="openConfirm(activity.id)" class="menu-item">
<button mat-menu-item (click)="deleteClicked(activity.id)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}
</button>
<!-- <button mat-menu-item *ngIf="needsUpdate(activity)" class="menu-item" (click)="openUpdateDatasetProfileDialogue(activity.id);">

View File

@ -39,7 +39,6 @@ export class DraftsComponent extends BaseComponent implements OnInit {
datasetDrafts: DatasetListingModel[];
datasetDraftsTypeEnum = RecentActivityType;
status: number;
lockStatusMap = new Map();
totalCount: number;
startIndex: number = 0;
@ -78,14 +77,6 @@ export class DraftsComponent extends BaseComponent implements OnInit {
this.datasetDrafts = response.data;
this.totalCount = response.totalCount;
this.totalCountDraftDatasets.emit(this.datasetDrafts.length);
this.datasetDrafts.forEach(recentActivity => {
let lockStatus: Boolean;
this.lockService.checkLockStatus(recentActivity.id).pipe(takeUntil(this._destroyed))
.subscribe(status => {
lockStatus = status;
this.lockStatusMap.set(recentActivity.id, lockStatus);
});
});
});
this.formGroup.get('like').valueChanges
.pipe(takeUntil(this._destroyed))
@ -168,7 +159,18 @@ export class DraftsComponent extends BaseComponent implements OnInit {
});
}
openConfirm(id: string): void {
deleteClicked(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => {
if (!lockStatus) {
this.openDeleteDialog(id);
} else {
this.openLockedByUserDialog();
}
});
}
openDeleteDialog(id: string): void {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px',
restoreFocus: false,
@ -191,6 +193,16 @@ export class DraftsComponent extends BaseComponent implements OnInit {
});
}
openLockedByUserDialog() {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '400px',
restoreFocus: false,
data: {
message: this.language.instant('DATASET-WIZARD.ACTIONS.LOCK')
}
});
}
openShareDialog(dmpRowId: any, dmpRowName: any) {
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
// height: '250px',

View File

@ -35,8 +35,6 @@
<span *ngIf="activity.status === 1 && activity.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span *ngIf="activity.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span>.</span>
<span *ngIf="lockStatusMap.get(activity.id)" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatusMap.get(activity.id)">.</span>
<span class="col-auto">{{'DMP-LISTING.VERSION' | translate}} {{activity.version}}</span>
<span>.</span>
<span class="col">{{ 'DMP-LISTING.GRANT' | translate }}: {{activity.grant}}</span>
@ -84,7 +82,7 @@
<button mat-menu-item (click)="viewVersions(getGroupId(activity), activity.title)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
</button>
<button mat-menu-item *ngIf="isUserOwner(activity) && !lockStatusMap.get(activity.id)" (click)="deleteClicked(activity)" class="menu-item">
<button mat-menu-item *ngIf="isUserOwner(activity)" (click)="deleteDmpClicked(activity)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }}
</button>
</mat-menu>
@ -105,8 +103,6 @@
<span *ngIf="activity.status === 1 && activity.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span *ngIf="activity.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span>.</span>
<span *ngIf="lockStatusMap.get(activity.id)" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatusMap.get(activity.id)">.</span>
<span class="col">{{'DATASET-LISTING.COLUMNS.GRANT' | translate}}: {{activity.grant}}</span>
</div>
<div class="d-flex flex-direction-row pt-3 pb-3">
@ -127,7 +123,7 @@
<button mat-menu-item (click)="openDmpSearchDialogue(activity)" class="menu-item">
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
</button>
<button mat-menu-item *ngIf="!lockStatusMap.get(activity.id)" (click)="openConfirm(activity.id)" class="menu-item">
<button mat-menu-item (click)="deleteDatasetClicked(activity.id)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}
</button>
<!-- <button mat-menu-item *ngIf="needsUpdate(activity)" class="menu-item" (click)="openUpdateDatasetProfileDialogue(activity.id);">

View File

@ -45,7 +45,6 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
allRecentActivities: RecentActivityModel[];
recentActivityTypeEnum = RecentActivityType;
isDraft: boolean;
lockStatusMap = new Map();
totalCount: number;
startIndex: number = 0;
dmpOffset: number = 0;
@ -88,12 +87,6 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
.subscribe(response => {
this.allRecentActivities = response;
this.allRecentActivities.forEach(recentActivity => {
let lockStatus: Boolean;
this.lockService.checkLockStatus(recentActivity.id).pipe(takeUntil(this._destroyed))
.subscribe(status => {
lockStatus = status;
this.lockStatusMap.set(recentActivity.id, lockStatus);
});
if (recentActivity.type === RecentActivityType.Dataset) {
this.datasetOffset = this.datasetOffset + 1;
} else if (recentActivity.type === RecentActivityType.Dmp) {
@ -153,7 +146,18 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
window.open(url.toString(), '_blank');
}
deleteClicked(dmp: DmpListingModel) {
deleteDmpClicked(dmp: DmpListingModel) {
this.lockService.checkLockStatus(dmp.id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => {
if (!lockStatus) {
this.openDeleteDmpDialog(dmp);
} else {
this.openDmpLockedByUserDialog();
}
});
}
openDeleteDmpDialog(dmp: DmpListingModel) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px',
restoreFocus: false,
@ -176,6 +180,16 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
});
}
openDmpLockedByUserDialog() {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '400px',
restoreFocus: false,
data: {
message: this.language.instant('DMP-EDITOR.ACTIONS.LOCK')
}
});
}
openShareDialog(rowId: any, rowName: any) {
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
// height: '250px',
@ -401,7 +415,18 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
});
}
openConfirm(id: string): void {
deleteDatasetClicked(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => {
if (!lockStatus) {
this.openDeleteDatasetDialog(id);
} else {
this.openDatasetLockedByUserDialog();
}
});
}
openDeleteDatasetDialog(id: string): void {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px',
restoreFocus: false,
@ -424,6 +449,16 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
});
}
openDatasetLockedByUserDialog() {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '400px',
restoreFocus: false,
data: {
message: this.language.instant('DATASET-WIZARD.ACTIONS.LOCK')
}
});
}
refresh(): void {
const fields: Array<string> = [];
// const fields: Array<string> = ["-modified"];

View File

@ -34,8 +34,6 @@
<span *ngIf="activity.status === 1 && activity.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span *ngIf="activity.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span>.</span>
<span *ngIf="lockStatusMap.get(activity.id)" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatusMap.get(activity.id)">.</span>
<span class="col">{{'DATASET-LISTING.COLUMNS.GRANT' | translate}}: {{activity.grant}}</span>
</div>
<div class="d-flex flex-direction-row pt-3 pb-3">
@ -56,7 +54,7 @@
<button mat-menu-item *ngIf="isAuthenticated()" (click)="openDmpSearchDialogue(activity)" class="menu-item">
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
</button>
<button mat-menu-item *ngIf="!lockStatusMap.get(activity.id)" (click)="openConfirm(activity.id)" class="menu-item">
<button mat-menu-item (click)="deleteClicked(activity.id)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}
</button>
<!-- <button mat-menu-item *ngIf="needsUpdate(activity)" class="menu-item" (click)="openUpdateDatasetProfileDialogue(activity.id);">

View File

@ -46,7 +46,6 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen
// publicMode = false;
order = RecentActivityOrder;
lockStatusMap = new Map();
constructor(
private authentication: AuthService,
@ -75,14 +74,6 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen
.getPaged(datasetDataTableRequest)
.subscribe(response => {
this.datasetActivities = response.data;
this.datasetActivities.forEach(recentActivity => {
let lockStatus: Boolean;
this.lockService.checkLockStatus(recentActivity.id).pipe(takeUntil(this._destroyed))
.subscribe(status => {
lockStatus = status;
this.lockStatusMap.set(recentActivity.id, lockStatus);
});
});
this.totalCount = response.totalCount;
this.totalCountDatasets.emit(this.datasetActivities.length);
});
@ -182,7 +173,18 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen
});
}
openConfirm(id: string): void {
deleteClicked(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => {
if (!lockStatus) {
this.openDeleteDialog(id);
} else {
this.openLockedByUserDialog();
}
});
}
openDeleteDialog(id: string): void {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px',
restoreFocus: false,
@ -205,6 +207,16 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen
});
}
openLockedByUserDialog() {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '400px',
restoreFocus: false,
data: {
message: this.language.instant('DATASET-WIZARD.ACTIONS.LOCK')
}
});
}
openShareDialog(dmpRowId: any, dmpRowName: any, activity: any) {
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
// height: '250px',

View File

@ -34,8 +34,6 @@
<span *ngIf="activity.status === 1 && activity.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span *ngIf="activity.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(activity.status) }}</span>
<span>.</span>
<span *ngIf="lockStatusMap.get(activity.id)" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatusMap.get(activity.id)">.</span>
<span class="col-auto">{{'DMP-LISTING.VERSION' | translate}} {{activity.version}}</span>
<span>.</span>
<span class="col">{{ 'DMP-LISTING.GRANT' | translate }}: {{activity.grant}}</span>
@ -83,7 +81,7 @@
<button mat-menu-item (click)="viewVersions(activity.groupId, activity.label)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
</button>
<button mat-menu-item *ngIf="isUserOwner(activity) && !lockStatusMap.get(activity.id)" (click)="deleteClicked()" class="menu-item">
<button mat-menu-item *ngIf="isUserOwner(activity)" (click)="deleteClicked(activity.id)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }}
</button>
</mat-menu>

View File

@ -38,7 +38,6 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
datasetActivities: DatasetListingModel[];
recentActivityTypeEnum = RecentActivityType;
isDraft: boolean;
lockStatusMap = new Map();
totalCount: number;
startIndex: number = 0;
@ -77,14 +76,6 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
.getPaged(dmpDataTableRequest, "listing")
.subscribe(response => {
this.dmpActivities = response.data;
this.dmpActivities.forEach(recentActivity => {
let lockStatus: Boolean;
this.lockService.checkLockStatus(recentActivity.id).pipe(takeUntil(this._destroyed))
.subscribe(status => {
lockStatus = status;
this.lockStatusMap.set(recentActivity.id, lockStatus);
});
});
this.totalCount = response.totalCount;
this.totalCountDmps.emit(this.dmpActivities.length);
// this.totalCount < this.pageSize ? this.totalCountDmps.emit(response.totalCount) : this.totalCountDmps.emit(this.pageSize);
@ -140,7 +131,18 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
window.open(url.toString(), '_blank');
}
deleteClicked(dmp: DmpListingModel) {
deleteClicked(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => {
if (!lockStatus) {
this.openDeleteDialog(id);
} else {
this.openLockedByUserDialog();
}
});
}
openDeleteDialog(id: string) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px',
restoreFocus: false,
@ -153,7 +155,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
this.dmpService.delete(dmp.id)
this.dmpService.delete(id)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onDeleteCallbackSuccess(),
@ -163,6 +165,16 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
});
}
openLockedByUserDialog() {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '400px',
restoreFocus: false,
data: {
message: this.language.instant('DMP-EDITOR.ACTIONS.LOCK')
}
});
}
openShareDialog(rowId: any, rowName: any) {
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
// height: '250px',

View File

@ -12,8 +12,6 @@
<span *ngIf="dataset.status === 1 && dataset.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(dataset.status) }}</span>
<span *ngIf="dataset.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(dataset.status) }}</span>
<span>.</span>
<span *ngIf="lockStatus" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatus">.</span>
<span class="col">{{'DATASET-LISTING.COLUMNS.GRANT' | translate}}: {{dataset.grant}}</span>
</div>
<div class="d-flex flex-direction-row pt-3 pb-3">
@ -34,7 +32,7 @@
<button *ngIf="isAuthenticated()" mat-menu-item (click)="openDmpSearchDialogue(dataset)" class="menu-item">
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
</button>
<button *ngIf="isUserDatasetRelated() && !lockStatus" mat-menu-item (click)="openConfirm(dataset.id)" class="menu-item">
<button *ngIf="isUserDatasetRelated()" mat-menu-item (click)="deleteClicked(dataset.id)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}
</button>
<!-- <button mat-menu-item *ngIf="needsUpdate(activity)" class="menu-item" (click)="openUpdateDatasetProfileDialogue(activity.id);">

View File

@ -35,7 +35,6 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit
isDraft: boolean;
isDeleted: boolean;
lockStatus: Boolean;
isUserOwner: boolean;
constructor(
@ -56,7 +55,6 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit
if (this.dataset.status === DatasetStatus.Draft) {
this.isDraft = true;
this.isDeleted = false;
this.checkLockStatus(this.dataset.id);
this.setIsUserOwner();
} else if (this.dataset.status === DatasetStatus.Deleted) {
this.isDeleted = true;
@ -68,11 +66,6 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit
}
}
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();
@ -181,7 +174,18 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit
});
}
openConfirm(id: string): void {
deleteClicked(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => {
if (!lockStatus) {
this.openDeleteDialog(id);
} else {
this.openLockedByUserDialog();
}
});
}
openDeleteDialog(id: string): void {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px',
restoreFocus: false,
@ -204,6 +208,16 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit
});
}
openLockedByUserDialog() {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '400px',
restoreFocus: false,
data: {
message: this.language.instant('DATASET-WIZARD.ACTIONS.LOCK')
}
});
}
reloadPage(): void {
const path = this.location.path();
this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => {
@ -250,14 +264,14 @@ export class DatasetListingItemComponent extends BaseComponent implements OnInit
const principal: Principal = this.authentication.current();
let isRelated: boolean = false;
if (this.dataset && principal) {
this.dataset.users.forEach(element => {
if (element.id === principal.id) {
isRelated = true;
}
})
this.dataset.users.forEach(element => {
if (element.id === principal.id) {
isRelated = true;
}
})
}
return isRelated;
}
}

View File

@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { BaseComponent } from '@common/base/base.component';
import { DatasetOverviewModel } from '@app/core/model/dataset/dataset-overview';
import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item';
import { Observable, of as observableOf, interval } from 'rxjs';
import { Observable, of as observableOf } from 'rxjs';
import { ActivatedRoute, Router, Params } from '@angular/router';
import { DatasetService } from '@app/core/services/dataset/dataset.service';
import { TranslateService } from '@ngx-translate/core';
@ -148,10 +148,7 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
checkLockStatus(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => {
this.lockStatus = lockStatus;
});
.subscribe(lockStatus => this.lockStatus = lockStatus);
}
onFetchingDeletedCallbackError(redirectRoot: string) {
@ -169,11 +166,9 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
}
reloadPage(): void {
const path = this.location.path();
this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => {
this.router.navigate([path]);
});
}
const path = this.location.path();
this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => this.router.navigate([path]));
}
getDmpResearchers() {
this.dmpService.getSingle(this.dataset.dmp.id).pipe(takeUntil(this._destroyed))
@ -269,10 +264,10 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
editClicked(dataset: DatasetOverviewModel) {
if (dataset.public) {
let url = this.router.createUrlTree(['/datasets/publicEdit/', dataset.id])
window.open(url.toString(), '_blank')
window.open(url.toString(), '_blank')
} else {
let url = this.router.createUrlTree(['/datasets/edit/', dataset.id])
window.open(url.toString(), '_blank')
window.open(url.toString(), '_blank')
}
}
@ -413,8 +408,8 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit {
.subscribe(result => {
if (result && result.datasetProfileExist) {
const newDmpId = result.formControl.value.id
let url = this.router.createUrlTree(['/datasets/copy/', result.datasetId, { newDmpId: newDmpId } ])
window.open(url.toString(), '_blank')
let url = this.router.createUrlTree(['/datasets/copy/', result.datasetId, { newDmpId: newDmpId }])
window.open(url.toString(), '_blank')
}
});
}

View File

@ -12,8 +12,6 @@
<span *ngIf="dmp.status === 1 && dmp.public === false" class="col-auto"><span class="material-icons icon-align">done</span>{{ enumUtils.toDmpStatusString(dmp.status) }}</span>
<span *ngIf="dmp.status === 0" class=" col-auto draft"><span class="material-icons icon-align">create</span>{{ enumUtils.toDmpStatusString(dmp.status) }}</span>
<span>.</span>
<span *ngIf="lockStatus" class="col-auto"><span class="material-icons icon-align">lock_outline</span>{{'DMP-OVERVIEW.LOCKED' | translate}}</span>
<span *ngIf="lockStatus">.</span>
<span class="col-auto">{{'DMP-LISTING.VERSION' | translate}} {{dmp.version}}</span>
<span>.</span>
<span class="col">{{ 'DMP-LISTING.GRANT' | translate }}: {{dmp.grant}}</span>
@ -61,7 +59,7 @@
<button mat-menu-item (click)="viewVersions(dmp.groupId, dmp.label)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
</button>
<button mat-menu-item *ngIf="isUserOwner(dmp) && !lockStatus" (click)="deleteClicked(dmp)" class="menu-item">
<button mat-menu-item *ngIf="isUserOwner(dmp)" (click)="deleteClicked(dmp.id)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DMP-LISTING.ACTIONS.DELETE' | translate }}
</button>
</mat-menu>

View File

@ -34,7 +34,6 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
isDraft: boolean;
isFinalized: boolean;
isPublished: boolean;
lockStatus: Boolean;
constructor(
private router: Router,
@ -46,15 +45,14 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
private uiNotificationService: UiNotificationService,
private lockService: LockService,
private location: Location) {
super();
}
super();
}
ngOnInit() {
if (this.dmp.status == DmpStatus.Draft) {
this.isDraft = true;
this.isFinalized = false;
this.isPublished = false;
this.checkLockStatus(this.dmp.id);
}
else if (this.dmp.status == DmpStatus.Finalized) {
this.isDraft = false;
@ -68,11 +66,6 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
return !(!this.authentication.current());
}
checkLockStatus(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => this.lockStatus = lockStatus);
}
openShareDialog(rowId: any, rowName: any) {
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
// height: '250px',
@ -216,7 +209,18 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
return filename;
}
deleteClicked(dmp: DmpListingModel) {
deleteClicked(id: string) {
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
.subscribe(lockStatus => {
if (!lockStatus) {
this.openDeleteDialog(id);
} else {
this.openLockedByUserDialog();
}
});
}
openDeleteDialog(id: string) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px',
restoreFocus: false,
@ -229,7 +233,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
this.dmpService.delete(dmp.id)
this.dmpService.delete(id)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onDeleteCallbackSuccess(),
@ -239,6 +243,16 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
});
}
openLockedByUserDialog() {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '400px',
restoreFocus: false,
data: {
message: this.language.instant('DMP-EDITOR.ACTIONS.LOCK')
}
});
}
isDraftDmp(activity: DmpListingModel) {
return activity.status == DmpStatus.Draft;
}