Completed Dataset Editing/Viewing alongside DMP finalisation (Ticket #45 - Dataset editing / viewing modes)
This commit is contained in:
parent
c33d5ea50a
commit
31fd9b8b14
|
@ -48,6 +48,14 @@ public class DMPs extends BaseController {
|
||||||
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
|
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = {"/dmps/{id}/unlock"}, produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<DMP>> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
|
||||||
|
new DataManagementPlanManager().unlock(this.getApiContext(), id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/getPaged"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal) throws Exception {
|
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal) throws Exception {
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
|
import eu.eudat.data.entities.DMP;
|
||||||
import eu.eudat.data.entities.Dataset;
|
import eu.eudat.data.entities.Dataset;
|
||||||
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
|
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
|
||||||
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
|
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
|
||||||
|
import eu.eudat.exceptions.datasetwizard.DatasetWizardCannotUnlockException;
|
||||||
|
import eu.eudat.logic.managers.DataManagementPlanManager;
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
import eu.eudat.logic.managers.DatasetWizardManager;
|
import eu.eudat.logic.managers.DatasetWizardManager;
|
||||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||||
|
@ -30,6 +33,7 @@ import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import static eu.eudat.types.Authorities.ANONYMOUS;
|
import static eu.eudat.types.Authorities.ANONYMOUS;
|
||||||
|
|
||||||
|
@ -116,4 +120,16 @@ public class DatasetWizardController extends BaseController {
|
||||||
responseHeaders,
|
responseHeaders,
|
||||||
HttpStatus.OK);
|
HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = {"/{id}/unlock"}, produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<Dataset>> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
|
||||||
|
try {
|
||||||
|
new DatasetWizardManager().unlock(this.getApiContext(), id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
|
||||||
|
}catch (DatasetWizardCannotUnlockException datasetWizardCannotUnlockException ){
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Dataset>().status(ApiMessageCode.ERROR_MESSAGE).message(datasetWizardCannotUnlockException.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package eu.eudat.exceptions.datasetwizard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 10/12/2018.
|
||||||
|
*/
|
||||||
|
public class DatasetWizardCannotUnlockException extends RuntimeException {
|
||||||
|
public DatasetWizardCannotUnlockException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatasetWizardCannotUnlockException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatasetWizardCannotUnlockException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatasetWizardCannotUnlockException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
|
@ -74,6 +74,13 @@ public class DataManagementPlanManager {
|
||||||
return dataTable;
|
return dataTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unlock(ApiContext apiContext, UUID uuid) throws Exception {
|
||||||
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao()
|
||||||
|
.asQueryable().where((builder, root) -> builder.equal(root.get("id"), uuid))
|
||||||
|
.update(root -> root.get("status"), DMP.DMPStatus.ACTIVE.getValue());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
public eu.eudat.models.data.dmp.DataManagementPlan getSingle(DMPDao dmpsRepository, String id, Principal principal, DynamicProjectConfiguration dynamicProjectConfiguration) throws InstantiationException, IllegalAccessException {
|
public eu.eudat.models.data.dmp.DataManagementPlan getSingle(DMPDao dmpsRepository, String id, Principal principal, DynamicProjectConfiguration dynamicProjectConfiguration) throws InstantiationException, IllegalAccessException {
|
||||||
DMP dataManagementPlanEntity = dmpsRepository.find(UUID.fromString(id));
|
DMP dataManagementPlanEntity = dmpsRepository.find(UUID.fromString(id));
|
||||||
if (dataManagementPlanEntity.getCreator().getId() != principal.getId() && dataManagementPlanEntity.getUsers().stream().filter(userInfo -> userInfo.getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
|
if (dataManagementPlanEntity.getCreator().getId() != principal.getId() && dataManagementPlanEntity.getUsers().stream().filter(userInfo -> userInfo.getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
|
||||||
|
|
|
@ -3,7 +3,10 @@ package eu.eudat.logic.managers;
|
||||||
import eu.eudat.data.dao.entities.DMPDao;
|
import eu.eudat.data.dao.entities.DMPDao;
|
||||||
|
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
|
import eu.eudat.data.entities.Dataset;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
|
import eu.eudat.exceptions.datasetwizard.DatasetWizardCannotUnlockException;
|
||||||
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.datasetwizard.DataManagentPlanListingModel;
|
import eu.eudat.models.data.datasetwizard.DataManagentPlanListingModel;
|
||||||
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
|
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
|
||||||
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
|
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
|
||||||
|
@ -14,6 +17,7 @@ import eu.eudat.queryable.QueryableList;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
public class DatasetWizardManager {
|
public class DatasetWizardManager {
|
||||||
|
@ -34,4 +38,12 @@ public class DatasetWizardManager {
|
||||||
List<AssociatedProfile> profiles = dataManagementPlan.getProfiles();
|
List<AssociatedProfile> profiles = dataManagementPlan.getProfiles();
|
||||||
return profiles;
|
return profiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unlock(ApiContext apiContext, UUID uuid) throws DatasetWizardCannotUnlockException {
|
||||||
|
Dataset dataset = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
|
||||||
|
if(dataset.getDmp().getStatus() == DMP.DMPStatus.FINALISED.getValue()) throw new DatasetWizardCannotUnlockException("To perform this action you will need to revert DMP's finalisation");
|
||||||
|
dataset.setStatus(Dataset.Status.SAVED.getValue());
|
||||||
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(dataset);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
private Date creationTime;
|
private Date creationTime;
|
||||||
private String organisations;
|
private String organisations;
|
||||||
private int version;
|
private int version;
|
||||||
|
private int status;
|
||||||
private UUID groupId;
|
private UUID groupId;
|
||||||
private List<DatasetUrlListing> datasets;
|
private List<DatasetUrlListing> datasets;
|
||||||
|
|
||||||
|
@ -95,11 +96,20 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
this.datasets = datasets;
|
this.datasets = datasets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataManagementPlanListingModel fromDataModel(DMP entity) {
|
public DataManagementPlanListingModel fromDataModel(DMP entity) {
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.project = entity.getProject().getLabel();
|
this.project = entity.getProject().getLabel();
|
||||||
|
this.status = entity.getStatus();
|
||||||
if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
|
if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
|
||||||
this.organisations = LabelBuilder.getLabel(entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()));
|
this.organisations = LabelBuilder.getLabel(entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()));
|
||||||
this.creationTime = entity.getCreated();
|
this.creationTime = entity.getCreated();
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
<div class="dataset-wizard">
|
<div class="dataset-wizard">
|
||||||
<h3 *ngIf="isNew">{{ 'DATASET-WIZARD.TITLE.NEW' | translate }}</h3>
|
<h3 *ngIf="isNew">{{ 'DATASET-WIZARD.TITLE.NEW' | translate }}</h3>
|
||||||
<div fxLayout="row" fxLayoutAlign="space-between center">
|
<div fxLayout="row" fxLayoutAlign="space-between center">
|
||||||
|
<div>
|
||||||
<h3 *ngIf="!isNew">{{datasetWizardModel?.label}} {{ 'GENERAL.NAMES.DATASET' | translate }}</h3>
|
<h3 *ngIf="!isNew">{{datasetWizardModel?.label}} {{ 'GENERAL.NAMES.DATASET' | translate }}</h3>
|
||||||
<h3 *ngIf="this.formGroup && this.formGroup.dirty"> - {{ 'GENERAL.STATUSES.EDIT' | translate }}</h3>
|
<h3 *ngIf="this.formGroup && this.formGroup.dirty"> - {{ 'GENERAL.STATUSES.EDIT' | translate }}</h3>
|
||||||
<h3 *ngIf="this.formGroup && viewOnly"> - {{ 'GENERAL.STATUSES.FINALISED' | translate }}</h3>
|
<h3 *ngIf="this.formGroup && viewOnly"> - {{ 'GENERAL.STATUSES.FINALISED' | translate }}</h3>
|
||||||
|
</div>
|
||||||
<button *ngIf="!editMode" mat-icon-button (click)="enableForm()">
|
<button *ngIf="!editMode" mat-icon-button (click)="enableForm()">
|
||||||
<mat-icon class="mat-24">edit</mat-icon>
|
<mat-icon class="mat-24">edit</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -470,10 +470,15 @@ export class DatasetWizardComponent implements OnInit, AfterViewInit, IBreadCrum
|
||||||
}
|
}
|
||||||
|
|
||||||
public enableForm() {
|
public enableForm() {
|
||||||
|
if (this.formGroup.get('status').value !== DatasetStatus.Finalised) {
|
||||||
this.editMode = true;
|
this.editMode = true;
|
||||||
this.viewOnly = false;
|
|
||||||
this.formGroup.enable();
|
this.formGroup.enable();
|
||||||
|
} else {
|
||||||
|
this.datasetWizardService.unlock(this.formGroup.get('id').value).subscribe(x => {
|
||||||
|
this.editMode = true;
|
||||||
|
this.formGroup.enable();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public disableForm() {
|
public disableForm() {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { FormGroup, FormControl } from '@angular/forms';
|
||||||
import { SnackBarNotificationComponent } from '../../shared/components/notificaiton/snack-bar-notification.component';
|
import { SnackBarNotificationComponent } from '../../shared/components/notificaiton/snack-bar-notification.component';
|
||||||
import { BaseErrorModel } from '../../models/error/BaseErrorModel';
|
import { BaseErrorModel } from '../../models/error/BaseErrorModel';
|
||||||
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
|
import { DataManagementPlanService } from '../../services/data-management-plan/data-management-plan.service';
|
||||||
import { DataManagementPlanModel } from '../../models/data-managemnt-plans/DataManagementPlanModel';
|
import { DataManagementPlanModel, DataManagementPlanStatus } from '../../models/data-managemnt-plans/DataManagementPlanModel';
|
||||||
import { ExternalSourcesService } from '../../services/external-sources/external-sources.service';
|
import { ExternalSourcesService } from '../../services/external-sources/external-sources.service';
|
||||||
import { ExternalSourcesItemModel } from '../../models/external-sources/ExternalSourcesItemModel';
|
import { ExternalSourcesItemModel } from '../../models/external-sources/ExternalSourcesItemModel';
|
||||||
import { RequestItem } from '../../models/criteria/RequestItem';
|
import { RequestItem } from '../../models/criteria/RequestItem';
|
||||||
|
@ -362,8 +362,15 @@ export class DataManagementPlanEditorComponent implements AfterViewInit, IBreadC
|
||||||
}
|
}
|
||||||
|
|
||||||
public enableForm() {
|
public enableForm() {
|
||||||
|
if (this.formGroup.get('status').value !== DataManagementPlanStatus.Finalised) {
|
||||||
this.editMode = true;
|
this.editMode = true;
|
||||||
this.formGroup.enable();
|
this.formGroup.enable();
|
||||||
|
} else {
|
||||||
|
this.dataManagementPlanService.unlock(this.formGroup.get('id').value).subscribe(x => {
|
||||||
|
this.editMode = true;
|
||||||
|
this.formGroup.enable();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public disableForm() {
|
public disableForm() {
|
||||||
|
@ -384,4 +391,6 @@ export class DataManagementPlanEditorComponent implements AfterViewInit, IBreadC
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,29 @@
|
||||||
<form>
|
<form *ngIf="formGroup" (ngSubmit)="onSubmit()">
|
||||||
<div mat-dialog-title>
|
<div mat-dialog-title>
|
||||||
</div>
|
</div>
|
||||||
<div mat-dialog-content *ngIf="datasetsFinalised && datasetsDraft">
|
<div mat-dialog-content *ngIf="datasetsFinalised && datasetsDraft">
|
||||||
|
<div *ngIf="datasetsFinalised.length > 0">
|
||||||
{{'DMP-FINALISE-DIALOG.ALREADY-FINALISED-DATASETS' | translate}}
|
{{'DMP-FINALISE-DIALOG.ALREADY-FINALISED-DATASETS' | translate}}
|
||||||
<mat-list>
|
<mat-list>
|
||||||
<mat-list-item *ngFor="let dataset of datasetsFinalised | async; let len = length">
|
<mat-list-item *ngFor="let dataset of datasetsFinalised; let len = length">
|
||||||
<div>{{ dataset.label }}</div>
|
<div>{{ dataset.label }}</div>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
</mat-list>
|
</mat-list>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="datasetsDraft.length > 0">
|
||||||
{{'DMP-FINALISE-DIALOG.FINALISE-TITLE' | translate}}
|
{{'DMP-FINALISE-DIALOG.FINALISE-TITLE' | translate}}
|
||||||
<mat-selection-list #datasetsDraftSelectionList>
|
<mat-selection-list #datasetsDraftSelectionList [formControl]="this.formGroup.get('datasets')">
|
||||||
<mat-list-option *ngFor="let dataset of datasetsDraft | async; let len = length" [value]='dataset'>
|
<mat-list-option *ngFor="let dataset of datasetsDraft; let len = length" [value]='dataset'>
|
||||||
{{ dataset.label }}
|
{{ dataset.label }}
|
||||||
</mat-list-option>
|
</mat-list-option>
|
||||||
</mat-selection-list>
|
</mat-selection-list>
|
||||||
</div>
|
</div>
|
||||||
|
<mat-error *ngIf="formGroup.get('datasets').errors?.minLengthArray">{{'DMP-FINALISE-DIALOG.VALIDATION.AT-LEAST-ONE-DATASET-FINALISED'
|
||||||
|
| translate}}</mat-error>
|
||||||
|
</div>
|
||||||
<div mat-dialog-actions>
|
<div mat-dialog-actions>
|
||||||
<div class="full-width">
|
<div class="full-width">
|
||||||
<button mat-raised-button (click)="submit()">
|
<button mat-raised-button type="submit">
|
||||||
{{'DMP-FINALISE-DIALOG.SUBMIT' | translate}}
|
{{'DMP-FINALISE-DIALOG.SUBMIT' | translate}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Component, OnInit, Inject, ViewChild } from '@angular/core';
|
import { Component, OnInit, Inject, ViewChild } from '@angular/core';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup, FormBuilder, Validators, AbstractControl, FormControl, FormArray } from '@angular/forms';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { AuthService } from '../../../services/auth/auth.service';
|
import { AuthService } from '../../../services/auth/auth.service';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA, MatSelectionList } from '@angular/material';
|
import { MatDialogRef, MAT_DIALOG_DATA, MatSelectionList } from '@angular/material';
|
||||||
|
@ -23,8 +23,8 @@ export class DMPFinaliseDialogComponent implements OnInit {
|
||||||
public formGroup: FormGroup;
|
public formGroup: FormGroup;
|
||||||
public submitFunction: (items: DatasetListingModel[]) => any;
|
public submitFunction: (items: DatasetListingModel[]) => any;
|
||||||
public dmp: DataManagementPlanModel;
|
public dmp: DataManagementPlanModel;
|
||||||
public datasetsFinalised: Observable<DatasetListingModel[]>;
|
public datasetsFinalised: DatasetListingModel[];
|
||||||
public datasetsDraft: Observable<DatasetListingModel[]>;
|
public datasetsDraft: DatasetListingModel[];
|
||||||
constructor(
|
constructor(
|
||||||
public router: Router,
|
public router: Router,
|
||||||
public dialogRef: MatDialogRef<DMPFinaliseDialogComponent>,
|
public dialogRef: MatDialogRef<DMPFinaliseDialogComponent>,
|
||||||
|
@ -33,12 +33,11 @@ export class DMPFinaliseDialogComponent implements OnInit {
|
||||||
) {
|
) {
|
||||||
this.submitFunction = data['submitFunction'];
|
this.submitFunction = data['submitFunction'];
|
||||||
this.dmp = data['dmp'];
|
this.dmp = data['dmp'];
|
||||||
this.initialiseDatasetFinalisedRequest();
|
|
||||||
this.initialiseDMPFinalisedRequest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
this.initialiseDatasetFinalisedRequest();
|
||||||
|
this.initialiseDMPFinalisedRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
initialiseDatasetFinalisedRequest() {
|
initialiseDatasetFinalisedRequest() {
|
||||||
|
@ -46,7 +45,10 @@ export class DMPFinaliseDialogComponent implements OnInit {
|
||||||
request.criteria = new DatasetCriteria();
|
request.criteria = new DatasetCriteria();
|
||||||
request.criteria.dmpIds = [this.dmp.id];
|
request.criteria.dmpIds = [this.dmp.id];
|
||||||
request.criteria.status = DatasetStatus.Finalised;
|
request.criteria.status = DatasetStatus.Finalised;
|
||||||
this.datasetsFinalised = this.dmpService.getPaged(request).map(x => x.data);
|
this.dmpService.getPaged(request).map(x => x.data).subscribe(result => {
|
||||||
|
this.datasetsFinalised = result;
|
||||||
|
this.createFormGroup();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,10 +57,45 @@ export class DMPFinaliseDialogComponent implements OnInit {
|
||||||
request.criteria = new DatasetCriteria();
|
request.criteria = new DatasetCriteria();
|
||||||
request.criteria.dmpIds = [this.dmp.id];
|
request.criteria.dmpIds = [this.dmp.id];
|
||||||
request.criteria.status = DatasetStatus.Draft;
|
request.criteria.status = DatasetStatus.Draft;
|
||||||
this.datasetsDraft = this.dmpService.getPaged(request).map(x => x.data);
|
this.dmpService.getPaged(request).map(x => x.data).subscribe(result => {
|
||||||
|
this.datasetsDraft = result;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
submit() {
|
createFormGroup() {
|
||||||
this.submitFunction(this.selectionList.selectedOptions.selected.map(x => x.value));
|
this.formGroup = new FormBuilder().group({
|
||||||
|
datasets: [this.datasetsFinalised, this.minLengthArray(1)]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit() {
|
||||||
|
//this.formGroup.get('datasets').patchValue(this.formGroup.get('datasets').value.push(this.selectionList.selectedOptions.selected.map(x => x.value)));
|
||||||
|
this.touchAllFormFields(this.formGroup);
|
||||||
|
if (!this.formGroup.valid) { return; }
|
||||||
|
this.submitFunction(this.formGroup.get('datasets').value);
|
||||||
|
}
|
||||||
|
|
||||||
|
minLengthArray(min: number) {
|
||||||
|
return (c: AbstractControl): { [key: string]: any } => {
|
||||||
|
if (c.value.length >= min) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return { 'minLengthArray': { valid: false } };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public touchAllFormFields(formControl: AbstractControl) {
|
||||||
|
if (formControl instanceof FormControl) {
|
||||||
|
formControl.markAsTouched();
|
||||||
|
} else if (formControl instanceof FormGroup) {
|
||||||
|
Object.keys(formControl.controls).forEach(item => {
|
||||||
|
const control = formControl.get(item);
|
||||||
|
this.touchAllFormFields(control);
|
||||||
|
});
|
||||||
|
} else if (formControl instanceof FormArray) {
|
||||||
|
formControl.controls.forEach(item => {
|
||||||
|
this.touchAllFormFields(item);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,15 +17,16 @@
|
||||||
|
|
||||||
<!-- Column Definition: Project -->
|
<!-- Column Definition: Project -->
|
||||||
<ng-container cdkColumnDef="project">
|
<ng-container cdkColumnDef="project">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header="|join|project:label">{{'DMP-LISTING.COLUMNS.PROJECT' | translate}}</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header="|join|project:label">{{'DMP-LISTING.COLUMNS.PROJECT' |
|
||||||
|
translate}}</mat-header-cell>
|
||||||
<mat-cell *matCellDef="let row"> {{row.project}} </mat-cell>
|
<mat-cell *matCellDef="let row"> {{row.project}} </mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<!-- Column Definition: Profile -->
|
<!-- Column Definition: Profile -->
|
||||||
<!-- <ng-container cdkColumnDef="profile">
|
<ng-container cdkColumnDef="status">
|
||||||
<mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.PROFILE' | translate}}</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell>
|
||||||
<mat-cell *matCellDef="let row"> {{row.profile}} </mat-cell>
|
<mat-cell *matCellDef="let row"> {{this.utilities.convertFromDMPStatus(row.status)}} </mat-cell>
|
||||||
</ng-container> -->
|
</ng-container>
|
||||||
|
|
||||||
<!-- Column Definition: Researchers -->
|
<!-- Column Definition: Researchers -->
|
||||||
<ng-container cdkColumnDef="creationTime">
|
<ng-container cdkColumnDef="creationTime">
|
||||||
|
@ -58,13 +59,17 @@
|
||||||
<mat-cell *matCellDef="let row" (click)="$event.stopPropagation()">
|
<mat-cell *matCellDef="let row" (click)="$event.stopPropagation()">
|
||||||
<mat-menu #actionsMenu="matMenu">
|
<mat-menu #actionsMenu="matMenu">
|
||||||
<button mat-menu-item (click)="openShareDialog(row.id,row.label)">
|
<button mat-menu-item (click)="openShareDialog(row.id,row.label)">
|
||||||
<mat-icon>share</mat-icon>{{'DMP-LISTING.ACTIONS.INVITE' | translate}}</button>
|
<mat-icon>share</mat-icon>{{'DMP-LISTING.ACTIONS.INVITE' | translate}}
|
||||||
|
</button>
|
||||||
<button mat-menu-item (click)="addDataset(row.id)">
|
<button mat-menu-item (click)="addDataset(row.id)">
|
||||||
<mat-icon>add</mat-icon>{{'DMP-LISTING.ACTIONS.ADD-DATASET' | translate}}</button>
|
<mat-icon>add</mat-icon>{{'DMP-LISTING.ACTIONS.ADD-DATASET' | translate}}
|
||||||
|
</button>
|
||||||
<button mat-menu-item (click)="showDatasets(row.id, row.label)">
|
<button mat-menu-item (click)="showDatasets(row.id, row.label)">
|
||||||
<mat-icon>list</mat-icon>{{'DMP-LISTING.ACTIONS.DATASETS' | translate}}</button>
|
<mat-icon>list</mat-icon>{{'DMP-LISTING.ACTIONS.DATASETS' | translate}}
|
||||||
|
</button>
|
||||||
<button mat-menu-item (click)="viewVersions(row.groupId, row.label)">
|
<button mat-menu-item (click)="viewVersions(row.groupId, row.label)">
|
||||||
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}</button>
|
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
|
||||||
|
</button>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
|
<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
|
||||||
<mat-icon>more_vert</mat-icon>
|
<mat-icon>more_vert</mat-icon>
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { ProjectModel } from '../../models/projects/ProjectModel';
|
||||||
import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent';
|
import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent';
|
||||||
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
|
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
|
||||||
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
import { JsonSerializer } from '../../utilities/JsonSerializer';
|
||||||
|
import { Utilities } from '../../utilities/utilities';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ import { JsonSerializer } from '../../utilities/JsonSerializer';
|
||||||
selector: 'app-dmp-listing-component',
|
selector: 'app-dmp-listing-component',
|
||||||
templateUrl: 'dmp-listing.component.html',
|
templateUrl: 'dmp-listing.component.html',
|
||||||
styleUrls: ['./dmp-listing.component.scss'],
|
styleUrls: ['./dmp-listing.component.scss'],
|
||||||
|
providers: [Utilities]
|
||||||
})
|
})
|
||||||
export class DataManagementPlanListingComponent implements OnInit, IBreadCrumbComponent {
|
export class DataManagementPlanListingComponent implements OnInit, IBreadCrumbComponent {
|
||||||
|
|
||||||
|
@ -36,7 +38,7 @@ export class DataManagementPlanListingComponent implements OnInit, IBreadCrumbCo
|
||||||
|
|
||||||
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
|
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
|
||||||
dataSource: DataManagementPlanDataSource | null;
|
dataSource: DataManagementPlanDataSource | null;
|
||||||
displayedColumns: String[] = ['name', 'project', 'creationTime', 'organisations', 'version', 'datasets', 'actions'];
|
displayedColumns: String[] = ['name', 'project', 'status', 'creationTime', 'organisations', 'version', 'datasets', 'actions'];
|
||||||
itemId: string;
|
itemId: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
showProject: boolean;
|
showProject: boolean;
|
||||||
|
@ -47,7 +49,8 @@ export class DataManagementPlanListingComponent implements OnInit, IBreadCrumbCo
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private languageService: TranslateService,
|
private languageService: TranslateService,
|
||||||
public snackBar: MatSnackBar,
|
public snackBar: MatSnackBar,
|
||||||
public dialog: MatDialog
|
public dialog: MatDialog,
|
||||||
|
public utilities: Utilities
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import { Serializable } from '../Serializable';
|
import { Serializable } from '../Serializable';
|
||||||
|
import { DataManagementPlanStatus } from './DataManagementPlanModel';
|
||||||
|
|
||||||
export class DataManagementPlanListingModel implements Serializable<DataManagementPlanListingModel> {
|
export class DataManagementPlanListingModel implements Serializable<DataManagementPlanListingModel> {
|
||||||
public id: String;
|
public id: String;
|
||||||
public label: String;
|
public label: String;
|
||||||
|
public status: DataManagementPlanStatus;
|
||||||
public project: String;
|
public project: String;
|
||||||
public profile: String;
|
public profile: String;
|
||||||
public creationTime: String;
|
public creationTime: String;
|
||||||
|
@ -14,6 +16,7 @@ export class DataManagementPlanListingModel implements Serializable<DataManageme
|
||||||
fromJSONObject(item: any): DataManagementPlanListingModel {
|
fromJSONObject(item: any): DataManagementPlanListingModel {
|
||||||
this.id = item.id;
|
this.id = item.id;
|
||||||
this.label = item.label;
|
this.label = item.label;
|
||||||
|
this.status = item.status;
|
||||||
this.project = item.project;
|
this.project = item.project;
|
||||||
this.profile = item.profile;
|
this.profile = item.profile;
|
||||||
this.creationTime = item.creationTime;
|
this.creationTime = item.creationTime;
|
||||||
|
|
|
@ -14,6 +14,12 @@ import { DmpUsersModel } from '../../models/dmpUsers/DmpUsersModel';
|
||||||
import { DataManagementPlanProfile } from '../data-management-plan-profile/DataManagementPlanProfile';
|
import { DataManagementPlanProfile } from '../data-management-plan-profile/DataManagementPlanProfile';
|
||||||
import { DynamicField } from './DynamicField';
|
import { DynamicField } from './DynamicField';
|
||||||
|
|
||||||
|
export enum DataManagementPlanStatus {
|
||||||
|
Draft = 0,
|
||||||
|
Finalised = 1,
|
||||||
|
Deleted = 99
|
||||||
|
}
|
||||||
|
|
||||||
export class DataManagementPlanModel implements Serializable<DataManagementPlanModel> {
|
export class DataManagementPlanModel implements Serializable<DataManagementPlanModel> {
|
||||||
public id: string;
|
public id: string;
|
||||||
public label: string;
|
public label: string;
|
||||||
|
|
|
@ -37,6 +37,9 @@ export class DataManagementPlanService {
|
||||||
return this.http.get<DataManagementPlanModel>(this.actionUrl + 'getSingle/' + id, { headers: this.headers });
|
return this.http.get<DataManagementPlanModel>(this.actionUrl + 'getSingle/' + id, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unlock(id: String): Observable<DataManagementPlanModel> {
|
||||||
|
return this.http.get<DataManagementPlanModel>(this.actionUrl + id + '/unlock', { headers: this.headers });
|
||||||
|
}
|
||||||
createDataManagementPlan(dataManagementPlanModel: DataManagementPlanModel): Observable<DataManagementPlanModel> {
|
createDataManagementPlan(dataManagementPlanModel: DataManagementPlanModel): Observable<DataManagementPlanModel> {
|
||||||
return this.http.post<DataManagementPlanModel>(this.actionUrl + 'createOrUpdate', dataManagementPlanModel, { headers: this.headers });
|
return this.http.post<DataManagementPlanModel>(this.actionUrl + 'createOrUpdate', dataManagementPlanModel, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,4 +56,8 @@ export class DatasetWizardService {
|
||||||
public getDefinition(id: String): Observable<DatasetProfileDefinitionModel> {
|
public getDefinition(id: String): Observable<DatasetProfileDefinitionModel> {
|
||||||
return this.http.get<DatasetProfileDefinitionModel>(this.actionUrl + 'get/' + id, { headers: this.headers });
|
return this.http.get<DatasetProfileDefinitionModel>(this.actionUrl + 'get/' + id, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unlock(id: String): Observable<DatasetWizardModel> {
|
||||||
|
return this.http.get<DatasetWizardModel>(this.actionUrl + id + '/unlock', { headers: this.headers });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { Principal } from '../models/login/Principal';
|
||||||
import { DMPProfileFieldDataType, DMPProfileType } from '../models/data-management-plan-profile/DataManagementProfileField';
|
import { DMPProfileFieldDataType, DMPProfileType } from '../models/data-management-plan-profile/DataManagementProfileField';
|
||||||
import { DatasetStatus } from '../models/datasets/DatasetWizardModel';
|
import { DatasetStatus } from '../models/datasets/DatasetWizardModel';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { DataManagementPlanStatus } from '../models/data-managemnt-plans/DataManagementPlanModel';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class Utilities {
|
export class Utilities {
|
||||||
|
@ -39,6 +40,12 @@ export class Utilities {
|
||||||
case DatasetStatus.Draft: return this.language.instant('TYPES.DATASET-STATUS.DRAFT');
|
case DatasetStatus.Draft: return this.language.instant('TYPES.DATASET-STATUS.DRAFT');
|
||||||
case DatasetStatus.Finalised: return this.language.instant('TYPES.DATASET-STATUS.FINALISED');
|
case DatasetStatus.Finalised: return this.language.instant('TYPES.DATASET-STATUS.FINALISED');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
convertFromDMPStatus(status: DataManagementPlanStatus): string {
|
||||||
|
switch (status) {
|
||||||
|
case DataManagementPlanStatus.Draft: return this.language.instant('TYPES.DMP.DRAFT');
|
||||||
|
case DataManagementPlanStatus.Finalised: return this.language.instant('TYPES.DMP.FINALISED');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,8 @@
|
||||||
"ORGANISATIONS": "Organisations",
|
"ORGANISATIONS": "Organisations",
|
||||||
"LATEST_VERSION": "Latest Version",
|
"LATEST_VERSION": "Latest Version",
|
||||||
"ACTIONS": "Actions",
|
"ACTIONS": "Actions",
|
||||||
"DATASETS": "Datasets"
|
"DATASETS": "Datasets",
|
||||||
|
"STATUS": "Status"
|
||||||
},
|
},
|
||||||
"ACTIONS": {
|
"ACTIONS": {
|
||||||
"EDIT": "Edit",
|
"EDIT": "Edit",
|
||||||
|
@ -289,6 +290,10 @@
|
||||||
"EXTERNAL-DATASET-TYPE": {
|
"EXTERNAL-DATASET-TYPE": {
|
||||||
"SOURCE": "Source",
|
"SOURCE": "Source",
|
||||||
"OUTPUT": "Output"
|
"OUTPUT": "Output"
|
||||||
|
},
|
||||||
|
"DMP": {
|
||||||
|
"FINALISED": "Finalised",
|
||||||
|
"DRAFT": "Draft"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ADDRESEARCHERS-EDITOR": {
|
"ADDRESEARCHERS-EDITOR": {
|
||||||
|
@ -414,6 +419,9 @@
|
||||||
"SUBMIT": "Submit",
|
"SUBMIT": "Submit",
|
||||||
"FINALISE-TITLE": "Do you want to finalise any of the following Datasets?",
|
"FINALISE-TITLE": "Do you want to finalise any of the following Datasets?",
|
||||||
"ALREADY-FINALISED-DATASETS": "Already Finalised Datasets",
|
"ALREADY-FINALISED-DATASETS": "Already Finalised Datasets",
|
||||||
"NONE": "None"
|
"NONE": "None",
|
||||||
|
"VALIDATION": {
|
||||||
|
"AT-LEAST-ONE-DATASET-FINALISED": "You need to have at least one Dataset Finalised"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue