Fixes how DMP versions are fetched when published and adds UI elemets on listings corresponding to that change.

This commit is contained in:
gkolokythas 2020-01-10 12:44:00 +02:00
parent 2798fa3a39
commit 18c785cd93
14 changed files with 137 additions and 26 deletions

View File

@ -12,6 +12,8 @@ public class DataManagementPlanPublicCriteria extends Criteria<DMP> {
public List<UUID> datasetProfile;
private List<String> dmpOrganisations;
private Integer role;
private boolean allVersions;
private List<UUID> groupIds;
public GrantStateType getGrantStatus() {
return grantStatus;
@ -47,4 +49,18 @@ public class DataManagementPlanPublicCriteria extends Criteria<DMP> {
public void setRole(Integer role) {
this.role = role;
}
public boolean getAllVersions() {
return allVersions;
}
public void setAllVersions(boolean allVersions) {
this.allVersions = allVersions;
}
public List<UUID> getGroupIds() {
return groupIds;
}
public void setGroupIds(List<UUID> groupIds) {
this.groupIds = groupIds;
}
}

View File

@ -36,10 +36,14 @@ public class DataManagmentPlanPublicTableRequest extends TableQuery<DataManageme
query.where((builder, root) -> 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.<String>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.<String>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;
}

View File

@ -8,4 +8,6 @@ export class ExploreDmpCriteriaModel extends BaseCriteria {
public grants: string[] = [];
public datasetProfile: string[] = [];
public dmpOrganisations: string[] = [];
public allVersions: boolean;
public groupIds: string[] = [];
}

View File

@ -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() {

View File

@ -4,6 +4,14 @@
<div class="row card-header card-header-plain d-flex">
<div class="card-desc d-flex flex-column justify-content-center">
<h4 class="card-title">{{'DMP-LISTING.TITLE' | translate}} {{titlePrefix}}</h4>
<div *ngIf="allVersions">
<span class="all-versions">
{{'DMP-LISTING.VIEW-ALL-VERSIONS' | translate}}
</span>
<span class="dmp-label">
{{this.groupLabel}}
</span>
</div>
<!-- <p class="card-category">{{'DMP-LISTING.SUBTITLE' | translate}}</p> -->
</div>
<div class="row ml-auto p-2">

View File

@ -51,6 +51,14 @@
display: none !important;
}
.all-versions {
color: #999999 !important;
}
.dmp-label {
color: #089dbb !important;
}
// .bot-paginator {
// margin-top: auto;
// }

View File

@ -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;

View File

@ -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 {

View File

@ -310,7 +310,7 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
const fields: Array<string> = new Array<string>();
fields.push('-finalizedAt');
const dmpDataTableRequest: DataTableRequest<ExploreDmpCriteriaModel> = new DataTableRequest(0, null, { fields: fields });
dmpDataTableRequest.criteria = new ExploreDatasetCriteriaModel();
dmpDataTableRequest.criteria = new ExploreDmpCriteriaModel();
dmpDataTableRequest.criteria.like = value;
return this.dmpService.getPublicPaged(dmpDataTableRequest, "autocomplete")
}

View File

@ -10,7 +10,14 @@
<div class="card-header card-header-plain d-flex">
<div class="card-desc d-flex flex-column justify-content-center">
<h4 class="card-title">{{'DMP-LISTING.TITLE' | translate}}</h4>
<!-- <p class="card-category">{{'DMP-LISTING.SUBTITLE' | translate}}</p> -->
<div *ngIf="allVersions">
<span class="all-versions">
{{'DMP-LISTING.VIEW-ALL-VERSIONS' | translate}}
</span>
<span class="dmp-label">
{{this.groupLabel}}
</span>
</div>
</div>
</div>
<div class="card-body table-responsive">

View File

@ -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;
}

View File

@ -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<BreadcrumbItem[]>;
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();
}

View File

@ -11,6 +11,13 @@ const routes: Routes = [
breadcrumb: true
}
},
{
path: 'versions/:groupId',
component: ExploreDmpListingComponent,
data: {
breadcrumb: true
},
},
{
path: 'overview/:publicId',
component: DmpOverviewComponent,

View File

@ -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",