2023-12-01 18:18:41 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
|
|
|
// import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item';
|
|
|
|
import { Location } from '@angular/common';
|
2024-03-11 08:47:03 +01:00
|
|
|
import { UntypedFormBuilder, UntypedFormControl, Validators } from '@angular/forms';
|
2023-12-01 18:18:41 +01:00
|
|
|
import { MatDialog } from '@angular/material/dialog';
|
|
|
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
|
|
|
import { DescriptionStatus } from '@app/core/common/enum/description-status';
|
|
|
|
import { DmpAccessType } from '@app/core/common/enum/dmp-access-type';
|
|
|
|
import { DmpStatus } from '@app/core/common/enum/dmp-status';
|
|
|
|
import { DmpUserRole } from '@app/core/common/enum/dmp-user-role';
|
|
|
|
import { DescriptionTemplate } from '@app/core/model/description-template/description-template';
|
2023-12-06 22:10:01 +01:00
|
|
|
import { Description, DescriptionStatusPersist } from '@app/core/model/description/description';
|
2024-03-07 16:14:39 +01:00
|
|
|
import { Dmp, DmpDescriptionTemplate, DmpUser, DmpUserRemovePersist } from '@app/core/model/dmp/dmp';
|
2023-12-28 16:18:49 +01:00
|
|
|
import { DmpReference } from '@app/core/model/dmp/dmp-reference';
|
|
|
|
import { Reference } from '@app/core/model/reference/reference';
|
2023-12-01 18:18:41 +01:00
|
|
|
import { AuthService } from '@app/core/services/auth/auth.service';
|
|
|
|
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
|
|
|
import { DescriptionService } from '@app/core/services/description/description.service';
|
2023-12-29 16:04:16 +01:00
|
|
|
import { DmpService } from '@app/core/services/dmp/dmp.service';
|
|
|
|
import { FileTransformerService } from '@app/core/services/file-transformer/file-transformer.service';
|
2023-12-01 18:18:41 +01:00
|
|
|
import { MatomoService } from '@app/core/services/matomo/matomo-service';
|
|
|
|
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
2024-02-09 21:46:05 +01:00
|
|
|
import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service';
|
2023-12-01 18:18:41 +01:00
|
|
|
import { ReferenceService } from '@app/core/services/reference/reference.service';
|
2023-12-28 16:18:49 +01:00
|
|
|
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
2023-12-01 18:18:41 +01:00
|
|
|
import { FileUtils } from '@app/core/services/utilities/file-utils.service';
|
|
|
|
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
|
|
|
import { Guid } from '@common/types/guid';
|
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
2023-12-28 16:18:49 +01:00
|
|
|
import * as FileSaver from 'file-saver';
|
|
|
|
import { filter, takeUntil } from 'rxjs/operators';
|
2023-12-01 18:18:41 +01:00
|
|
|
import { nameof } from 'ts-simple-nameof';
|
|
|
|
import { DescriptionCopyDialogComponent } from '../description-copy-dialog/description-copy-dialog.component';
|
2024-03-06 17:41:26 +01:00
|
|
|
import { ReferenceType } from '@app/core/model/reference-type/reference-type';
|
2024-03-15 13:13:55 +01:00
|
|
|
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
2024-03-15 14:48:32 +01:00
|
|
|
import { DescriptionValidationOutput } from '@app/ui/dmp/dmp-finalize-dialog/dmp-finalize-dialog.component';
|
2024-03-21 12:06:59 +01:00
|
|
|
import { LockService } from '@app/core/services/lock/lock.service';
|
|
|
|
import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component';
|
2023-12-01 18:18:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-description-overview',
|
|
|
|
templateUrl: './description-overview.component.html',
|
|
|
|
styleUrls: ['./description-overview.component.scss']
|
|
|
|
})
|
|
|
|
export class DescriptionOverviewComponent extends BaseComponent implements OnInit {
|
|
|
|
|
2024-03-11 08:47:03 +01:00
|
|
|
description: any;
|
2023-12-01 18:18:41 +01:00
|
|
|
researchers: DmpReference[] = [];
|
|
|
|
isNew = true;
|
|
|
|
isFinalized = false;
|
|
|
|
isPublicView = true;
|
|
|
|
hasPublishButton: boolean = true;
|
|
|
|
// breadCrumbs: Observable<BreadcrumbItem[]> = observableOf();
|
|
|
|
expand = false;
|
2024-03-21 12:06:59 +01:00
|
|
|
isLocked: Boolean;
|
2023-12-01 18:18:41 +01:00
|
|
|
descriptionStatusEnum = DescriptionStatus;
|
|
|
|
dmpAccessTypeEnum = DmpAccessType;
|
2023-12-04 18:37:52 +01:00
|
|
|
dmpStatusEnum = DmpStatus;
|
|
|
|
dmpUserRoleEnum = DmpUserRole;
|
2023-12-01 18:18:41 +01:00
|
|
|
|
2024-03-15 13:13:55 +01:00
|
|
|
canEdit = false;
|
|
|
|
canDelete = false;
|
|
|
|
canFinalize = false;
|
|
|
|
canInviteDmpUsers = false;
|
|
|
|
|
2023-12-01 18:18:41 +01:00
|
|
|
constructor(
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private router: Router,
|
|
|
|
private descriptionService: DescriptionService,
|
|
|
|
private authentication: AuthService,
|
|
|
|
private dialog: MatDialog,
|
|
|
|
private language: TranslateService,
|
|
|
|
private uiNotificationService: UiNotificationService,
|
|
|
|
private configurationService: ConfigurationService,
|
2023-12-29 16:04:16 +01:00
|
|
|
private dmpService: DmpService,
|
2023-12-01 18:18:41 +01:00
|
|
|
public referenceService: ReferenceService,
|
|
|
|
private location: Location,
|
|
|
|
public enumUtils: EnumUtils,
|
|
|
|
private matomoService: MatomoService,
|
2023-12-29 16:04:16 +01:00
|
|
|
private fileUtils: FileUtils,
|
2024-03-15 13:13:55 +01:00
|
|
|
private authService: AuthService,
|
2024-02-09 21:46:05 +01:00
|
|
|
public fileTransformerService: FileTransformerService,
|
2024-03-11 08:47:03 +01:00
|
|
|
private referenceTypeService: ReferenceTypeService,
|
|
|
|
private fb: UntypedFormBuilder,
|
2024-03-21 12:06:59 +01:00
|
|
|
private lockService: LockService
|
2023-12-01 18:18:41 +01:00
|
|
|
) {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.matomoService.trackPageView('Description Overview');
|
2024-03-15 13:13:55 +01:00
|
|
|
this.canDelete = false;
|
|
|
|
this.canEdit = false;
|
|
|
|
this.canFinalize = false;
|
|
|
|
this.canInviteDmpUsers = false;
|
2023-12-01 18:18:41 +01:00
|
|
|
// Gets description data using parameter id
|
|
|
|
this.route.params
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe((params: Params) => {
|
|
|
|
const itemId = params['id'];
|
|
|
|
const publicId = params['publicId'];
|
|
|
|
if (itemId != null) {
|
|
|
|
this.isNew = false;
|
|
|
|
this.isPublicView = false;
|
|
|
|
this.descriptionService.getSingle(itemId, this.lookupFields())
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(data => {
|
|
|
|
this.description = data;
|
2024-02-09 21:46:05 +01:00
|
|
|
this.researchers = this.referenceService.getReferencesForTypes(this.description?.dmp?.dmpReferences, [this.referenceTypeService.getResearcherReferenceType()]);
|
2023-12-01 18:18:41 +01:00
|
|
|
// this.users = this.description.dmp.users;
|
|
|
|
this.checkLockStatus(this.description.id);
|
2024-03-15 13:13:55 +01:00
|
|
|
this.canDelete = this.authService.hasPermission(AppPermission.DeleteDescription) ||
|
|
|
|
this.description.authorizationFlags?.some(x => x === AppPermission.DeleteDescription);
|
|
|
|
|
|
|
|
this.canEdit = this.authService.hasPermission(AppPermission.EditDescription) ||
|
|
|
|
this.description.authorizationFlags?.some(x => x === AppPermission.EditDescription);
|
|
|
|
|
|
|
|
this.canFinalize = this.authService.hasPermission(AppPermission.FinalizeDescription) ||
|
|
|
|
this.description.authorizationFlags?.some(x => x === AppPermission.FinalizeDescription);
|
|
|
|
|
|
|
|
this.canInviteDmpUsers = this.authService.hasPermission(AppPermission.InviteDmpUsers) ||
|
|
|
|
this.description.dmp?.authorizationFlags?.some(x => x === AppPermission.InviteDmpUsers);
|
2023-12-01 18:18:41 +01:00
|
|
|
// const breadCrumbs = [];
|
|
|
|
// breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DESCRIPTION-DESCRIPTIONS'), url: "/descriptions" });
|
|
|
|
// breadCrumbs.push({ parentComponentName: 'DescriptionListingComponent', label: this.description.label, url: '/descriptions/overview/' + this.description.id });
|
|
|
|
// this.breadCrumbs = observableOf(breadCrumbs);
|
2024-03-15 13:13:55 +01:00
|
|
|
|
2023-12-01 18:18:41 +01:00
|
|
|
}, (error: any) => {
|
|
|
|
if (error.status === 404) {
|
|
|
|
return this.onFetchingDeletedCallbackError('/descriptions/');
|
|
|
|
}
|
|
|
|
if (error.status === 403) {
|
|
|
|
return this.onFetchingForbiddenCallbackError('/descriptions/');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (publicId != null) {
|
|
|
|
this.isNew = false;
|
|
|
|
this.isFinalized = true;
|
|
|
|
this.isPublicView = true;
|
|
|
|
this.descriptionService.getPublicSingle(publicId, this.lookupFields())
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(data => {
|
|
|
|
this.description = data;
|
2024-02-09 21:46:05 +01:00
|
|
|
this.researchers = this.referenceService.getReferencesForTypes(this.description?.dmp?.dmpReferences, [this.referenceTypeService.getResearcherReferenceType()]);
|
2023-12-01 18:18:41 +01:00
|
|
|
// this.users = this.description.dmp.users;
|
|
|
|
// const breadCrumbs = [];
|
|
|
|
// breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.PUBLIC DESCRIPTIONS'), url: "/explore" });
|
2023-12-20 08:20:38 +01:00
|
|
|
// breadCrumbs.push({ parentComponentName: 'DescriptionListingComponent', label: this.description.label, url: '/descriptions/overview/public/' + this.description.id });
|
2023-12-01 18:18:41 +01:00
|
|
|
// this.breadCrumbs = observableOf(breadCrumbs);
|
|
|
|
}, (error: any) => {
|
|
|
|
if (error.status === 404) {
|
|
|
|
return this.onFetchingDeletedCallbackError('/explore-descriptions');
|
|
|
|
}
|
|
|
|
if (error.status === 403) {
|
|
|
|
return this.onFetchingForbiddenCallbackError('/explore-descriptions');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
checkLockStatus(id: Guid) {
|
2024-03-21 12:06:59 +01:00
|
|
|
this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(lockStatus => {
|
|
|
|
this.isLocked = lockStatus.status;
|
|
|
|
if (this.isLocked) {
|
|
|
|
this.dialog.open(PopupNotificationDialogComponent, {
|
|
|
|
data: {
|
|
|
|
title: this.language.instant('DESCRIPTION-OVERVIEW.LOCKED-DIALOG.TITLE'),
|
|
|
|
message: this.language.instant('DESCRIPTION-OVERVIEW.LOCKED-DIALOG.MESSAGE')
|
|
|
|
}, maxWidth: '30em'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2023-12-01 18:18:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
onFetchingDeletedCallbackError(redirectRoot: string) {
|
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('DESCRIPTION-OVERVIEW.ERROR.DELETED-DESCRIPTION'), SnackBarNotificationLevel.Error);
|
|
|
|
this.router.navigate([redirectRoot]);
|
|
|
|
}
|
|
|
|
|
|
|
|
onFetchingForbiddenCallbackError(redirectRoot: string) {
|
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('DESCRIPTION-OVERVIEW.ERROR.FORBIDEN-DESCRIPTION'), SnackBarNotificationLevel.Error);
|
|
|
|
this.router.navigate([redirectRoot]);
|
|
|
|
}
|
|
|
|
|
|
|
|
goBack(): void {
|
|
|
|
this.location.back();
|
|
|
|
}
|
|
|
|
|
|
|
|
reloadPage(): void {
|
|
|
|
const path = this.location.path();
|
|
|
|
this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => this.router.navigate([path]));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
isUserAuthor(userId: Guid): boolean {
|
|
|
|
if (this.isAuthenticated()) {
|
|
|
|
const principalId: Guid = this.authentication.userId();
|
|
|
|
return userId === principalId;
|
|
|
|
} else return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
openShareDialog(rowId: any, rowName: any) {
|
|
|
|
// TODO: add dialog
|
|
|
|
// const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
|
|
|
|
// autoFocus: false,
|
|
|
|
// restoreFocus: false,
|
|
|
|
// data: {
|
|
|
|
// dmpId: rowId,
|
|
|
|
// dmpName: rowName
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
|
|
|
|
public isAuthenticated(): boolean {
|
|
|
|
return this.authentication.currentAccountIsAuthenticated();
|
|
|
|
}
|
|
|
|
|
|
|
|
isDraftDescription(description: Description) {
|
|
|
|
return description.status == DescriptionStatus.Draft;
|
|
|
|
}
|
|
|
|
|
|
|
|
editClicked(description: Description) {
|
|
|
|
if (description.status === DescriptionStatus.Finalized && description.dmp.accessType === DmpAccessType.Public) {
|
|
|
|
this.router.navigate(['/descriptions/publicEdit/', description.id]);
|
|
|
|
} else {
|
|
|
|
this.router.navigate(['/descriptions/edit/', description.id]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteClicked() {
|
|
|
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
|
|
|
maxWidth: '300px',
|
|
|
|
data: {
|
|
|
|
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
|
|
|
|
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'),
|
|
|
|
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
|
|
|
|
isDeleteConfirmation: true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
|
|
if (result) {
|
|
|
|
this.descriptionService.delete(this.description.id)
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(
|
|
|
|
complete => {
|
|
|
|
this.onDeleteCallbackSuccess();
|
|
|
|
},
|
|
|
|
error => this.onDeleteCallbackError(error)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
dmpClicked(dmp: Dmp) {
|
|
|
|
if (this.isPublicView) {
|
2023-12-20 08:20:38 +01:00
|
|
|
this.router.navigate(['/explore-plans/overview/public/' + dmp.id]);
|
2023-12-01 18:18:41 +01:00
|
|
|
} else {
|
|
|
|
this.router.navigate(['/plans/overview/' + dmp.id]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private onDeleteCallbackSuccess(): void {
|
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success);
|
|
|
|
this.router.navigate(['/descriptions']);
|
|
|
|
}
|
|
|
|
|
|
|
|
private onDeleteCallbackError(error) {
|
|
|
|
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
private onUpdateCallbackSuccess(): void {
|
|
|
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
|
|
|
this.reloadPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
private onUpdateCallbackError(error) {
|
|
|
|
this.uiNotificationService.snackBarNotification(error.error.message ? this.tryTranslate(error.error.message) : this.language.instant('DESCRIPTION-UPLOAD.SNACK-BAR.UNSUCCESSFUL'), SnackBarNotificationLevel.Error);
|
|
|
|
}
|
|
|
|
|
|
|
|
private tryTranslate(errorMessage: string): string {
|
|
|
|
return errorMessage.replace('Field value of', this.language.instant('Field value of'))
|
|
|
|
.replace('must be filled', this.language.instant('must be filled'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public getOrcidPath(): string {
|
|
|
|
return this.configurationService.orcidPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
isOrcid(reference: Reference) {
|
|
|
|
return reference.source === 'orcid';
|
|
|
|
}
|
|
|
|
|
|
|
|
getOrcidPathForResearcher(reference: string): string {
|
|
|
|
const path = this.getOrcidPath();
|
|
|
|
return path + reference;
|
|
|
|
}
|
|
|
|
|
2023-12-19 17:09:09 +01:00
|
|
|
// downloadPDF(id: string) {
|
|
|
|
// this.descriptionService.downloadPDF(id)
|
|
|
|
// .pipe(takeUntil(this._destroyed))
|
|
|
|
// .subscribe(response => {
|
|
|
|
// const blob = new Blob([response.body], { type: 'application/pdf' });
|
|
|
|
// const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
2023-12-18 11:55:19 +01:00
|
|
|
|
2023-12-19 17:09:09 +01:00
|
|
|
// FileSaver.saveAs(blob, filename);
|
|
|
|
// this.matomoService.trackDownload('descriptions', "pdf", id);
|
|
|
|
// });
|
|
|
|
// }
|
2023-12-01 18:18:41 +01:00
|
|
|
|
2023-12-19 17:09:09 +01:00
|
|
|
download(id: string, format: string) {
|
|
|
|
this.descriptionService.download(id, format)
|
2023-12-18 11:55:19 +01:00
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(response => {
|
2023-12-19 17:09:09 +01:00
|
|
|
const blob = new Blob([response.body], { type: 'application/octet-stream' });
|
2023-12-18 11:55:19 +01:00
|
|
|
const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
|
|
|
|
|
|
|
FileSaver.saveAs(blob, filename);
|
2023-12-19 17:09:09 +01:00
|
|
|
this.matomoService.trackDownload('descriptions', format, id);
|
2023-12-18 11:55:19 +01:00
|
|
|
});
|
2023-12-01 18:18:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
downloadXml(id: string) {
|
|
|
|
// TODO: add download
|
|
|
|
// this.descriptionService.downloadXML(id)
|
|
|
|
// .pipe(takeUntil(this._destroyed))
|
|
|
|
// .subscribe(response => {
|
|
|
|
// const blob = new Blob([response.body], { type: 'application/xml' });
|
|
|
|
// const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
|
|
|
|
|
|
|
// FileSaver.saveAs(blob, filename);
|
|
|
|
// this.matomoService.trackDownload('descriptions', "xml", id);
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
|
|
|
|
openCopyToDmpDialog() {
|
2024-03-11 08:47:03 +01:00
|
|
|
const formGroup = this.fb.group({
|
|
|
|
dmpId: this.fb.control(null, Validators.required),
|
|
|
|
sectionId: this.fb.control(null, Validators.required),
|
|
|
|
})
|
2023-12-01 18:18:41 +01:00
|
|
|
const dialogRef = this.dialog.open(DescriptionCopyDialogComponent, {
|
|
|
|
width: '500px',
|
|
|
|
restoreFocus: false,
|
|
|
|
data: {
|
2024-03-11 08:47:03 +01:00
|
|
|
formGroup: formGroup,
|
2023-12-01 18:18:41 +01:00
|
|
|
descriptionId: this.description.id,
|
2023-12-04 18:37:52 +01:00
|
|
|
descriptionTemplate: this.description.descriptionTemplate,
|
2024-03-07 16:14:39 +01:00
|
|
|
dmpDescriptionTemplate: this.description.dmpDescriptionTemplate,
|
2023-12-01 18:18:41 +01:00
|
|
|
descriptionProfileExist: false,
|
|
|
|
confirmButton: this.language.instant('DESCRIPTION-OVERVIEW.COPY-DIALOG.COPY'),
|
|
|
|
cancelButton: this.language.instant('DESCRIPTION-OVERVIEW.COPY-DIALOG.CANCEL')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed))
|
2024-03-11 08:47:03 +01:00
|
|
|
.subscribe(formGroup => {
|
|
|
|
if (formGroup) {
|
|
|
|
this.router.navigate(['descriptions/edit/copy/' + this.description.id + '/' + formGroup.get('dmpId').value + '/' + formGroup.get('sectionId').value]);
|
2023-12-01 18:18:41 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
removeUserFromDmp(dmpUser: DmpUser) {
|
|
|
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
|
|
|
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'),
|
|
|
|
isDeleteConfirmation: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialogRef.afterClosed().subscribe(result => {
|
|
|
|
if (result) {
|
2023-12-06 22:10:01 +01:00
|
|
|
const dmpUserRemovePersist: DmpUserRemovePersist = {
|
|
|
|
id: dmpUser.id,
|
|
|
|
dmpId: this.description.dmp.id,
|
|
|
|
role: dmpUser.role
|
|
|
|
};
|
|
|
|
this.dmpService.removeUser(dmpUserRemovePersist).pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(data => {
|
|
|
|
this.reloadPage();
|
|
|
|
}, (error: any) => {
|
|
|
|
//TODO: Error handling
|
|
|
|
});
|
|
|
|
|
2023-12-01 18:18:41 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
finalize(description: Description) {
|
|
|
|
|
2024-03-15 14:48:32 +01:00
|
|
|
this.descriptionService.validate([description.id]).pipe(takeUntil(this._destroyed)
|
|
|
|
).subscribe(result => {
|
|
|
|
if (result[0].result == DescriptionValidationOutput.Invalid){
|
|
|
|
this.router.navigate(['descriptions/edit/' + description.id + '/finalize']);
|
|
|
|
}else{
|
|
|
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
|
|
|
restoreFocus: false,
|
|
|
|
data: {
|
|
|
|
message: this.language.instant('DESCRIPTION-OVERVIEW.FINALIZE-DIALOG.TITLE'),
|
|
|
|
confirmButton: this.language.instant('DESCRIPTION-OVERVIEW.FINALIZE-DIALOG.CONFIRM'),
|
|
|
|
cancelButton: this.language.instant('DESCRIPTION-OVERVIEW.FINALIZE-DIALOG.NEGATIVE'),
|
|
|
|
isDeleteConfirmation: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
|
|
if (result) {
|
|
|
|
const descriptionStatusPersist: DescriptionStatusPersist = {
|
|
|
|
id: description.id,
|
|
|
|
status: DescriptionStatus.Finalized,
|
|
|
|
hash: description.hash
|
|
|
|
};
|
|
|
|
this.descriptionService.persistStatus(descriptionStatusPersist).pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(data => {
|
|
|
|
this.reloadPage();
|
|
|
|
this.onUpdateCallbackSuccess()
|
|
|
|
}, (error: any) => {
|
|
|
|
this.onUpdateCallbackError(error)
|
|
|
|
});
|
|
|
|
}});
|
|
|
|
}
|
|
|
|
});
|
2023-12-01 18:18:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hasReversableStatus(description: Description): boolean {
|
|
|
|
return description.dmp.status == DmpStatus.Draft && description.status == DescriptionStatus.Finalized
|
|
|
|
}
|
|
|
|
|
2023-12-06 22:10:01 +01:00
|
|
|
reverseFinalization(description: Description) {
|
2023-12-01 18:18:41 +01:00
|
|
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
|
|
|
restoreFocus: false,
|
|
|
|
data: {
|
|
|
|
message: this.language.instant('DESCRIPTION-OVERVIEW.UNDO-FINALIZATION-DIALOG.TITLE'),
|
|
|
|
confirmButton: this.language.instant('DESCRIPTION-OVERVIEW.UNDO-FINALIZATION-DIALOG.CONFIRM'),
|
2024-03-14 08:36:07 +01:00
|
|
|
cancelButton: this.language.instant('DESCRIPTION-OVERVIEW.UNDO-FINALIZATION-DIALOG.NEGATIVE'),
|
2023-12-01 18:18:41 +01:00
|
|
|
isDeleteConfirmation: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
|
|
|
if (result) {
|
2023-12-06 22:10:01 +01:00
|
|
|
const dmpUserRemovePersist: DescriptionStatusPersist = {
|
|
|
|
id: description.id,
|
|
|
|
status: DescriptionStatus.Draft,
|
|
|
|
hash: description.hash
|
|
|
|
};
|
|
|
|
this.descriptionService.persistStatus(dmpUserRemovePersist).pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(data => {
|
|
|
|
this.reloadPage();
|
|
|
|
this.onUpdateCallbackSuccess()
|
|
|
|
}, (error: any) => {
|
|
|
|
this.onUpdateCallbackError(error)
|
|
|
|
});
|
2023-12-01 18:18:41 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private lookupFields(): string[] {
|
|
|
|
return [
|
|
|
|
nameof<Description>(x => x.id),
|
|
|
|
nameof<Description>(x => x.label),
|
2024-03-06 17:41:26 +01:00
|
|
|
nameof<Description>(x => x.description),
|
2023-12-01 18:18:41 +01:00
|
|
|
nameof<Description>(x => x.status),
|
|
|
|
nameof<Description>(x => x.updatedAt),
|
2024-03-14 08:36:07 +01:00
|
|
|
nameof<Description>(x => x.hash),
|
2024-03-15 13:13:55 +01:00
|
|
|
|
|
|
|
[nameof<Description>(x => x.authorizationFlags), AppPermission.EditDescription].join('.'),
|
|
|
|
[nameof<Description>(x => x.authorizationFlags), AppPermission.DeleteDescription].join('.'),
|
|
|
|
[nameof<Description>(x => x.authorizationFlags), AppPermission.FinalizeDescription].join('.'),
|
|
|
|
|
2023-12-01 18:18:41 +01:00
|
|
|
[nameof<Description>(x => x.descriptionTemplate), nameof<DescriptionTemplate>(x => x.id)].join('.'),
|
|
|
|
[nameof<Description>(x => x.descriptionTemplate), nameof<DescriptionTemplate>(x => x.label)].join('.'),
|
2023-12-04 18:37:52 +01:00
|
|
|
[nameof<Description>(x => x.descriptionTemplate), nameof<DescriptionTemplate>(x => x.groupId)].join('.'),
|
2024-03-07 16:14:39 +01:00
|
|
|
[nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.id)].join('.'),
|
|
|
|
[nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.dmp), nameof<Dmp>(x => x.id)].join('.'),
|
|
|
|
[nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'),
|
2023-12-01 18:18:41 +01:00
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.id)].join('.'),
|
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.label)].join('.'),
|
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.accessType)].join('.'),
|
2024-03-14 08:36:07 +01:00
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.status)].join('.'),
|
2024-03-15 13:13:55 +01:00
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.authorizationFlags),AppPermission.InviteDmpUsers].join('.'),
|
2023-12-01 18:18:41 +01:00
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.id)].join('.'),
|
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.user.id)].join('.'),
|
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.user.name)].join('.'),
|
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.role)].join('.'),
|
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.id)].join('.'),
|
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.id)].join('.'),
|
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.label)].join('.'),
|
2024-03-06 17:41:26 +01:00
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.type), nameof<ReferenceType>(x => x.id)].join('.'),
|
2023-12-01 18:18:41 +01:00
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.source)].join('.'),
|
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.reference)].join('.'),
|
2024-03-11 14:20:09 +01:00
|
|
|
[nameof<Description>(x => x.dmp), nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.isActive)].join('.'),
|
2023-12-01 18:18:41 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|