From 7c9e36341b5901645a52bd66d2574144a41d4989 Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Mon, 4 Dec 2023 17:56:12 +0200 Subject: [PATCH] more ui changes --- .../java/eu/eudat/data/DescriptionEntity.java | 3 +- .../eu/eudat/model/builder/DmpBuilder.java | 3 +- .../java/eu/eudat/query/DescriptionQuery.java | 17 + .../src/app/core/common/enum/entity-type.ts | 3 + dmp-frontend/src/app/core/model/dmp/dmp.ts | 2 + .../app/core/model/entity-doi/entity-doi.ts | 11 + .../src/app/core/services/dmp/dmp.service.ts | 9 + .../listing/description-listing.component.ts | 4 + .../dmp-listing-item.component.html | 6 +- .../dmp-listing-item.component.ts | 23 +- .../dmp/overview/dmp-overview.component.html | 248 +---- .../ui/dmp/overview/dmp-overview.component.ts | 939 +++++++----------- 12 files changed, 436 insertions(+), 832 deletions(-) create mode 100644 dmp-frontend/src/app/core/common/enum/entity-type.ts create mode 100644 dmp-frontend/src/app/core/model/entity-doi/entity-doi.ts diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java index 2ff4040e4..379cb67ed 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java @@ -78,14 +78,13 @@ public class DescriptionEntity implements DataEntity { @Column(name = "dmp", columnDefinition = "uuid", nullable = false) private UUID dmpId; + public static final String _dmpId = "dmpId"; @Column(name = "description_template", columnDefinition = "uuid", nullable = false) private UUID descriptionTemplateId; - public static final String _descriptionTemplateId = "descriptionTemplateId"; - public static final String _dmpId = "dmpId"; public UUID getId() { return id; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBuilder.java index f88bdc3da..33470d18f 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBuilder.java @@ -203,8 +203,7 @@ public class DmpBuilder extends BaseBuilder { Map> itemMap; FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(Description._dmp, Dmp._id)); - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).ids(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); - DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(this.authorize).dmpSubQuery(dmpQuery); + DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList())); itemMap = this.builderFactory.builder(DescriptionBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId()); if (!fields.hasField(this.asIndexer(Description._dmp, Dmp._id))) { diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java index 7966001e2..1cf29dd15 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java @@ -43,6 +43,7 @@ public class DescriptionQuery extends QueryBase { private Collection isActives; private Collection statuses; + private Collection dmpIds; private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @@ -152,6 +153,16 @@ public class DescriptionQuery extends QueryBase { return this; } + public DescriptionQuery dmpIds(Collection values) { + this.dmpIds = values; + return this; + } + + public DescriptionQuery dmpIds(UUID value) { + this.dmpIds = List.of(value); + return this; + } + public DescriptionQuery authorize(EnumSet values) { this.authorize = values; return this; @@ -225,6 +236,12 @@ public class DescriptionQuery extends QueryBase { notInClause.value(item); predicates.add(notInClause.not()); } + if (this.dmpIds != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpId)); + for (UUID item : this.dmpIds) + inClause.value(item); + predicates.add(inClause); + } if (this.isActives != null) { CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._isActive)); for (IsActive item : this.isActives) diff --git a/dmp-frontend/src/app/core/common/enum/entity-type.ts b/dmp-frontend/src/app/core/common/enum/entity-type.ts new file mode 100644 index 000000000..536bb62c5 --- /dev/null +++ b/dmp-frontend/src/app/core/common/enum/entity-type.ts @@ -0,0 +1,3 @@ +export enum EntityType { + DMP = 0, +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/model/dmp/dmp.ts b/dmp-frontend/src/app/core/model/dmp/dmp.ts index 71623e7b6..3d5a18cf6 100644 --- a/dmp-frontend/src/app/core/model/dmp/dmp.ts +++ b/dmp-frontend/src/app/core/model/dmp/dmp.ts @@ -18,6 +18,7 @@ import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; import { Guid } from '@common/types/guid'; import { DescriptionTemplate } from '../description-template/description-template'; +import { EntityDoi } from '../entity-doi/entity-doi'; export interface DmpModel { //TODO: Delete id: string; @@ -70,6 +71,7 @@ export interface Dmp extends BaseEntity { dmpReferences: DmpReference[]; dmpUsers: DmpUser[]; descriptions: Description[]; + entityDois: EntityDoi[]; // TODO: delete diff --git a/dmp-frontend/src/app/core/model/entity-doi/entity-doi.ts b/dmp-frontend/src/app/core/model/entity-doi/entity-doi.ts new file mode 100644 index 000000000..ea2951052 --- /dev/null +++ b/dmp-frontend/src/app/core/model/entity-doi/entity-doi.ts @@ -0,0 +1,11 @@ +import { EntityType } from "@app/core/common/enum/entity-type"; +import { BaseEntity } from "@common/base/base-entity.model"; +import { Guid } from "@common/types/guid"; + +export interface EntityDoi extends BaseEntity { + id: Guid; + entityType: EntityType; + entityId: Guid; + repositoryId: string; + doi: string; +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts index 95543b769..5e4a57c66 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts @@ -64,6 +64,15 @@ export class DmpServiceNew { catchError((error: any) => throwError(error))); } + getPublicSingle(id: Guid, reqFields: string[] = []): Observable { //TODO: add this to backend. + const url = `${this.apiBase}/public/${id}`; + const options = { params: { f: reqFields } }; + + return this.http + .get(url, options).pipe( + catchError((error: any) => throwError(error))); + } + persist(item: DmpPersist): Observable { const url = `${this.apiBase}/persist`; diff --git a/dmp-frontend/src/app/ui/description/listing/description-listing.component.ts b/dmp-frontend/src/app/ui/description/listing/description-listing.component.ts index 9bb492566..51cb0c6d5 100644 --- a/dmp-frontend/src/app/ui/description/listing/description-listing.component.ts +++ b/dmp-frontend/src/app/ui/description/listing/description-listing.component.ts @@ -7,6 +7,7 @@ import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; import { ActivatedRoute, Params, Router } from '@angular/router'; import { DescriptionStatus } from '@app/core/common/enum/description-status'; +import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; @@ -106,6 +107,9 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit this.dmpId = queryParams['dmpId']; this.status = queryParams['status']; + this.lookup.dmpSubQuery = new DmpLookup(); + this.lookup.dmpSubQuery.statuses = [DmpStatus.Draft]; + this.lookup.page = { size: this.pageSize, offset: 0 }; this.lookup.order = { items: ['-' + nameof(x => x.updatedAt)] }; this.lookup.metadata = { countAll: true }; diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html index 9b369b991..afb2be780 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html @@ -17,15 +17,15 @@ . {{ 'DMP-LISTING.GRANT' | translate }}: {{referenceService.getReferencesForTypesFirstSafe(dmp?.dmpReferences, [referenceTypeEnum.Grants])?.reference?.label}} -
{{'DMP-LISTING.CONTAINED-DESCRIPTIONS' | translate}}: ({{ dmp.descriptions.length }}) +
{{'DMP-LISTING.CONTAINED-DESCRIPTIONS' | translate}}: ({{ dmp.descriptions?.length }})
-
+
{{description.label}},
{{description.label}}
- {{'GENERAL.ACTIONS.SHOW-MORE' | translate}} + {{'GENERAL.ACTIONS.SHOW-MORE' | translate}}
open_in_new{{'DMP-LISTING.ACTIONS.EXPORT' | translate}} diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts index e2a836dfe..9c78c9e04 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts @@ -1,42 +1,29 @@ import { Location } from '@angular/common'; import { HttpClient } from '@angular/common/http'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { UntypedFormGroup } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; -import { DmpBlueprintSectionFieldCategory } from '@app/core/common/enum/dmp-blueprint-section-field-category'; -import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type'; -import { Role } from '@app/core/common/enum/role'; +import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; +import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; +import { ReferenceType } from '@app/core/common/enum/reference-type'; import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; -import { Dmp, DmpModel } from '@app/core/model/dmp/dmp'; +import { Dmp } from '@app/core/model/dmp/dmp'; import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; import { DmpService } from '@app/core/services/dmp/dmp.service'; import { LockService } from '@app/core/services/lock/lock.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; +import { ReferenceService } from '@app/core/services/reference/reference.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; import { BaseComponent } from '@common/base/base.component'; import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; import { Guid } from '@common/types/guid'; import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; import { map, takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; import { DmpStatus } from '../../../../core/common/enum/dmp-status'; import { AuthService } from '../../../../core/services/auth/auth.service'; -import { CloneDialogComponent } from '../../clone/clone-dialog/clone-dialog.component'; -import { DmpEditorModel } from '../../editor/dmp-editor.model'; -import { ExtraPropertiesFormModel } from '../../editor/general-tab/extra-properties-form.model'; -import { FunderFormModel } from '../../editor/grant-tab/funder-form-model'; -import { GrantTabModel } from '../../editor/grant-tab/grant-tab-model'; -import { ProjectFormModel } from '../../editor/grant-tab/project-form-model'; -import { DmpInvitationDialogComponent } from '../../invitation/dmp-invitation-dialog.component'; -import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; -import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; -import { ReferenceType } from '@app/core/common/enum/reference-type'; -import { ReferenceService } from '@app/core/services/reference/reference.service'; @Component({ selector: 'app-dmp-listing-item-component', diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html index a29352f1a..3f0bca21b 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html @@ -12,24 +12,16 @@

{{ dmp.label }}

-
+

- {{ roleDisplayFromList(dmp.users) }}

+ {{ enumUtils.toDmpUserRolesString(dmpService.getCurrentUserRolesInDmp(dmp?.dmpUsers)) }}
- . - - + .
public {{'DMP-OVERVIEW.PUBLIC' | translate}}
. - -
lock_outline {{'DMP-OVERVIEW.LOCKED' | translate}} @@ -139,24 +131,6 @@
-
@@ -170,7 +144,7 @@
-
+
@@ -190,12 +164,6 @@

{{ 'DMP-LISTING.ACTIONS.START-NEW-VERSION' | translate }}

-
@@ -246,208 +214,4 @@
- - - - - - - - - - - + \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts index fd76aef2b..d5782a629 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts @@ -5,10 +5,9 @@ import { DatasetStatus } from '@app/core/common/enum/dataset-status'; import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { DatasetOverviewModel } from '@app/core/model/dataset/dataset-overview'; import { DatasetsToBeFinalized } from '@app/core/model/dataset/datasets-toBeFinalized'; -import { DmpOverviewModel } from '@app/core/model/dmp/dmp-overview'; import { UserInfoListingModel } from '@app/core/model/user/user-info-listing'; import { AuthService } from '@app/core/services/auth/auth.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; +import { DmpService, DmpServiceNew } from '@app/core/services/dmp/dmp.service'; import { SnackBarNotificationLevel, UiNotificationService @@ -27,7 +26,7 @@ import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint import { Role } from "@app/core/common/enum/role"; import { DepositConfigurationModel } from '@app/core/model/deposit/deposit-configuration'; import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; -import { DmpModel } from '@app/core/model/dmp/dmp'; +import { Dmp, Dmp, DmpUser } from '@app/core/model/dmp/dmp'; import { DoiModel } from '@app/core/model/doi/doi'; import { VersionListingModel } from '@app/core/model/version/version-listing.model'; import { ConfigurationService } from '@app/core/services/configuration/configuration.service'; @@ -53,6 +52,10 @@ import { GrantTabModel } from '../editor/grant-tab/grant-tab-model'; import { ProjectFormModel } from '../editor/grant-tab/project-form-model'; import { DmpInvitationDialogComponent } from '../invitation/dmp-invitation-dialog.component'; import { StartNewDmpDialogComponent } from '../start-new-dmp-dialogue/start-new-dmp-dialog.component'; +import { EntityDoi } from '@app/core/model/entity-doi/entity-doi'; +import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; +import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; +import { Description } from '@app/core/model/description/description'; @Component({ selector: 'app-dmp-overview', @@ -61,20 +64,18 @@ import { StartNewDmpDialogComponent } from '../start-new-dmp-dialogue/start-new- }) export class DmpOverviewComponent extends BaseComponent implements OnInit { - dmp: DmpOverviewModel; - dmpModel: DmpEditorModel; + dmp: Dmp; isNew = true; isFinalized = false; isPublicView = true; hasPublishButton: boolean = true; // breadCrumbs: Observable = observableOf(); isUserOwner: boolean; - expand = false; lockStatus: Boolean; textMessage: any; versions: VersionListingModel[]; version: VersionListingModel; - selectedModel: DoiModel; + selectedModel: EntityDoi; @ViewChild('doi') doi: ElementRef; @@ -86,7 +87,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { constructor( private route: ActivatedRoute, private router: Router, - private dmpService: DmpService, + private dmpService: DmpServiceNew, private dmpBlueprintService: DmpBlueprintService, private depositRepositoriesService: DepositRepositoriesService, private translate: TranslateService, @@ -114,12 +115,12 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { if (itemId != null) { this.isNew = false; this.isPublicView = false; - this.dmpService.getOverviewSingle(itemId) + this.dmpService.getSingle(itemId, this.lookupFields()) .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.dmp = data; if (!this.hasDoi()) { - this.selectedModel = this.dmp.dois[0]; + this.selectedModel = this.dmp.entityDois[0]; } this.checkLockStatus(this.dmp.id); this.setIsUserOwner(); @@ -141,12 +142,12 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { this.isNew = false; this.isFinalized = true; this.isPublicView = true; - this.dmpService.getOverviewSinglePublic(publicId) + this.dmpService.getPublicSingle(itemId, this.lookupFields()) .pipe(takeUntil(this._destroyed)) .subscribe(data => { this.dmp = data; if (!this.hasDoi()) { - this.selectedModel = this.dmp.dois[0]; + this.selectedModel = this.dmp.entityDois[0]; } // this.checkLockStatus(this.dmp.id); this.getAllVersions(this.dmp); @@ -185,204 +186,134 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { setIsUserOwner() { if (this.dmp) { - const principalId: string = this.authentication.userId()?.toString(); - if (principalId) this.isUserOwner = !!this.dmp.users.find(x => (x.role === Role.Owner) && (principalId === x.id)); + const principalId: Guid = this.authentication.userId(); + if (principalId) this.isUserOwner = !!this.dmp.dmpUsers.find(x => (x.role === DmpUserRole.Owner) && (principalId === x.id)); } } - isUserAuthor(userId: string): boolean { + isUserAuthor(userId: Guid): boolean { if (this.isAuthenticated()) { - return userId === this.authentication.userId()?.toString(); + const principalId: Guid = this.authentication.userId(); + return userId === principalId; } else return false; } - editClicked(dmp: DmpOverviewModel) { + editClicked(dmp: Dmp) { this.router.navigate(['/plans/edit/', dmp.id]); - // let url = this.router.createUrlTree(['/plans/edit/', dmp.id]); - // window.open(url.toString(), '_blank'); } - cloneOrNewVersionClicked(dmp: DmpOverviewModel, isNewVersion: boolean) { - this.dmpService.getSingle(this.dmp.id).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.dmpModel = new DmpEditorModel(); - this.dmpModel.grant = new GrantTabModel(); - this.dmpModel.project = new ProjectFormModel(); - this.dmpModel.funder = new FunderFormModel(); - this.dmpModel.extraProperties = new ExtraPropertiesFormModel(); - this.dmpModel.fromModel(data); - this.dmpModel.status = DmpStatus.Draft; - this.formGroup = this.dmpModel.buildForm(); + cloneOrNewVersionClicked(dmp: Dmp, isNewVersion: boolean) { + //TODO: split the logic here to new version and clone seperately + // this.dmpService.getSingle(this.dmp.id).pipe(map(data => data as Dmp)) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { + // this.dmp = new DmpEditorModel(); + // this.dmp.grant = new GrantTabModel(); + // this.dmp.project = new ProjectFormModel(); + // this.dmp.funder = new FunderFormModel(); + // this.dmp.extraProperties = new ExtraPropertiesFormModel(); + // this.dmp.fromModel(data); + // this.dmp.status = DmpStatus.Draft; + // this.formGroup = this.dmp.buildForm(); - if (!isNullOrUndefined(this.formGroup.get('profile').value)) { - this.getBlueprintDefinition(Guid.parse(this.formGroup.get('profile').value), result => { - this.checkForGrant(result.definition); - this.checkForFunder(result.definition); - this.checkForProject(result.definition); - }); - } + // if (!isNullOrUndefined(this.formGroup.get('profile').value)) { + // this.getBlueprintDefinition(Guid.parse(this.formGroup.get('profile').value), result => { + // this.checkForGrant(result.definition); + // this.checkForFunder(result.definition); + // this.checkForProject(result.definition); + // }); + // } - if (!isNewVersion) { - this.formGroup.get('label').setValue(this.dmp.label + " New"); - } - this.openCloneDialog(isNewVersion); - }); + // if (!isNewVersion) { + // this.formGroup.get('label').setValue(this.dmp.label + " New"); + // } + // this.openCloneDialog(isNewVersion); + // }); } - private getBlueprintDefinition(blueprintId: Guid, successFunction) { - this.dmpBlueprintService.getSingle(blueprintId, [ - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), + // private checkForGrant(blueprint: DmpBlueprintDefinition) { + // let hasGrant = false; + // blueprint.sections.forEach(section => section.fields.forEach( + // field => { + // if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.GRANT) { + // hasGrant = true; + // } + // } + // )); + // if (!hasGrant) { + // this.formGroup.removeControl('grant'); + // } + // } - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.placeholder)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), + // private checkForFunder(blueprint: DmpBlueprintDefinition) { + // let hasFunder = false; + // blueprint.sections.forEach(section => section.fields.forEach( + // field => { + // if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.FUNDER) { + // hasFunder = true; + // } + // } + // )); + // if (!hasFunder) { + // this.formGroup.removeControl('funder'); + // } + // } - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), - ] - ) - .pipe(map(data => data as DmpBlueprint), takeUntil(this._destroyed)) - .subscribe( - data => successFunction(data), - error => this.onCallbackError(error) - ); - } + // private checkForProject(blueprint: DmpBlueprintDefinition) { + // let hasProject = false; + // blueprint.sections.forEach(section => section.fields.forEach( + // field => { + // if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.PROJECT) { + // hasProject = true; + // } + // } + // )); + // if (!hasProject) { + // this.formGroup.removeControl('project'); + // } + // } - private checkForGrant(blueprint: DmpBlueprintDefinition) { - let hasGrant = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.GRANT) { - hasGrant = true; - } - } - )); - if (!hasGrant) { - this.formGroup.removeControl('grant'); - } - } + // openCloneDialog(isNewVersion: boolean) { + // const dialogRef = this.dialog.open(CloneDialogComponent, { + // maxWidth: '900px', + // maxHeight: '80vh', + // data: { + // formGroup: this.formGroup, + // datasets: this.dmp.datasets, + // isNewVersion: isNewVersion, + // confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.SAVE'), + // cancelButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CANCEL'), + // } + // }); + // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { + // if (result) { + // if (!isNewVersion) { + // this.dmpService.clone(this.formGroup.getRawValue(), this.dmp.id) + // .pipe(takeUntil(this._destroyed)) + // .subscribe( + // complete => this.onCallbackSuccess(complete), + // error => this.onCallbackError(error) + // ); + // } else if (isNewVersion) { + // this.dmpService.newVersion(this.formGroup.getRawValue(), this.dmp.id) + // .pipe(takeUntil(this._destroyed)) + // .subscribe( + // complete => this.onCallbackSuccess(complete), + // error => this.onCallbackError(error) + // ); + // } + // } + // }); + // } - private checkForFunder(blueprint: DmpBlueprintDefinition) { - let hasFunder = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.FUNDER) { - hasFunder = true; - } - } - )); - if (!hasFunder) { - this.formGroup.removeControl('funder'); - } - } + // onCallbackSuccess(dmpId: String): void { + // this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); + // this.router.navigate(['/plans/edit/', dmpId]); + // } - private checkForProject(blueprint: DmpBlueprintDefinition) { - let hasProject = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.PROJECT) { - hasProject = true; - } - } - )); - if (!hasProject) { - this.formGroup.removeControl('project'); - } - } - - openCloneDialog(isNewVersion: boolean) { - const dialogRef = this.dialog.open(CloneDialogComponent, { - maxWidth: '900px', - maxHeight: '80vh', - data: { - formGroup: this.formGroup, - datasets: this.dmp.datasets, - isNewVersion: isNewVersion, - confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.SAVE'), - cancelButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CANCEL'), - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - if (!isNewVersion) { - this.dmpService.clone(this.formGroup.getRawValue(), this.dmp.id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCallbackSuccess(complete), - error => this.onCallbackError(error) - ); - } else if (isNewVersion) { - this.dmpService.newVersion(this.formGroup.getRawValue(), this.dmp.id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCallbackSuccess(complete), - error => this.onCallbackError(error) - ); - } - } - }); - } - - onCallbackSuccess(dmpId: String): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/plans/edit/', dmpId]); - } - - onCallbackError(error: any) { - this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Error); - } - - grantClicked(grantId: String) { - // ----------- UNCOMMENT TO ADD AGAIN GRANTS -------- - // this.router.navigate(['/grants/edit/' + grantId]); - } - - expandDesc() { - this.expand = !this.expand; - } - - checkOverflow(element) { - if (this.expand || (element.offsetHeight < element.scrollHeight || - element.offsetWidth < element.scrollWidth)) { - return true; - } else { - return false; - } - } - - datasetClicked(datasetId: String) { - // if (this.isPublicView) { - // this.router.navigate(['/datasets/publicEdit/' + datasetId]); - // } else { - // this.router.navigate(['/datasets/edit/' + datasetId]); - // } - this.router.navigate(['/datasets/overview/' + datasetId]); - } - - datasetsClicked(dmpId: String) { - if (!this.isFinalized) - this.router.navigate(['/plans/edit/' + dmpId], { queryParams: { tab: "datasetDescriptions" } }); - else - this.router.navigate(['/explore-descriptions'], { queryParams: { dmpId: dmpId } }); - } - - goToUri(uri: string) { - window.open(uri, "_blank"); - } + // onCallbackError(error: any) { + // this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Error); + // } deleteClicked() { const dialogRef = this.dialog.open(ConfirmationDialogComponent, { @@ -425,285 +356,207 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { } downloadXml(id: string) { - this.dmpService.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')); + // this.dmpService.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('dmps', "xml", id); - }); + // FileSaver.saveAs(blob, filename); + // this.matomoService.trackDownload('dmps', "xml", id); + // }); } downloadDocx(id: string) { - this.dmpService.downloadDocx(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/msword' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); + //TODO: add this + // this.dmpService.downloadDocx(id) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(response => { + // const blob = new Blob([response.body], { type: 'application/msword' }); + // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "docx", id); - }); + // FileSaver.saveAs(blob, filename); + // this.matomoService.trackDownload('dmps', "docx", id); + // }); } downloadPDF(id: string) { - this.dmpService.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')); + //TODO: add this + // this.dmpService.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')); - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "pdf", id); - }); + // FileSaver.saveAs(blob, filename); + // this.matomoService.trackDownload('dmps', "pdf", id); + // }); } downloadJson(id: string) { - this.dmpService.downloadJson(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(complete => { - const blob = new Blob([complete.body], { type: 'application/json' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(complete.headers.get('Content-Disposition')); - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "json", id); - }, async error => { - this.onExportCallbackError(error); - }); + //TODO: add this + // this.dmpService.downloadJson(id) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(complete => { + // const blob = new Blob([complete.body], { type: 'application/json' }); + // const filename = this.fileUtils.getFilenameFromContentDispositionHeader(complete.headers.get('Content-Disposition')); + // FileSaver.saveAs(blob, filename); + // this.matomoService.trackDownload('dmps', "json", id); + // }, async error => { + // this.onExportCallbackError(error); + // }); } - async onExportCallbackError(error: any) { - const errorJsonText = await error.error.text(); - const errorObj = JSON.parse(errorJsonText); - this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error); + // async onExportCallbackError(error: any) { + // const errorJsonText = await error.error.text(); + // const errorObj = JSON.parse(errorJsonText); + // this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error); + // } + + isUserDmpRelated(): boolean { + const principalId: Guid = this.authentication.userId(); + return this.dmp.dmpUsers.some(x => (x.user.id === principalId)); } - roleDisplayFromList(value: UserInfoListingModel[]) { - const principalId: string = this.authentication.userId()?.toString(); - let role: number; - if (principalId) { - value.forEach(element => { - if (principalId === element.id) { - role = element.role; - } - }); - } - if (role === Role.Owner) { - return this.translate.instant('DMP-LISTING.OWNER'); - } else if (role === Role.Member) { - return this.translate.instant('DMP-LISTING.MEMBER'); - } else { - return this.translate.instant('DMP-LISTING.OWNER'); - } - } - - isUserDMPRelated() { - const principalId: string = this.authentication.userId()?.toString(); - let isRelated: boolean = false; - if (this.dmp && principalId) { - this.dmp.users.forEach(element => { - if (element.id === principalId) { - isRelated = true; - } - }) - } - return isRelated; - } - - roleDisplay(value: UserInfoListingModel) { - if (value.role === Role.Owner) { - return this.translate.instant('DMP-LISTING.OWNER'); - } else if (value.role === Role.Member) { - return this.translate.instant('DMP-LISTING.MEMBER'); - } else { - return this.translate.instant('DMP-LISTING.OWNER'); - } - } - - isDraftDataset(dataset: DatasetOverviewModel) { - return dataset.status == DatasetStatus.Draft; - } - - isDraftDmp(dmp: DmpOverviewModel) { + isDraftDmp(dmp: Dmp) { return dmp.status == DmpStatus.Draft; } - isFinalizedDmp(dmp: DmpOverviewModel) { + isFinalizedDmp(dmp: Dmp) { return dmp.status == DmpStatus.Finalized; } - isPublishedDMP(dmp: DmpOverviewModel) { - return (dmp.status == DmpStatus.Finalized && dmp.isPublic); + isPublishedDMP(dmp: Dmp) { + return (dmp.status == DmpStatus.Finalized && dmp.accessType === DmpAccessType.Public); } - hasDoi(dmp: DmpOverviewModel = null) { - return (this.dmp.dois == null || this.dmp.dois.length == 0); + hasDoi() { + return (this.dmp.entityDois == null || this.dmp.entityDois.length == 0); } - getAllVersions(dmp: DmpOverviewModel) { - this.dmpService.getAllVersions(dmp.groupId, this.isPublicView) - .pipe(takeUntil(this._destroyed)) - .subscribe(items => { - this.versions = items; - }); + getAllVersions(dmp: Dmp) { + //TODO: add this + // this.dmpService.getAllVersions(dmp.groupId, this.isPublicView) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(items => { + // this.versions = items; + // }); } - showPublishButton(dmp: DmpOverviewModel) { - return this.isFinalizedDmp(dmp) && !dmp.isPublic && this.hasPublishButton; - } - - publish(dmpId: String) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '500px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PUBLISH-ITEM'), - privacyPolicyNames: this.language.instant('GENERAL.CONFIRMATION-DIALOG.PRIVACY-POLICY-NAMES'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: false - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.dmpService.publish(dmpId) - .pipe(takeUntil(this._destroyed)) - .subscribe(() => { - this.hasPublishButton = false; - this.reloadPage(); - }); - } - }); - } - - afterDeposit(result: DoiModel[]) { + afterDeposit(result: EntityDoi[]) { if (result.length > 0) { - this.dmp.dois = result; - this.selectedModel = this.dmp.dois[this.dmp.dois.length - 1]; + this.dmp.entityDois = result; + this.selectedModel = this.dmp.entityDois[this.dmp.entityDois.length - 1]; } } get inputRepos() { - return this.depositRepos.filter(repo => !this.dmp.dois.find(doi => doi.repositoryId === repo.repositoryId)); + return this.depositRepos.filter(repo => !this.dmp.entityDois.find(doi => doi.repositoryId === repo.repositoryId)); } moreDeposit() { - return (this.dmp.dois.length < this.depositRepos.length); + return (this.dmp.entityDois.length < this.depositRepos.length); } - finalize(dmp: DmpOverviewModel) { + finalize() { + //TODO: add this + // const extraProperties = new ExtraPropertiesFormModel(); + // this.dmpService.getSingle(this.dmp.id).pipe(map(data => data as Dmp)) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(data => { - const extraProperties = new ExtraPropertiesFormModel(); - this.dmpService.getSingle(this.dmp.id).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { + // if (!isNullOrUndefined(data.extraProperties)) { + // extraProperties.fromModel(data.extraProperties); + // } + // const dialogInputModel: DmpFinalizeDialogInput = { + // dmpLabel: this.dmp.label, + // dmpDescription: this.dmp.description, + // datasets: this.dmp.datasets.map(x => { + // return { label: x.label, id: x.id, status: x.status } + // }), + // accessRights: extraProperties.visible + // } - if (!isNullOrUndefined(data.extraProperties)) { - extraProperties.fromModel(data.extraProperties); - } - const dialogInputModel: DmpFinalizeDialogInput = { - dmpLabel: this.dmp.label, - dmpDescription: this.dmp.description, - datasets: this.dmp.datasets.map(x => { - return { label: x.label, id: x.id, status: x.status } - }), - accessRights: extraProperties.visible - } + // const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, { + // maxWidth: '500px', + // restoreFocus: false, + // autoFocus: false, + // data: { + // dialogInputModel: dialogInputModel, + // message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'), + // confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'), + // cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), + // } + // }); + // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: DmpFinalizeDialogOutput) => { + // if (result && !result.cancelled) { + // this.checkIfAnyProfileIsUsedLessThanMin(data).subscribe(checked => { + // if (!checked) { + // var datasetsToBeFinalized: DatasetsToBeFinalized = { + // uuids: result.datasetsToBeFinalized + // }; + // this.dmpService.finalize(datasetsToBeFinalized, this.dmp.id) + // .pipe(takeUntil(this._destroyed)) + // .subscribe( + // complete => { + // if (extraProperties.visible) { + // //this.publish(this.dmp.id); + // this.dmpService.publish(this.dmp.id) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(() => { + // //this.hasPublishButton = false; + // this.dmp.status = DmpStatus.Finalized; + // this.onUpdateCallbackSuccess(); + // }); + // } + // else { + // this.dmp.status = DmpStatus.Finalized; + // this.onUpdateCallbackSuccess(); + // } + // }, + // error => this.onUpdateCallbackError(error) + // ); + // } + // }) + // } + // }); - const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, { - maxWidth: '500px', - restoreFocus: false, - autoFocus: false, - data: { - dialogInputModel: dialogInputModel, - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'), - confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe((result: DmpFinalizeDialogOutput) => { - if (result && !result.cancelled) { - this.checkIfAnyProfileIsUsedLessThanMin(data).subscribe(checked => { - if (!checked) { - var datasetsToBeFinalized: DatasetsToBeFinalized = { - uuids: result.datasetsToBeFinalized - }; - this.dmpService.finalize(datasetsToBeFinalized, this.dmp.id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - if (extraProperties.visible) { - //this.publish(this.dmp.id); - this.dmpService.publish(this.dmp.id) - .pipe(takeUntil(this._destroyed)) - .subscribe(() => { - //this.hasPublishButton = false; - this.dmp.status = DmpStatus.Finalized; - this.onUpdateCallbackSuccess(); - }); - } - else { - this.dmp.status = DmpStatus.Finalized; - this.onUpdateCallbackSuccess(); - } - }, - error => this.onUpdateCallbackError(error) - ); - } - }) - } - }); - - }); + // }); } - private checkIfAnyProfileIsUsedLessThanMin(dmpModel: DmpModel): Observable { - const blueprintId = dmpModel.profile.id; - return this.dmpBlueprintService.getSingle(Guid.parse(blueprintId)) - .pipe(map(result => { - return result.definition.sections.some(section => { - if (!section.hasTemplates) - return false; - return section.descriptionTemplates.some(template => { - if (!(template.minMultiplicity > 0)) - return false; - let count = 0; - dmpModel.datasets.filter(dataset => dataset.dmpSectionIndex === (section.ordinal - 1)).forEach(dataset => { - if (Guid.parse(dataset.profile.id) === template.descriptionTemplateId) { - count++; - } - }) - if (count < template.minMultiplicity) { - this.dialog.open(PopupNotificationDialogComponent, { - data: { - title: this.language.instant('DMP-OVERVIEW.MIN-DESCRIPTIONS-DIALOG.TITLE', { 'minMultiplicity': template.minMultiplicity }), - message: this.language.instant('DMP-OVERVIEW.MIN-DESCRIPTIONS-DIALOG.MESSAGE',) - }, maxWidth: '30em' - }); - return true; - } - else - return false; - }) - }) - }), takeUntil(this._destroyed)); - } - - // newVersion(id: String, label: String) { - // let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }]) - // window.open(url.toString(), '_blank') + // private checkIfAnyProfileIsUsedLessThanMin(dmp: Dmp): Observable { + // const blueprintId = dmp.profile.id; + // return this.dmpBlueprintService.getSingle(Guid.parse(blueprintId)) + // .pipe(map(result => { + // return result.definition.sections.some(section => { + // if (!section.hasTemplates) + // return false; + // return section.descriptionTemplates.some(template => { + // if (!(template.minMultiplicity > 0)) + // return false; + // let count = 0; + // dmp.datasets.filter(dataset => dataset.dmpSectionIndex === (section.ordinal - 1)).forEach(dataset => { + // if (Guid.parse(dataset.profile.id) === template.descriptionTemplateId) { + // count++; + // } + // }) + // if (count < template.minMultiplicity) { + // this.dialog.open(PopupNotificationDialogComponent, { + // data: { + // title: this.language.instant('DMP-OVERVIEW.MIN-DESCRIPTIONS-DIALOG.TITLE', { 'minMultiplicity': template.minMultiplicity }), + // message: this.language.instant('DMP-OVERVIEW.MIN-DESCRIPTIONS-DIALOG.MESSAGE',) + // }, maxWidth: '30em' + // }); + // return true; + // } + // else + // return false; + // }) + // }) + // }), takeUntil(this._destroyed)); // } - viewVersions(rowId: String, rowLabel: String) { - if (this.isPublicView) { - this.router.navigate(['/explore-plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); - } else { - this.router.navigate(['/plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); - } - } - public isAuthenticated(): boolean { return this.authentication.currentAccountIsAuthenticated(); } @@ -717,48 +570,28 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { } openShareDialog(rowId: any, rowName: any) { - const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { - // height: '250px', - // width: '700px', - autoFocus: false, - restoreFocus: false, - data: { - dmpId: rowId, - dmpName: rowName - } - }); + //TODO: add this + // const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { + // // height: '250px', + // // width: '700px', + // autoFocus: false, + // restoreFocus: false, + // data: { + // dmpId: rowId, + // dmpName: rowName + // } + // }); } - openNewDmpDialog() { - if (this.dialog.openDialogs.length > 0) { - this.dialog.closeAll(); - } - else { - const dialogRef = this.dialog.open(StartNewDmpDialogComponent, { - disableClose: false, - data: { - isDialog: true - } - }); - } - } - - // addDataset(rowId: String) { - // this.router.navigate(['/datasets/new/' + rowId]); - // } - - addNewDataset() { - this.router.navigate(['/datasets', 'new', this.dmp.id]); - } - - selectDoi(doiModel: DoiModel) { - this.selectedModel = doiModel; - const foundIdx = this.dmp.dois.findIndex(el => el.id == doiModel.id); - this.dmp.dois.splice(foundIdx, 1); - this.dmp.dois.unshift(doiModel); + selectDoi(entityDoi: EntityDoi) { + this.selectedModel = entityDoi; + const foundIdx = this.dmp.entityDois.findIndex(el => el.id == entityDoi.id); + this.dmp.entityDois.splice(foundIdx, 1); + this.dmp.entityDois.unshift(entityDoi); } createDoiLink(doiModel: DoiModel): string { + //TODO: needs rewriting const repository = this.depositRepos.find(r => r.repositoryId == doiModel.repositoryId); if (typeof repository !== "undefined") { if (doiModel.repositoryId == "Zenodo") { @@ -775,28 +608,29 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { } } - reverse() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.UNFINALIZE-ITEM'), - confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), - cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE'), - isDeleteConfirmation: false - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.dmpService.unfinalize(this.dmp.id).pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.dmp.status = DmpStatus.Draft; - this.onUpdateCallbackSuccess() - }, - error => this.onUpdateCallbackError(error) - ); - } - }); + reverseFinalization() { + //TODO: add this + // const dialogRef = this.dialog.open(ConfirmationDialogComponent, { + // restoreFocus: false, + // data: { + // message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.UNFINALIZE-ITEM'), + // confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), + // cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE'), + // isDeleteConfirmation: false + // } + // }); + // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { + // if (result) { + // this.dmpService.unfinalize(this.dmp.id).pipe(takeUntil(this._destroyed)) + // .subscribe( + // complete => { + // this.dmp.status = DmpStatus.Draft; + // this.onUpdateCallbackSuccess() + // }, + // error => this.onUpdateCallbackError(error) + // ); + // } + // }); } goBack(): void { @@ -810,35 +644,36 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { }); } - updateUsers() { - return this.dmpService.updateUsers(this.dmp.id, this.dmp.users).pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.onUpdateCallbackSuccess(); - }, - error => this.onUpdateCallbackError(error) - ); - } + // updateUsers() { + // return this.dmpService.updateUsers(this.dmp.id, this.dmp.users).pipe(takeUntil(this._destroyed)) + // .subscribe( + // complete => { + // this.onUpdateCallbackSuccess(); + // }, + // error => this.onUpdateCallbackError(error) + // ); + // } removeUserFromDmp(user: UserInfoListingModel) { - 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) { - const list = this.dmp.users; - const index = this.dmp.users.indexOf(user); - if (index > -1) { - this.dmp.users.splice(index, 1); - } - this.updateUsers(); - } - }); + //TODO: implement remove user from backend + // 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) { + // const list = this.dmp.users; + // const index = this.dmp.users.indexOf(user); + // if (index > -1) { + // this.dmp.users.splice(index, 1); + // } + // this.updateUsers(); + // } + // }); } copyDoi(doi) { @@ -869,8 +704,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { return path + userId; } - checkLockStatus(id: string) { - this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed)) + checkLockStatus(id: Guid) { + this.lockService.checkLockStatus(id.toString()).pipe(takeUntil(this._destroyed)) .subscribe(lockStatus => { this.lockStatus = lockStatus if (lockStatus) { @@ -884,58 +719,32 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { }); } - getUserFromDMP(): any { - if (this.dmp) { - const principalId: string = this.authentication.userId().toString(); - return this.dmp.users.find(x => x.id === principalId); - } + private lookupFields(): string[] { + return [ + nameof(x => x.id), + nameof(x => x.label), + nameof(x => x.status), + nameof(x => x.accessType), + nameof(x => x.version), + nameof(x => x.groupId), + nameof(x => x.updatedAt), + [nameof(x => x.entityDois), nameof(x => x.id)].join('.'), + [nameof(x => x.entityDois), nameof(x => x.repositoryId)].join('.'), + [nameof(x => x.entityDois), nameof(x => x.doi)].join('.'), + [nameof(x => x.descriptions), nameof(x => x.id)].join('.'), + [nameof(x => x.descriptions), nameof(x => x.label)].join('.'), + // [nameof(x => x.descriptionTemplate), nameof(x => x.label)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.id)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.label)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.accessType)].join('.'), + [nameof(x => x.dmpUsers), nameof(x => x.id)].join('.'), + [nameof(x => x.dmpUsers), nameof(x => x.user.id)].join('.'), + [nameof(x => x.dmpUsers), nameof(x => x.role)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.id)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.id)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.label)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.type)].join('.'), + // [nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.reference)].join('.'), + ] } - - - - - // advancedClicked() { - // const dialogRef = this.dialog.open(ExportMethodDialogComponent, { - // maxWidth: '500px', - // data: { - // message: "Download as:", - // XMLButton: "XML", - // documentButton: "Document", - // pdfButton: "PDF", - // jsonButton: "JSON" - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // if (result == "pdf") { - // this.downloadPDF(this.dmp.id); - // } else if (result == "xml") { - // this.downloadXml(this.dmp.id); - // } else if (result == "doc") { - // this.downloadDocx(this.dmp.id); - // } else if (result == "json") { - // this.downloadJson(this.dmp.id); - // } - // }); - // } - - // advancedClickedFinalized() { - // const dialogRef = this.dialog.open(ExportMethodDialogComponent, { - // maxWidth: '250px', - // data: { - // message: "Download as:", - // documentButton: "Document", - // pdfButton: "PDF", - // isFinalized: true - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // if (result == "pdf") { - // this.downloadPDF(this.dmp.id); - // } else if (result == "doc") { - // this.downloadDocx(this.dmp.id); - // } - // }); - // } - - }