Completed Dataset Editing/Viewing alongside DMP finalisation (Ticket #45 - Dataset editing / viewing modes)

This commit is contained in:
Ioannis Kalyvas 2018-10-12 11:22:23 +03:00
parent c33d5ea50a
commit 31fd9b8b14
19 changed files with 282 additions and 110 deletions

View File

@ -48,6 +48,14 @@ public class DMPs extends BaseController {
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")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal) throws Exception {

View File

@ -1,8 +1,11 @@
package eu.eudat.controllers;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
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.DatasetWizardManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
@ -30,6 +33,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.UUID;
import static eu.eudat.types.Authorities.ANONYMOUS;
@ -116,4 +120,16 @@ public class DatasetWizardController extends BaseController {
responseHeaders,
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()));
}
}
}

View File

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

View File

@ -74,6 +74,13 @@ public class DataManagementPlanManager {
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 {
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)

View File

@ -3,7 +3,10 @@ package eu.eudat.logic.managers;
import eu.eudat.data.dao.entities.DMPDao;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Dataset;
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.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
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.List;
import java.util.UUID;
public class DatasetWizardManager {
@ -34,4 +38,12 @@ public class DatasetWizardManager {
List<AssociatedProfile> profiles = dataManagementPlan.getProfiles();
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;
}
}

View File

@ -20,6 +20,7 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
private Date creationTime;
private String organisations;
private int version;
private int status;
private UUID groupId;
private List<DatasetUrlListing> datasets;
@ -95,11 +96,20 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
this.datasets = datasets;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
@Override
public DataManagementPlanListingModel fromDataModel(DMP entity) {
this.id = entity.getId().toString();
this.label = entity.getLabel();
this.project = entity.getProject().getLabel();
this.status = entity.getStatus();
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.creationTime = entity.getCreated();

View File

@ -1,10 +1,11 @@
<div class="dataset-wizard">
<h3 *ngIf="isNew">{{ 'DATASET-WIZARD.TITLE.NEW' | translate }}</h3>
<div fxLayout="row" fxLayoutAlign="space-between center">
<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 && viewOnly"> - {{ 'GENERAL.STATUSES.FINALISED' | translate }}</h3>
<div>
<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 && viewOnly"> - {{ 'GENERAL.STATUSES.FINALISED' | translate }}</h3>
</div>
<button *ngIf="!editMode" mat-icon-button (click)="enableForm()">
<mat-icon class="mat-24">edit</mat-icon>
</button>

View File

@ -470,10 +470,15 @@ export class DatasetWizardComponent implements OnInit, AfterViewInit, IBreadCrum
}
public enableForm() {
this.editMode = true;
this.viewOnly = false;
this.formGroup.enable();
if (this.formGroup.get('status').value !== DatasetStatus.Finalised) {
this.editMode = true;
this.formGroup.enable();
} else {
this.datasetWizardService.unlock(this.formGroup.get('id').value).subscribe(x => {
this.editMode = true;
this.formGroup.enable();
});
}
}
public disableForm() {

View File

@ -9,7 +9,7 @@ import { FormGroup, FormControl } from '@angular/forms';
import { SnackBarNotificationComponent } from '../../shared/components/notificaiton/snack-bar-notification.component';
import { BaseErrorModel } from '../../models/error/BaseErrorModel';
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 { ExternalSourcesItemModel } from '../../models/external-sources/ExternalSourcesItemModel';
import { RequestItem } from '../../models/criteria/RequestItem';
@ -362,8 +362,15 @@ export class DataManagementPlanEditorComponent implements AfterViewInit, IBreadC
}
public enableForm() {
this.editMode = true;
this.formGroup.enable();
if (this.formGroup.get('status').value !== DataManagementPlanStatus.Finalised) {
this.editMode = true;
this.formGroup.enable();
} else {
this.dataManagementPlanService.unlock(this.formGroup.get('id').value).subscribe(x => {
this.editMode = true;
this.formGroup.enable();
});
}
}
public disableForm() {
@ -384,4 +391,6 @@ export class DataManagementPlanEditorComponent implements AfterViewInit, IBreadC
}
});
}
}

View File

@ -1,23 +1,29 @@
<form>
<form *ngIf="formGroup" (ngSubmit)="onSubmit()">
<div mat-dialog-title>
</div>
<div mat-dialog-content *ngIf="datasetsFinalised && datasetsDraft">
{{'DMP-FINALISE-DIALOG.ALREADY-FINALISED-DATASETS' | translate}}
<mat-list>
<mat-list-item *ngFor="let dataset of datasetsFinalised | async; let len = length">
<div>{{ dataset.label }}</div>
</mat-list-item>
</mat-list>
{{'DMP-FINALISE-DIALOG.FINALISE-TITLE' | translate}}
<mat-selection-list #datasetsDraftSelectionList>
<mat-list-option *ngFor="let dataset of datasetsDraft | async; let len = length" [value]='dataset'>
{{ dataset.label }}
</mat-list-option>
</mat-selection-list>
<div *ngIf="datasetsFinalised.length > 0">
{{'DMP-FINALISE-DIALOG.ALREADY-FINALISED-DATASETS' | translate}}
<mat-list>
<mat-list-item *ngFor="let dataset of datasetsFinalised; let len = length">
<div>{{ dataset.label }}</div>
</mat-list-item>
</mat-list>
</div>
<div *ngIf="datasetsDraft.length > 0">
{{'DMP-FINALISE-DIALOG.FINALISE-TITLE' | translate}}
<mat-selection-list #datasetsDraftSelectionList [formControl]="this.formGroup.get('datasets')">
<mat-list-option *ngFor="let dataset of datasetsDraft; let len = length" [value]='dataset'>
{{ dataset.label }}
</mat-list-option>
</mat-selection-list>
</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 class="full-width">
<button mat-raised-button (click)="submit()">
<button mat-raised-button type="submit">
{{'DMP-FINALISE-DIALOG.SUBMIT' | translate}}
</button>
</div>

View File

@ -1,5 +1,5 @@
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 { AuthService } from '../../../services/auth/auth.service';
import { MatDialogRef, MAT_DIALOG_DATA, MatSelectionList } from '@angular/material';
@ -23,8 +23,8 @@ export class DMPFinaliseDialogComponent implements OnInit {
public formGroup: FormGroup;
public submitFunction: (items: DatasetListingModel[]) => any;
public dmp: DataManagementPlanModel;
public datasetsFinalised: Observable<DatasetListingModel[]>;
public datasetsDraft: Observable<DatasetListingModel[]>;
public datasetsFinalised: DatasetListingModel[];
public datasetsDraft: DatasetListingModel[];
constructor(
public router: Router,
public dialogRef: MatDialogRef<DMPFinaliseDialogComponent>,
@ -33,12 +33,11 @@ export class DMPFinaliseDialogComponent implements OnInit {
) {
this.submitFunction = data['submitFunction'];
this.dmp = data['dmp'];
this.initialiseDatasetFinalisedRequest();
this.initialiseDMPFinalisedRequest();
}
ngOnInit(): void {
this.initialiseDatasetFinalisedRequest();
this.initialiseDMPFinalisedRequest();
}
initialiseDatasetFinalisedRequest() {
@ -46,7 +45,10 @@ export class DMPFinaliseDialogComponent implements OnInit {
request.criteria = new DatasetCriteria();
request.criteria.dmpIds = [this.dmp.id];
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.dmpIds = [this.dmp.id];
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() {
this.submitFunction(this.selectionList.selectedOptions.selected.map(x => x.value));
createFormGroup() {
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);
});
}
}
}

View File

@ -1,86 +1,91 @@
<div>
<h3>{{'DMP-LISTING.TITLE' | translate}} {{titlePrefix}}</h3>
<h3>{{'DMP-LISTING.TITLE' | translate}} {{titlePrefix}}</h3>
<app-dmp-criteria-component [showProject]="showProject"></app-dmp-criteria-component>
<mat-card class="mat-card">
<mat-card-header>
<mat-progress-bar *ngIf="dataSource?.isLoadingResults" mode="query"></mat-progress-bar>
</mat-card-header>
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
<app-dmp-criteria-component [showProject]="showProject"></app-dmp-criteria-component>
<mat-card class="mat-card">
<mat-card-header>
<mat-progress-bar *ngIf="dataSource?.isLoadingResults" mode="query"></mat-progress-bar>
</mat-card-header>
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
<!-- Column Definition: Name -->
<ng-container cdkColumnDef="name">
<mat-header-cell *matHeaderCellDef mat-sort-header="label">{{'DMP-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.label}}</mat-cell>
</ng-container>
<!-- Column Definition: Name -->
<ng-container cdkColumnDef="name">
<mat-header-cell *matHeaderCellDef mat-sort-header="label">{{'DMP-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.label}}</mat-cell>
</ng-container>
<!-- Column Definition: Project -->
<ng-container cdkColumnDef="project">
<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>
</ng-container>
<!-- Column Definition: Project -->
<ng-container cdkColumnDef="project">
<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>
</ng-container>
<!-- Column Definition: Profile -->
<!-- <ng-container cdkColumnDef="profile">
<mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.PROFILE' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.profile}} </mat-cell>
</ng-container> -->
<!-- Column Definition: Profile -->
<ng-container cdkColumnDef="status">
<mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{this.utilities.convertFromDMPStatus(row.status)}} </mat-cell>
</ng-container>
<!-- Column Definition: Researchers -->
<ng-container cdkColumnDef="creationTime">
<mat-header-cell *matHeaderCellDef mat-sort-header="created">{{'DMP-LISTING.COLUMNS.CREATION-TIME' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.creationTime | date:'shortDate'}} </mat-cell>
</ng-container>
<!-- Column Definition: Researchers -->
<ng-container cdkColumnDef="creationTime">
<mat-header-cell *matHeaderCellDef mat-sort-header="created">{{'DMP-LISTING.COLUMNS.CREATION-TIME' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.creationTime | date:'shortDate'}} </mat-cell>
</ng-container>
<!-- Column Definition: Organisations -->
<ng-container cdkColumnDef="organisations">
<mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.ORGANISATIONS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.organisations}} </mat-cell>
</ng-container>
<!-- Column Definition: Organisations -->
<ng-container cdkColumnDef="organisations">
<mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.ORGANISATIONS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.organisations}} </mat-cell>
</ng-container>
<!-- Column Definition: Version -->
<ng-container cdkColumnDef="version">
<mat-header-cell *matHeaderCellDef mat-sort-header="version">{{'DMP-LISTING.COLUMNS.LATEST_VERSION' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.version}}</mat-cell>
</ng-container>
<!-- Column Definition: Version -->
<ng-container cdkColumnDef="version">
<mat-header-cell *matHeaderCellDef mat-sort-header="version">{{'DMP-LISTING.COLUMNS.LATEST_VERSION' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.version}}</mat-cell>
</ng-container>
<!-- Column Definition: Datasets -->
<ng-container cdkColumnDef="datasets">
<mat-header-cell *matHeaderCellDef mat-sort-header="|count|dataset">{{'DMP-LISTING.COLUMNS.DATASETS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row" (click)="$event.stopPropagation()">
<app-url-listing [items]="row.datasets" [urlLimit]="5" [parameters]="{ datasetLabel: row.label }"></app-url-listing>
</mat-cell>
</ng-container>
<!-- Column Definition: Datasets -->
<ng-container cdkColumnDef="datasets">
<mat-header-cell *matHeaderCellDef mat-sort-header="|count|dataset">{{'DMP-LISTING.COLUMNS.DATASETS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row" (click)="$event.stopPropagation()">
<app-url-listing [items]="row.datasets" [urlLimit]="5" [parameters]="{ datasetLabel: row.label }"></app-url-listing>
</mat-cell>
</ng-container>
<ng-container cdkColumnDef="actions">
<mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.ACTIONS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row" (click)="$event.stopPropagation()">
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item (click)="openShareDialog(row.id,row.label)">
<mat-icon>share</mat-icon>{{'DMP-LISTING.ACTIONS.INVITE' | translate}}</button>
<button mat-menu-item (click)="addDataset(row.id)">
<mat-icon>add</mat-icon>{{'DMP-LISTING.ACTIONS.ADD-DATASET' | translate}}</button>
<button mat-menu-item (click)="showDatasets(row.id, row.label)">
<mat-icon>list</mat-icon>{{'DMP-LISTING.ACTIONS.DATASETS' | translate}}</button>
<button mat-menu-item (click)="viewVersions(row.groupId, row.label)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}</button>
</mat-menu>
<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
<mat-icon>more_vert</mat-icon>
</button>
</mat-cell>
</ng-container>
<ng-container cdkColumnDef="actions">
<mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.ACTIONS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row" (click)="$event.stopPropagation()">
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item (click)="openShareDialog(row.id,row.label)">
<mat-icon>share</mat-icon>{{'DMP-LISTING.ACTIONS.INVITE' | translate}}
</button>
<button mat-menu-item (click)="addDataset(row.id)">
<mat-icon>add</mat-icon>{{'DMP-LISTING.ACTIONS.ADD-DATASET' | translate}}
</button>
<button mat-menu-item (click)="showDatasets(row.id, row.label)">
<mat-icon>list</mat-icon>{{'DMP-LISTING.ACTIONS.DATASETS' | translate}}
</button>
<button mat-menu-item (click)="viewVersions(row.groupId, row.label)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
</button>
</mat-menu>
<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
<mat-icon>more_vert</mat-icon>
</button>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id);"></mat-row>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id);"></mat-row>
</mat-table>
<mat-paginator #paginator [length]="dataSource?.totalCount" [pageSizeOptions]="[10, 25, 100]">
</mat-paginator>
</mat-card>
</mat-table>
<mat-paginator #paginator [length]="dataSource?.totalCount" [pageSizeOptions]="[10, 25, 100]">
</mat-paginator>
</mat-card>
<button *ngIf="!this.projectId" mat-fab class="mat-fab-bottom-right" color="primary" [routerLink]=" ['./new'] ">
<mat-icon class="mat-24">add</mat-icon>
</button>
<button *ngIf="!this.projectId" mat-fab class="mat-fab-bottom-right" color="primary" [routerLink]=" ['./new'] ">
<mat-icon class="mat-24">add</mat-icon>
</button>
</div>

View File

@ -18,6 +18,7 @@ import { ProjectModel } from '../../models/projects/ProjectModel';
import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent';
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
import { JsonSerializer } from '../../utilities/JsonSerializer';
import { Utilities } from '../../utilities/utilities';
@ -25,6 +26,7 @@ import { JsonSerializer } from '../../utilities/JsonSerializer';
selector: 'app-dmp-listing-component',
templateUrl: 'dmp-listing.component.html',
styleUrls: ['./dmp-listing.component.scss'],
providers: [Utilities]
})
export class DataManagementPlanListingComponent implements OnInit, IBreadCrumbComponent {
@ -36,7 +38,7 @@ export class DataManagementPlanListingComponent implements OnInit, IBreadCrumbCo
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
dataSource: DataManagementPlanDataSource | null;
displayedColumns: String[] = ['name', 'project', 'creationTime', 'organisations', 'version', 'datasets', 'actions'];
displayedColumns: String[] = ['name', 'project', 'status', 'creationTime', 'organisations', 'version', 'datasets', 'actions'];
itemId: string;
projectId: string;
showProject: boolean;
@ -47,7 +49,8 @@ export class DataManagementPlanListingComponent implements OnInit, IBreadCrumbCo
private route: ActivatedRoute,
private languageService: TranslateService,
public snackBar: MatSnackBar,
public dialog: MatDialog
public dialog: MatDialog,
public utilities: Utilities
) {
}

View File

@ -1,8 +1,10 @@
import { Serializable } from '../Serializable';
import { DataManagementPlanStatus } from './DataManagementPlanModel';
export class DataManagementPlanListingModel implements Serializable<DataManagementPlanListingModel> {
public id: String;
public label: String;
public status: DataManagementPlanStatus;
public project: String;
public profile: String;
public creationTime: String;
@ -14,6 +16,7 @@ export class DataManagementPlanListingModel implements Serializable<DataManageme
fromJSONObject(item: any): DataManagementPlanListingModel {
this.id = item.id;
this.label = item.label;
this.status = item.status;
this.project = item.project;
this.profile = item.profile;
this.creationTime = item.creationTime;

View File

@ -14,6 +14,12 @@ import { DmpUsersModel } from '../../models/dmpUsers/DmpUsersModel';
import { DataManagementPlanProfile } from '../data-management-plan-profile/DataManagementPlanProfile';
import { DynamicField } from './DynamicField';
export enum DataManagementPlanStatus {
Draft = 0,
Finalised = 1,
Deleted = 99
}
export class DataManagementPlanModel implements Serializable<DataManagementPlanModel> {
public id: string;
public label: string;

View File

@ -37,6 +37,9 @@ export class DataManagementPlanService {
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> {
return this.http.post<DataManagementPlanModel>(this.actionUrl + 'createOrUpdate', dataManagementPlanModel, { headers: this.headers });
}

View File

@ -56,4 +56,8 @@ export class DatasetWizardService {
public getDefinition(id: String): Observable<DatasetProfileDefinitionModel> {
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 });
}
}

View File

@ -4,6 +4,7 @@ import { Principal } from '../models/login/Principal';
import { DMPProfileFieldDataType, DMPProfileType } from '../models/data-management-plan-profile/DataManagementProfileField';
import { DatasetStatus } from '../models/datasets/DatasetWizardModel';
import { TranslateService } from '@ngx-translate/core';
import { DataManagementPlanStatus } from '../models/data-managemnt-plans/DataManagementPlanModel';
@Injectable()
export class Utilities {
@ -39,6 +40,12 @@ export class Utilities {
case DatasetStatus.Draft: return this.language.instant('TYPES.DATASET-STATUS.DRAFT');
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');
}
}
}

View File

@ -61,7 +61,8 @@
"ORGANISATIONS": "Organisations",
"LATEST_VERSION": "Latest Version",
"ACTIONS": "Actions",
"DATASETS": "Datasets"
"DATASETS": "Datasets",
"STATUS": "Status"
},
"ACTIONS": {
"EDIT": "Edit",
@ -289,6 +290,10 @@
"EXTERNAL-DATASET-TYPE": {
"SOURCE": "Source",
"OUTPUT": "Output"
},
"DMP": {
"FINALISED": "Finalised",
"DRAFT": "Draft"
}
},
"ADDRESEARCHERS-EDITOR": {
@ -414,6 +419,9 @@
"SUBMIT": "Submit",
"FINALISE-TITLE": "Do you want to finalise any of the following 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"
}
}
}