From 18c785cd9392e9c52608e6ecceeaadefa8bb740f Mon Sep 17 00:00:00 2001 From: gkolokythas Date: Fri, 10 Jan 2020 12:44:00 +0200 Subject: [PATCH] Fixes how DMP versions are fetched when published and adds UI elemets on listings corresponding to that change. --- .../DataManagementPlanPublicCriteria.java | 16 ++++++++ .../DataManagmentPlanPublicTableRequest.java | 12 ++++-- .../query/explore-dmp/explore-dmp-criteria.ts | 2 + .../app/ui/dmp/editor/dmp-editor.component.ts | 19 +++++---- .../ui/dmp/listing/dmp-listing.component.html | 8 ++++ .../ui/dmp/listing/dmp-listing.component.scss | 8 ++++ .../ui/dmp/listing/dmp-listing.component.ts | 21 ++++++++++ .../ui/dmp/overview/dmp-overview.component.ts | 8 +++- .../explore-dataset-filters.component.ts | 2 +- .../explore-dmp-listing.component.html | 9 ++++- .../explore-dmp-listing.component.scss | 8 ++++ .../explore-dmp-listing.component.ts | 40 ++++++++++++++----- .../app/ui/explore-dmp/explore-dmp.routing.ts | 7 ++++ dmp-frontend/src/assets/i18n/en.json | 3 +- 14 files changed, 137 insertions(+), 26 deletions(-) diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanPublicCriteria.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanPublicCriteria.java index edc1ffa9f..cc96186fc 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanPublicCriteria.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanPublicCriteria.java @@ -12,6 +12,8 @@ public class DataManagementPlanPublicCriteria extends Criteria { public List datasetProfile; private List dmpOrganisations; private Integer role; + private boolean allVersions; + private List groupIds; public GrantStateType getGrantStatus() { return grantStatus; @@ -47,4 +49,18 @@ public class DataManagementPlanPublicCriteria extends Criteria { public void setRole(Integer role) { this.role = role; } + + public boolean getAllVersions() { + return allVersions; + } + public void setAllVersions(boolean allVersions) { + this.allVersions = allVersions; + } + + public List getGroupIds() { + return groupIds; + } + public void setGroupIds(List groupIds) { + this.groupIds = groupIds; + } } diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dmp/DataManagmentPlanPublicTableRequest.java b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dmp/DataManagmentPlanPublicTableRequest.java index ed0ecdb22..f359fcb4b 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dmp/DataManagmentPlanPublicTableRequest.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dmp/DataManagmentPlanPublicTableRequest.java @@ -36,10 +36,14 @@ public class DataManagmentPlanPublicTableRequest extends TableQuery root.join("associatedDmps").get("id").in(this.getCriteria().datasetProfile)); if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty()) query.where(((builder, root) -> root.join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations()))); - - query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), - query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("groupId"), - nestedRoot.get("groupId")), builder1.equal(nestedRoot.get("isPublic"), true)), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class))); + if (!this.getCriteria().getAllVersions()) { + query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), + query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("groupId"), + nestedRoot.get("groupId")), builder1.equal(nestedRoot.get("isPublic"), true)), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class))); + } + if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty()) { + query.where((builder, root) -> root.get("groupId").in(this.getCriteria().getGroupIds())); + } return query; } diff --git a/dmp-frontend/src/app/core/query/explore-dmp/explore-dmp-criteria.ts b/dmp-frontend/src/app/core/query/explore-dmp/explore-dmp-criteria.ts index e577c31aa..376d14196 100644 --- a/dmp-frontend/src/app/core/query/explore-dmp/explore-dmp-criteria.ts +++ b/dmp-frontend/src/app/core/query/explore-dmp/explore-dmp-criteria.ts @@ -8,4 +8,6 @@ export class ExploreDmpCriteriaModel extends BaseCriteria { public grants: string[] = []; public datasetProfile: string[] = []; public dmpOrganisations: string[] = []; + public allVersions: boolean; + public groupIds: string[] = []; } diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index bf196de0c..c9cb70752 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -485,14 +485,17 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), } }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result && !result.cancelled) { - this.formGroup.get('status').setValue(DmpStatus.Finalized); - this.formGroup.get('datasetsToBeFinalized').setValue(result.datasetsToBeFinalized); - this.formSubmit(false); - dialogRef.close(); - } - }); + dialogRef.afterClosed() + .pipe(takeUntil(this._destroyed)) + .subscribe(result => { + if (result && !result.cancelled) { + this.formGroup.get('status').setValue(DmpStatus.Finalized); + this.formGroup.get('datasetsToBeFinalized').setValue(result.datasetsToBeFinalized); + this.formSubmit(false); + //this.router.navigate(['/plans/overview/' + this.formGroup.get('id').value]); + dialogRef.close(); + } + }); } // advancedClicked() { diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.html b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.html index 18d5dc1fe..04e6675f5 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.html @@ -4,6 +4,14 @@

{{'DMP-LISTING.TITLE' | translate}} {{titlePrefix}}

+
+ + {{'DMP-LISTING.VIEW-ALL-VERSIONS' | translate}} + + + {{this.groupLabel}} + +
diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.scss b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.scss index 4def11f1b..ead048e9b 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.scss +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.scss @@ -51,6 +51,14 @@ display: none !important; } +.all-versions { + color: #999999 !important; +} + +.dmp-label { + color: #089dbb !important; +} + // .bot-paginator { // margin-top: auto; // } diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts index 060eb213e..384dced5c 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts @@ -38,6 +38,8 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread titlePrefix: string; totalCount: number; listingItems: DmpListingModel[] = []; + allVersions: boolean = false; + groupLabel: string; constructor( private dmpService: DmpService, @@ -72,6 +74,25 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages)); }) + } else if (params['groupId']) { + this.itemId = params['groupId']; + this.showGrant = true; + const breadCrumbs = []; + this.allVersions = true; + + this.language.get('NAV-BAR.MY-DMPS').pipe(takeUntil(this._destroyed)).subscribe(x => { + this.breadCrumbs = observableOf([ + { + parentComponentName: null, + label: x, + url: '/plans' + }] + ); + }) + this.criteria.setCriteria(this.getDefaultCriteria()); + this.groupLabel = this.route.snapshot.queryParams.groupLabel; + this.refresh(); + this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages)); } else { this.itemId = params['groupId']; this.showGrant = true; 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 35a749461..4b2e8b51e 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 @@ -92,7 +92,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { setIsUserOwner() { if (this.dmp) { const principal: Principal = this.authentication.current(); - if (principal) this.isUserOwner = principal.id === this.dmp.users.find(x => x.role === Role.Owner).id; + if (principal) this.isUserOwner = principal.id === this.dmp.users.find(x => x.role === Role.Owner).id; } } @@ -385,7 +385,11 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { } viewVersions(rowId: String, rowLabel: String) { - this.router.navigate(['/plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); + if (this.dmp.isPublic && !this.isUserOwner) { + this.router.navigate(['/explore-plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); + } else { + this.router.navigate(['/plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); + } } public isAuthenticated(): boolean { diff --git a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.ts b/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.ts index d9a1e5f5b..084a35f7f 100644 --- a/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.ts +++ b/dmp-frontend/src/app/ui/explore-dataset/filters/explore-dataset-filters.component.ts @@ -310,7 +310,7 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI const fields: Array = new Array(); fields.push('-finalizedAt'); const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new ExploreDatasetCriteriaModel(); + dmpDataTableRequest.criteria = new ExploreDmpCriteriaModel(); dmpDataTableRequest.criteria.like = value; return this.dmpService.getPublicPaged(dmpDataTableRequest, "autocomplete") } diff --git a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.html b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.html index 394cdf4b5..1652e34fe 100644 --- a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.html +++ b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.html @@ -10,7 +10,14 @@

{{'DMP-LISTING.TITLE' | translate}}

- +
+ + {{'DMP-LISTING.VIEW-ALL-VERSIONS' | translate}} + + + {{this.groupLabel}} + +
diff --git a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.scss b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.scss index d56c694f6..fa94d00e3 100644 --- a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.scss +++ b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.scss @@ -76,3 +76,11 @@ text-center { ::ng-deep .mat-paginator-navigation-previous { margin-left: auto !important; } + +.all-versions { + color: #999999 !important; +} + +.dmp-label { + color: #089dbb !important; +} diff --git a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.ts b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.ts index 0ab48acfb..9ca409955 100644 --- a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.ts +++ b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.ts @@ -24,12 +24,15 @@ export class ExploreDmpListingComponent extends BaseComponent implements OnInit, @ViewChild(MatPaginator, { static: true }) _paginator: MatPaginator; sort = new MatSort(); - exploreDmpCriteriaModel: ExploreDmpCriteriaModel; + exploreDmpCriteriaModel: ExploreDmpCriteriaModel = new ExploreDmpCriteriaModel(); titlePrefix: string; totalCount: number; listingItems: DmpListingModel[] = []; breadCrumbs: Observable; linkToDmpId: string; + groupId: string; + allVersions: boolean = false; + groupLabel: string; constructor( private dmpService: DmpService, @@ -43,15 +46,32 @@ export class ExploreDmpListingComponent extends BaseComponent implements OnInit, } ngOnInit() { - this.refresh(); + this.route.params + .pipe(takeUntil(this._destroyed)) + .subscribe(params => { + if (params['groupId']) { + this.groupId = params['groupId']; + this.exploreDmpCriteriaModel.groupIds.push(this.groupId); + this.exploreDmpCriteriaModel.allVersions = true; + this.allVersions = true; + this.route.queryParams + .pipe(takeUntil(this._destroyed)) + .subscribe(queryParams => { + if (queryParams["groupLabel"]) { + this.groupLabel = queryParams["groupLabel"]; + } + }) + } - const breadCrumbs = []; - breadCrumbs.push({ - parentComponentName: null, - label: this.language.instant('NAV-BAR.PUBLIC-DMPS'), - url: "/explore-plans" - }) - this.breadCrumbs = observableOf(breadCrumbs); + this.refresh(); + const breadCrumbs = []; + breadCrumbs.push({ + parentComponentName: null, + label: this.language.instant('NAV-BAR.PUBLIC-DMPS'), + url: "/explore-plans" + }) + this.breadCrumbs = observableOf(breadCrumbs); + }) } refresh() { @@ -76,6 +96,8 @@ export class ExploreDmpListingComponent extends BaseComponent implements OnInit, onCriteriaChange(event: ExploreDmpCriteriaModel) { this.exploreDmpCriteriaModel = event; + if (this.allVersions == true) this.exploreDmpCriteriaModel.allVersions = this.allVersions; + if (this.groupId) this.exploreDmpCriteriaModel.groupIds.push(this.groupId); this._paginator.pageIndex = 0; this.refresh(); } diff --git a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp.routing.ts b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp.routing.ts index 6b5ad0cb9..4918a250d 100644 --- a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp.routing.ts +++ b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp.routing.ts @@ -11,6 +11,13 @@ const routes: Routes = [ breadcrumb: true } }, + { + path: 'versions/:groupId', + component: ExploreDmpListingComponent, + data: { + breadcrumb: true + }, + }, { path: 'overview/:publicId', component: DmpOverviewComponent, diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 121132dd9..91bb8dcd0 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -411,7 +411,8 @@ "LEVEL-OF-ACCESS": "Level of Access", "INVOLVED-DATASETS": "Involved Dataset Descriptions", "TEMPLATES-INVOLVED": "Dataset Description Templates Involved" - } + }, + "VIEW-ALL-VERSIONS": "All versions of" }, "DMP-PUBLIC-LISTING": { "TITLE": "Published Data Management Plans",