Adds buttons to change DMP status from Draft to Finalized and from Finalized to Published (refactor on dmp-finalize-dialog-component.ts)

This commit is contained in:
apapachristou 2019-07-01 12:35:09 +03:00
parent 93ec605c6b
commit 14a1afc414
14 changed files with 373 additions and 288 deletions

View File

@ -1,8 +1,8 @@
import { DatasetProfileModel } from "./dataset-profile"; import { DatasetProfileModel } from "./dataset-profile";
export interface DatasetOverviewModel { export interface DatasetOverviewModel {
id: String; id: string;
label: String; label: string;
status: any; status: any;
datasetTemplate: DatasetProfileModel; datasetTemplate: DatasetProfileModel;
} }

View File

@ -0,0 +1,3 @@
export interface DatasetsToBeFinalized {
uuids: string[];
}

View File

@ -14,6 +14,7 @@ export interface DmpOverviewModel {
modifiedTime: string; modifiedTime: string;
version: number; version: number;
status: number; status: number;
isPublic: boolean;
groupId: string; groupId: string;
description: string; description: string;
project: ProjectOverviewModel; project: ProjectOverviewModel;
@ -21,5 +22,8 @@ export interface DmpOverviewModel {
users: UserInfoListingModel[]; users: UserInfoListingModel[];
organisations: OrganizationModel[]; organisations: OrganizationModel[];
datasets: DatasetOverviewModel[]; datasets: DatasetOverviewModel[];
datasetsToBeFinalized: string[];
researchers: ResearcherModel[]; researchers: ResearcherModel[];
finalizedAt: Date;
publishedAt: Date;
} }

View File

@ -19,7 +19,7 @@ export interface DmpModel {
description: String; description: String;
project: ProjectListingModel; project: ProjectListingModel;
datasets: DatasetModel[]; datasets: DatasetModel[];
datasetsToBeFinalized: String[]; datasetsToBeFinalized: string[];
profiles: DmpProfile[]; profiles: DmpProfile[];
organisations: OrganizationModel[]; organisations: OrganizationModel[];
researchers: ResearcherModel[]; researchers: ResearcherModel[];

View File

@ -18,6 +18,7 @@ import { InterceptorType } from '../../../common/http/interceptors/interceptor-t
import { ExploreDmpCriteriaModel } from '../../query/explore-dmp/explore-dmp-criteria'; import { ExploreDmpCriteriaModel } from '../../query/explore-dmp/explore-dmp-criteria';
import { DmpOverviewModel } from '../../model/dmp/dmp-overview'; import { DmpOverviewModel } from '../../model/dmp/dmp-overview';
import { DatasetListingModel } from '../../model/dataset/dataset-listing'; import { DatasetListingModel } from '../../model/dataset/dataset-listing';
import { DatasetsToBeFinalized } from '../../model/dataset/datasets-toBeFinalized';
@Injectable() @Injectable()
export class DmpService { export class DmpService {
@ -83,6 +84,14 @@ export class DmpService {
return this.http.delete<DmpModel>(this.actionUrl + id, { headers: this.headers }); // + 'delete/' return this.http.delete<DmpModel>(this.actionUrl + id, { headers: this.headers }); // + 'delete/'
} }
publish(id: String): Observable<DmpModel> {
return this.http.get<DmpModel>(this.actionUrl + 'makepublic/' + id, { headers: this.headers });
}
finalize(datasetsToBeFinalized: DatasetsToBeFinalized, id: String): Observable<DmpModel> {
return this.http.post<DmpModel>(this.actionUrl + 'finalize/' + id, datasetsToBeFinalized, { headers: this.headers });
}
getDynamicField(requestItem: RequestItem<DynamicFieldProjectCriteria>): any { getDynamicField(requestItem: RequestItem<DynamicFieldProjectCriteria>): any {
return this.http.post<any>(this.actionUrl + 'dynamic', requestItem, { headers: this.headers }); return this.http.post<any>(this.actionUrl + 'dynamic', requestItem, { headers: this.headers });
} }

View File

@ -1,5 +1,5 @@
import { Component, OnInit, ViewContainerRef } from '@angular/core'; import { Component, OnInit, ViewContainerRef } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms'; import { FormGroup, FormControl, FormArray } from '@angular/forms';
import { MatDialog, MatSnackBar } from '@angular/material'; import { MatDialog, MatSnackBar } from '@angular/material';
import { ActivatedRoute, Params, Router } from '@angular/router'; import { ActivatedRoute, Params, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
@ -29,7 +29,7 @@ import { LanguageResolverService } from '../../../services/language-resolver/lan
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item'; import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent'; import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
import { DmpEditorModel } from './dmp-editor.model'; import { DmpEditorModel } from './dmp-editor.model';
import { DmpFinalizeDialogComponent } from './dmp-finalize-dialog/dmp-finalize-dialog.component'; import { DmpFinalizeDialogComponent, DmpFinalizeDialogInput } from './dmp-finalize-dialog/dmp-finalize-dialog.component';
import { AuthService } from '../../../core/services/auth/auth.service'; import { AuthService } from '../../../core/services/auth/auth.service';
import { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component'; import { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component';
import { UserInfoListingModel } from '../../../core/model/user/user-info-listing'; import { UserInfoListingModel } from '../../../core/model/user/user-info-listing';
@ -259,7 +259,6 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
onCallbackError(error: any) { onCallbackError(error: any) {
this.setErrorModel(error.error); this.setErrorModel(error.error);
//this.validateAllFormFields(this.formGroup); //this.validateAllFormFields(this.formGroup);
} }
@ -435,22 +434,31 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
} }
saveAndFinalize() { saveAndFinalize() {
const dialogInputModel: DmpFinalizeDialogInput = {
dmpLabel: this.formGroup.get('label').value,
dmpDescription: this.formGroup.get('description').value,
datasets: this.formGroup.get('datasets').value.map(x => {
return { label: x.label, id: x.id, status: x.status };
})
}
const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, { const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, {
maxWidth: '500px', maxWidth: '500px',
data: { data: {
formGroup: this.formGroup, dialogInputModel: dialogInputModel,
dmp: this.dmp,
isWizard: false,
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'), message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'),
confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'), confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
submitFunction: () => { }
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result && !result.cancelled) {
this.formGroup.get('status').setValue(DmpStatus.Finalized); this.formGroup.get('status').setValue(DmpStatus.Finalized);
this.formGroup.get('datasetsToBeFinalized').setValue(result.datasetsToBeFinalized);
this.formSubmit(); this.formSubmit();
dialogRef.close(); dialogRef.close();
} }
}
}); });
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { });
} }
} }

View File

@ -31,7 +31,7 @@ export class DmpEditorModel {
public researchers: ResearcherModel[] = []; public researchers: ResearcherModel[] = [];
public profiles: DmpProfile[] = []; public profiles: DmpProfile[] = [];
public datasets: DatasetModel[] = []; public datasets: DatasetModel[] = [];
public datasetsToBeFinalized: String[] = []; public datasetsToBeFinalized: string[] = [];
public associatedUsers: UserModel[] = []; public associatedUsers: UserModel[] = [];
public users: UserInfoListingModel[] = []; public users: UserInfoListingModel[] = [];
public definition: DmpProfileDefinition; public definition: DmpProfileDefinition;

View File

@ -1,11 +1,83 @@
<form *ngIf="formGroup" (ngSubmit)="onSubmit()"> <div class="row d-flex flex-row">
<div class="row d-flex flex-row">
<div mat-dialog-title class="col-auto">{{ data.message }}</div> <div mat-dialog-title class="col-auto">{{ data.message }}</div>
<div class="col-auto close-btn ml-auto" (click)="close()"> <div class="col-auto close-btn ml-auto" (click)="close()">
<mat-icon>close</mat-icon> <mat-icon>close</mat-icon>
</div> </div>
</div>
<div mat-dialog-content class="pt-2 pb-2">
<mat-accordion [multi]="true">
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
{{ 'DMP-FINALISE-DIALOG.DMP' | translate }}
</mat-panel-title>
<mat-panel-description class="dmp-title">
{{ inputModel.dmpLabel }}
</mat-panel-description>
</mat-expansion-panel-header>
{{ inputModel.dmpDescription }}
</mat-expansion-panel>
<mat-expansion-panel [expanded]="true">
<mat-expansion-panel-header>
<mat-panel-title>
{{ 'DMP-FINALISE-DIALOG.DATASETS' | translate }}
</mat-panel-title>
<mat-panel-description></mat-panel-description>
</mat-expansion-panel-header>
<div *ngIf="inputModel.datasets.length > 0">
<div *ngFor="let dataset of inputModel.datasets" class="row pl-3 datasets">
<mat-icon *ngIf="dataset.status == 0" class="col-1 draft-bookmark">bookmark</mat-icon>
<mat-icon *ngIf="dataset.status != 0" class="col-1 finalized-bookmark">bookmark</mat-icon>
<h4 *ngIf="dataset.status == 0" class="col-11 ml-auto mt-1 mb-4">
<span>{{ 'TYPES.DATASET-STATUS.DRAFT' | translate }}:</span>
{{ dataset.label }}</h4>
<h4 *ngIf="dataset.status != 0" class="col-11 ml-auto mt-1 mb-4">{{ dataset.label }}</h4>
</div> </div>
<div mat-dialog-content *ngIf="datasetsFinalized && datasetsDraft" class="pt-2 pb-2"> </div>
<div *ngIf="inputModel.datasets.length === 0" class="emptyList">{{ 'DMP-FINALISE-DIALOG.EMPTY' | translate }} </div>
</mat-expansion-panel>
</mat-accordion>
<div *ngIf="getDraftDatasets().length > 0" class="pt-4 pb-2">
<h4 class="pl-2">{{'DMP-FINALISE-DIALOG.FINALISE-TITLE' | translate}}</h4>
<mat-selection-list #datasetsDraftSelectionList [(ngModel)]="outputModel.datasetsToBeFinalized">
<div class="styleBorder" *ngFor="let dataset of getDraftDatasets()">
<mat-list-option [value]='dataset.id'>
{{ dataset.label }}
</mat-list-option>
</div>
</mat-selection-list>
</div>
<mat-error *ngIf="getFinalizedDatasets().length == 0">
{{'DMP-FINALISE-DIALOG.VALIDATION.AT-LEAST-ONE-DATASET-FINALISED' | translate}}
</mat-error>
</div>
<div *ngIf="getFinalizedDatasets().length != 0">
<div class="row pt-2 pb-2 pl-4 pr-4">
{{ 'DMP-FINALISE-DIALOG.IMPACT' | translate }}
</div>
<div class="row pl-4 pr-4">
{{ 'DMP-FINALISE-DIALOG.AFTER-FINALIZATION' | translate }}
</div>
</div>
<div mat-dialog-actions class="d-flex justify-content-end">
<div class="col-auto">
<button mat-raised-button class="confirm" (click)="onSubmit()">{{ data.confirmButton }}</button>
</div>
<div class="col-auto">
<button mat-raised-button cdkFocusInitial (click)="close()" class="cancel">{{ data.cancelButton }}</button>
</div>
</div>
<!-- <form *ngIf="formGroup" (ngSubmit)="onSubmit()">
<div class="row d-flex flex-row">
<div mat-dialog-title class="col-auto">{{ data.message }}</div>
<div class="col-auto close-btn ml-auto" (click)="close()">
<mat-icon>close</mat-icon>
</div>
</div>
<div mat-dialog-content *ngIf="datasetsFinalized && datasetsDraft" class="pt-2 pb-2">
<mat-accordion [multi]="true"> <mat-accordion [multi]="true">
<mat-expansion-panel> <mat-expansion-panel>
<mat-expansion-panel-header> <mat-expansion-panel-header>
@ -41,7 +113,7 @@
<div *ngIf="datasetsDraft.length > 0" class="pt-4 pb-2"> <div *ngIf="datasetsDraft.length > 0" class="pt-4 pb-2">
<h4 class="pl-2">{{'DMP-FINALISE-DIALOG.FINALISE-TITLE' | translate}}</h4> <h4 class="pl-2">{{'DMP-FINALISE-DIALOG.FINALISE-TITLE' | translate}}</h4>
<mat-selection-list #datasetsDraftSelectionList [formControl]="this.formGroup.get('datasetsToBeFinalized')"> <mat-selection-list #datasetsDraftSelectionList [ngModel]="outputModel.datasetToBeFinalized">
<div class="styleBorder" *ngFor="let dataset of datasetsDraft"> <div class="styleBorder" *ngFor="let dataset of datasetsDraft">
<mat-list-option [value]='dataset.id'> <mat-list-option [value]='dataset.id'>
{{ dataset.label }} {{ dataset.label }}
@ -51,9 +123,9 @@
</div> </div>
<mat-error *ngIf="datasetsFinalized.length == 0">{{'DMP-FINALISE-DIALOG.VALIDATION.AT-LEAST-ONE-DATASET-FINALISED' <mat-error *ngIf="datasetsFinalized.length == 0">{{'DMP-FINALISE-DIALOG.VALIDATION.AT-LEAST-ONE-DATASET-FINALISED'
| translate}}</mat-error> | translate}}</mat-error>
</div> </div>
<div mat-dialog-content *ngIf="isWizard" class="pt-2 pb-2"> <div mat-dialog-content *ngIf="isWizard" class="pt-2 pb-2">
<mat-accordion [multi]="true"> <mat-accordion [multi]="true">
<mat-expansion-panel> <mat-expansion-panel>
<mat-expansion-panel-header> <mat-expansion-panel-header>
@ -79,27 +151,27 @@
<h4 class="col-11 ml-auto mt-1 mb-4">{{ label }}</h4> <h4 class="col-11 ml-auto mt-1 mb-4">{{ label }}</h4>
</div> </div>
</div> </div>
<div *ngIf="allDatasetLabels.length === 0" class="emptyList"> {{ 'DMP-FINALISE-DIALOG.EMPTY' | translate }} </div> <div *ngIf="allDatasetLabels.length === 0" class="emptyList"> {{ 'DMP-FINALISE-DIALOG.EMPTY' | translate }}
</div>
</mat-expansion-panel> </mat-expansion-panel>
</mat-accordion> </mat-accordion>
</div> </div>
<div *ngIf="datasetsFinalized && datasetsFinalized.length != 0"> <div *ngIf="datasetsFinalized && datasetsFinalized.length != 0">
<div class="row pt-2 pb-2 pl-4 pr-4"> <div class="row pt-2 pb-2 pl-4 pr-4">
{{ 'DMP-FINALISE-DIALOG.IMPACT' | translate }} {{ 'DMP-FINALISE-DIALOG.IMPACT' | translate }}
</div> </div>
<div class="row pl-4 pr-4"> <div class="row pl-4 pr-4">
{{ 'DMP-FINALISE-DIALOG.AFTER-FINALIZATION' | translate }} {{ 'DMP-FINALISE-DIALOG.AFTER-FINALIZATION' | translate }}
</div> </div>
</div> </div>
<div mat-dialog-actions class="d-flex justify-content-end"> <div mat-dialog-actions class="d-flex justify-content-end">
<div class="col-auto"> <div class="col-auto">
<button mat-raised-button type="submit" class="confirm">{{ data.confirmButton }}</button> <button mat-raised-button class="confirm" (click)="onSubmit()">{{ data.confirmButton }}</button>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<button mat-raised-button cdkFocusInitial type="button" (click)="cancel()" <button mat-raised-button cdkFocusInitial (click)="close()" class="cancel">{{ data.cancelButton }}</button>
class="cancel">{{ data.cancelButton }}</button>
</div> </div>
</div> </div>
</form> </form> -->

View File

@ -1,16 +1,9 @@
import { Component, Inject, OnInit, ViewChild } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { AbstractControl, FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { MatDialogRef, MatSelectionList, MAT_DIALOG_DATA } from '@angular/material';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { takeUntil } from 'rxjs/operators';
import { BaseComponent } from '../../../../core/common/base/base.component'; import { BaseComponent } from '../../../../core/common/base/base.component';
import { DatasetStatus } from '../../../../core/common/enum/dataset-status'; import { DatasetStatus } from '../../../../core/common/enum/dataset-status';
import { DataTableRequest } from '../../../../core/model/data-table/data-table-request';
import { DatasetListingModel } from '../../../../core/model/dataset/dataset-listing';
import { DmpModel } from '../../../../core/model/dmp/dmp';
import { DatasetCriteria } from '../../../../core/query/dataset/dataset-criteria';
import { DatasetService } from '../../../../core/services/dataset/dataset.service'; import { DatasetService } from '../../../../core/services/dataset/dataset.service';
import { DatasetOverviewModel } from '../../../../core/model/dataset/dataset-overview';
@Component({ @Component({
selector: 'app-dmp-finalize-dialog-component', selector: 'app-dmp-finalize-dialog-component',
@ -19,119 +12,52 @@ import { DatasetOverviewModel } from '../../../../core/model/dataset/dataset-ove
}) })
export class DmpFinalizeDialogComponent extends BaseComponent implements OnInit { export class DmpFinalizeDialogComponent extends BaseComponent implements OnInit {
@ViewChild('datasetsDraftSelectionList') selectionList: MatSelectionList; inputModel: DmpFinalizeDialogInput;
public formGroup: FormGroup; outputModel: DmpFinalizeDialogOutput;
public submitFunction: () => any;
public dmp: DmpModel;
public datasetsFinalized: DatasetListingModel[];
public datasetsDraft: DatasetListingModel[];
public allDatasets: DatasetListingModel[] = [];
public allDatasetLabels: String[] = [];
public isWizard: boolean;
constructor( constructor(
public router: Router, public router: Router,
public dialogRef: MatDialogRef<DmpFinalizeDialogComponent>, public dialogRef: MatDialogRef<DmpFinalizeDialogComponent>,
public dmpService: DatasetService, public datasetService: DatasetService,
@Inject(MAT_DIALOG_DATA) public data: any @Inject(MAT_DIALOG_DATA) public data: any
) { ) {
super(); super();
this.submitFunction = data['submitFunction']; this.inputModel = data['dialogInputModel'];
this.dmp = data['dmp']; this.outputModel = { datasetsToBeFinalized: [] };
this.formGroup = data['formGroup'];
this.isWizard = data['isWizard'];
} }
ngOnInit(): void { ngOnInit(): void { }
if(!this.isWizard) {
this.initialiseDatasetFinalizedRequest();
this.initialiseDmpFinalizedRequest();
} else {
for (let value of (this.formGroup.get('datasets').get('datasetsList') as FormArray).value) {
this.allDatasetLabels.push(value.datasetLabel);
}
}
}
initialiseDatasetFinalizedRequest() {
const request = new DataTableRequest<DatasetCriteria>(null, null, null);
request.criteria = new DatasetCriteria();
request.criteria.dmpIds = [this.dmp.id];
request.criteria.status = DatasetStatus.Finalized;
this.dmpService.getPaged(request).map(x => x.data)
.pipe(takeUntil(this._destroyed))
.subscribe(result => {
this.datasetsFinalized = result;
// this.createFormGroup();
this.datasetsFinalized.forEach(element => {
this.allDatasets.push(element);
});
});
}
initialiseDmpFinalizedRequest() {
const request = new DataTableRequest<DatasetCriteria>(null, null, null);
request.criteria = new DatasetCriteria();
request.criteria.dmpIds = [this.dmp.id];
request.criteria.status = DatasetStatus.Draft;
this.dmpService.getPaged(request).map(x => x.data)
.pipe(takeUntil(this._destroyed))
.subscribe(result => {
this.datasetsDraft = result;
this.datasetsDraft.forEach(element => {
this.allDatasets.push(element);
});
});
}
createFormGroup() {
if (this.datasetsFinalized.length > 0) {
this.formGroup = new FormBuilder().group({
datasets: [this.datasetsFinalized, this.minLengthArray(1)]
});
}
}
onSubmit() { onSubmit() {
this.touchAllFormFields(this.formGroup); this.dialogRef.close(this.outputModel);
if (!this.formGroup.valid) { return; }
this.submitFunction();
} }
minLengthArray(min: number) { getFinalizedDatasets() {
return (c: AbstractControl): { [key: string]: any } => { return this.inputModel.datasets.filter(x => x.status === DatasetStatus.Finalized);
if (c.value.length >= min) {
return null;
}
return { 'minLengthArray': { valid: false } };
};
} }
public touchAllFormFields(formControl: AbstractControl) { getDraftDatasets() {
if (formControl instanceof FormControl) { return this.inputModel.datasets.filter(x => x.status === DatasetStatus.Draft);
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);
});
}
}
isDraft(dataset: DatasetOverviewModel) {
if (dataset.status == DatasetStatus.Draft) { return true }
else { return false }
} }
close() { close() {
this.dialogRef.close(false); this.dialogRef.close({ cancelled: true } as DmpFinalizeDialogOutput);
} }
}
cancel() {
this.dialogRef.close(false); export interface DmpFinalizeDialogInput {
} dmpLabel: string;
dmpDescription: string;
datasets: DmpFinalizeDialogDataset[];
}
export interface DmpFinalizeDialogDataset {
label: string;
id?: string;
status: DatasetStatus;
}
export interface DmpFinalizeDialogOutput {
cancelled?: boolean;
datasetsToBeFinalized?: string[];
} }

View File

@ -5,8 +5,8 @@
<div class="card-desc d-flex flex-column justify-content-center"> <div class="card-desc d-flex flex-column justify-content-center">
<h4 class="card-title">{{ dmp.label }}</h4> <h4 class="card-title">{{ dmp.label }}</h4>
</div> </div>
<div *ngIf="!isPublic" class="d-flex ml-auto p-2"> <div class="d-flex ml-auto p-2">
<button *ngIf="dmp.status == 0" mat-icon-button [matMenuTriggerFor]="actionsMenu" class="ml-auto more-icon" <button *ngIf="isDraftDmp(dmp)" mat-icon-button [matMenuTriggerFor]="actionsMenu" class="ml-auto more-icon"
(click)="$event.stopImmediatePropagation();"> (click)="$event.stopImmediatePropagation();">
<mat-icon class="more-horiz">more_horiz</mat-icon> <mat-icon class="more-horiz">more_horiz</mat-icon>
</button> </button>
@ -27,6 +27,12 @@
<button mat-raised-button color="primary" (click)="downloadPDF(dmp.id)" class="lightblue-btn ml-2"> <button mat-raised-button color="primary" (click)="downloadPDF(dmp.id)" class="lightblue-btn ml-2">
<mat-icon>save_alt</mat-icon> {{ 'DMP-LISTING.ACTIONS.EXPORT' | translate }} <mat-icon>save_alt</mat-icon> {{ 'DMP-LISTING.ACTIONS.EXPORT' | translate }}
</button> </button>
<button *ngIf="showPublishButton(dmp)" mat-raised-button color="primary" (click)="publish(dmp.id)" class="lightblue-btn ml-2">
<mat-icon>public</mat-icon> {{ 'DMP-LISTING.ACTIONS.PUBLISH' | translate }}
</button>
<button *ngIf="isDraftDmp(dmp)" mat-raised-button color="primary" (click)="finalize(dmp)" class="lightblue-btn ml-2">
<mat-icon>done_all</mat-icon> {{ 'DMP-LISTING.ACTIONS.FINALIZE' | translate }}
</button>
</div> </div>
</div> </div>
<div class="row ml-2"> <div class="row ml-2">
@ -63,10 +69,10 @@
<div class="row"> <div class="row">
<div *ngFor="let dataset of dmp.datasets; let i=index" class="col-md-4"> <div *ngFor="let dataset of dmp.datasets; let i=index" class="col-md-4">
<div *ngIf="i < 9" class="dataset-card" (click)="datasetClicked(dataset.id)"> <div *ngIf="i < 9" class="dataset-card" (click)="datasetClicked(dataset.id)">
<mat-icon *ngIf="isDraft(dataset)" class="draft-bookmark">bookmark</mat-icon> <mat-icon *ngIf="isDraftDataset(dataset)" class="draft-bookmark">bookmark</mat-icon>
<mat-icon *ngIf="!isDraft(dataset)" class="finalized-bookmark">bookmark</mat-icon> <mat-icon *ngIf="!isDraftDataset(dataset)" class="finalized-bookmark">bookmark</mat-icon>
<h4 *ngIf="isDraft(dataset)"><span>{{ 'TYPES.DMP.DRAFT' | translate }}:</span> {{ dataset.label }}</h4> <h4 *ngIf="isDraftDataset(dataset)"><span>{{ 'TYPES.DMP.DRAFT' | translate }}:</span> {{ dataset.label }}</h4>
<h4 *ngIf="!isDraft(dataset)">{{ dataset.label }}</h4> <h4 *ngIf="!isDraftDataset(dataset)">{{ dataset.label }}</h4>
<div matTooltip="{{ dataset.datasetTemplate.label }}" class="chip"> <div matTooltip="{{ dataset.datasetTemplate.label }}" class="chip">
{{ dataset.datasetTemplate.label }}</div> {{ dataset.datasetTemplate.label }}</div>
</div> </div>

View File

@ -1,22 +1,27 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Params, ActivatedRoute, Router } from '@angular/router'; import { FormGroup } from '@angular/forms';
import { BaseComponent } from '../../../core/common/base/base.component';
import { DmpService } from '../../../core/services/dmp/dmp.service';
import { takeUntil } from 'rxjs/operators';
import { DmpOverviewModel } from '../../../core/model/dmp/dmp-overview';
import { TranslateService } from '@ngx-translate/core';
import { Principal } from '../../../core/model/auth/Principal';
import { AuthService } from '../../../core/services/auth/auth.service';
import { UserInfoListingModel } from '../../../core/model/user/user-info-listing';
import { DatasetOverviewModel } from '../../../core/model/dataset/dataset-overview';
import { MatDialog } from '@angular/material'; import { MatDialog } from '@angular/material';
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component'; import { ActivatedRoute, Params, Router } from '@angular/router';
import { UiNotificationService, SnackBarNotificationLevel } from '../../../core/services/notification/ui-notification-service'; import { TranslateService } from '@ngx-translate/core';
import * as FileSaver from 'file-saver'; import * as FileSaver from 'file-saver';
import { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item'; import { takeUntil } from 'rxjs/operators';
import { BaseComponent } from '../../../core/common/base/base.component';
import { DatasetStatus } from '../../../core/common/enum/dataset-status'; import { DatasetStatus } from '../../../core/common/enum/dataset-status';
import { DmpStatus } from '../../../core/common/enum/dmp-status';
import { Principal } from '../../../core/model/auth/Principal';
import { DatasetOverviewModel } from '../../../core/model/dataset/dataset-overview';
import { DmpOverviewModel } from '../../../core/model/dmp/dmp-overview';
import { UserInfoListingModel } from '../../../core/model/user/user-info-listing';
import { AuthService } from '../../../core/services/auth/auth.service';
import { DmpService } from '../../../core/services/dmp/dmp.service';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
import { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { DmpFinalizeDialogComponent, DmpFinalizeDialogInput, DmpFinalizeDialogOutput } from '../editor/dmp-finalize-dialog/dmp-finalize-dialog.component';
import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model';
import { DatasetsToBeFinalized } from '../../../core/model/dataset/datasets-toBeFinalized';
@Component({ @Component({
selector: 'app-dmp-overview', selector: 'app-dmp-overview',
@ -27,7 +32,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
dmp: DmpOverviewModel; dmp: DmpOverviewModel;
isNew = true; isNew = true;
isPublic = false; isFinalized = false;
hasPublishButton: boolean = true;
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of(); breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of();
constructor( constructor(
@ -64,7 +70,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
} }
else if (publicId != null) { else if (publicId != null) {
this.isNew = false; this.isNew = false;
this.isPublic = true; this.isFinalized = true;
this.dmpService.getOverviewSinglePublic(publicId) this.dmpService.getOverviewSinglePublic(publicId)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
@ -95,7 +101,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
} }
datasetsClicked(dmpId: String) { datasetsClicked(dmpId: String) {
if(!this.isPublic) if (!this.isFinalized)
this.router.navigate(['/datasets'], { queryParams: { dmpId: dmpId } }); this.router.navigate(['/datasets'], { queryParams: { dmpId: dmpId } });
else else
this.router.navigate(['/explore'], { queryParams: { dmpId: dmpId } }); this.router.navigate(['/explore'], { queryParams: { dmpId: dmpId } });
@ -242,8 +248,59 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
} }
} }
isDraft(dataset: DatasetOverviewModel) { isDraftDataset(dataset: DatasetOverviewModel) {
if (dataset.status == DatasetStatus.Draft) { return true } return dataset.status == DatasetStatus.Draft;
else { return false } }
isDraftDmp(dmp: DmpOverviewModel) {
return dmp.status == DmpStatus.Draft;
}
isFinalizedDmp(dmp: DmpOverviewModel) {
return dmp.status == DmpStatus.Finalized;
}
showPublishButton(dmp: DmpOverviewModel) {
return this.isFinalizedDmp(dmp) && !dmp.isPublic && this.hasPublishButton;
}
publish(dmpId: String) {
this.dmpService.publish(dmpId)
.pipe(takeUntil(this._destroyed))
.subscribe(() => { this.hasPublishButton = false });
}
finalize(dmp: DmpOverviewModel) {
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 }
})
}
const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, {
maxWidth: '500px',
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.dmp.status = DmpStatus.Finalized;
var datasetsToBeFinalized: DatasetsToBeFinalized = {
uuids: result.datasetsToBeFinalized
};
this.dmpService.finalize(datasetsToBeFinalized, this.dmp.id)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onCallbackSuccess()
);
}
});
} }
} }

View File

@ -1,14 +1,10 @@
import { DatasetDescriptionFormEditorModel } from "../../misc/dataset-description-form/dataset-description-form.model"; import { FormControl, FormGroup } from "@angular/forms";
import { DatasetProfileDefinitionModel } from "../../../core/model/dataset-profile-definition/dataset-profile-definition"; import { DatasetProfileDefinitionModel } from "../../../core/model/dataset-profile-definition/dataset-profile-definition";
import { FormGroup, FormControl } from "@angular/forms"; import { DatasetDescriptionFormEditorModel } from "../../misc/dataset-description-form/dataset-description-form.model";
export class QuickWizardDatasetDescriptionModel extends DatasetDescriptionFormEditorModel { export class QuickWizardDatasetDescriptionModel extends DatasetDescriptionFormEditorModel {
public datasetLabel: string; public datasetLabel: string;
//public status: number;
fromModel(item: DatasetProfileDefinitionModel): DatasetDescriptionFormEditorModel { fromModel(item: DatasetProfileDefinitionModel): DatasetDescriptionFormEditorModel {
super.fromModel(item); super.fromModel(item);
@ -17,8 +13,8 @@ export class QuickWizardDatasetDescriptionModel extends DatasetDescriptionFormEd
buildForm(): FormGroup { buildForm(): FormGroup {
const formGroup: FormGroup = super.buildForm(); const formGroup: FormGroup = super.buildForm();
formGroup.addControl('datasetLabel', new FormControl({value: this.datasetLabel})); formGroup.addControl('datasetLabel', new FormControl({ value: this.datasetLabel }));
formGroup.addControl('status', new FormControl({value: this.status})); formGroup.addControl('status', new FormControl({ value: this.status }));
return formGroup; return formGroup;
} }
} }

View File

@ -1,24 +1,24 @@
import { Component, OnInit, ViewChild } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms'; import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
import { MatSnackBar, MatStepper, MatDialog } from '@angular/material'; import { MatDialog, MatSnackBar, MatStepper } from '@angular/material';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model'; import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model';
import { BaseComponent } from "../../../core/common/base/base.component"; import { BaseComponent } from "../../../core/common/base/base.component";
import { DatasetStatus } from '../../../core/common/enum/dataset-status';
import { DmpStatus } from '../../../core/common/enum/dmp-status';
import { DatasetService } from '../../../core/services/dataset/dataset.service';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service'; import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
import { QuickWizardService } from '../../../core/services/quick-wizard/quick-wizard.service'; import { QuickWizardService } from '../../../core/services/quick-wizard/quick-wizard.service';
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
import { DmpFinalizeDialogComponent, DmpFinalizeDialogDataset, DmpFinalizeDialogInput } from '../../dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item'; import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent'; import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
import { DatasetEditorWizardComponent } from '../dataset-editor/dataset-editor-wizard.component';
import { ProjectEditorWizardModel } from '../project-editor/project-editor-wizard-model'; import { ProjectEditorWizardModel } from '../project-editor/project-editor-wizard-model';
import { QuickWizardEditorWizardModel } from './quick-wizard-editor.model'; import { QuickWizardEditorWizardModel } from './quick-wizard-editor.model';
import { DatasetEditorWizardComponent } from '../dataset-editor/dataset-editor-wizard.component';
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
import { DmpFinalizeDialogComponent } from '../../dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component';
import { DmpStatus } from '../../../core/common/enum/dmp-status';
import { DatasetStatus } from '../../../core/common/enum/dataset-status';
@Component({ @Component({
selector: 'app-quick-wizard-editor-component', selector: 'app-quick-wizard-editor-component',
@ -31,7 +31,8 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
@ViewChild('stepper') stepper: MatStepper; @ViewChild('stepper') stepper: MatStepper;
@ViewChild(DatasetEditorWizardComponent) datasetEditorWizardComponent: DatasetEditorWizardComponent; @ViewChild(DatasetEditorWizardComponent) datasetEditorWizardComponent: DatasetEditorWizardComponent;
isNew = true; isNew = true;
quickWizard: QuickWizardEditorWizardModel quickWizard: QuickWizardEditorWizardModel;
allDatasets: DmpFinalizeDialogDataset[] = [];
formGroup: FormGroup = null; formGroup: FormGroup = null;
constructor( constructor(
@ -39,6 +40,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
private route: ActivatedRoute, private route: ActivatedRoute,
public router: Router, public router: Router,
public language: TranslateService, public language: TranslateService,
public datasetService: DatasetService,
public quickWizardService: QuickWizardService, public quickWizardService: QuickWizardService,
private uiNotificationService: UiNotificationService, private uiNotificationService: UiNotificationService,
private dialog: MatDialog private dialog: MatDialog
@ -85,39 +87,39 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
} }
saveFinalize() { saveFinalize() {
if (!this.isFormValid()) { return; }
const dialogInputModel: DmpFinalizeDialogInput = {
dmpLabel: this.formGroup.get('dmp').get('label').value,
dmpDescription: this.formGroup.get('dmp').get('description').value,
datasets: (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls.map(x => {
return { label: x.get('datasetLabel').value, status: DatasetStatus.Finalized };
})
}
const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, { const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, {
maxWidth: '500px', maxWidth: '500px',
data: { data: {
formGroup: this.formGroup, dialogInputModel: dialogInputModel,
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'),
isWizard: true,
confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'), confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
submitFunction: () => { }
if (!this.isFormValid()) { return; } });
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result && !result.cancelled) {
if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) { if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) { for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) {
control.get('status').setValue(DatasetStatus.Finalized); control.get('status').setValue(DatasetStatus.Finalized);
} }
this.formGroup.get('dmp').get('status').setValue(DmpStatus.Finalized); this.formGroup.get('dmp').get('status').setValue(DmpStatus.Finalized);
this.onSubminSaveAndFinalize(); this.onSubmitSaveAndFinalize();
} else {
return;
}
dialogRef.close();
} }
} }
}); });
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
});
} }
hasDatasets() { hasDatasets() {
if ((this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) { return (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0;
return true;
} else {
return false;
}
} }
public isFormValid() { public isFormValid() {
@ -139,7 +141,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
} }
} }
onSubminSaveAndFinalize() { onSubmitSaveAndFinalize() {
this.quickWizardService.createQuickWizard(this.formGroup.getRawValue()) this.quickWizardService.createQuickWizard(this.formGroup.getRawValue())
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(

View File

@ -275,6 +275,8 @@
"CLONE": "Clone", "CLONE": "Clone",
"DELETE": "Delete", "DELETE": "Delete",
"EXPORT": "Export", "EXPORT": "Export",
"PUBLISH": "Publish",
"FINALIZE": "Finalize",
"ADV-EXP": "Advanced Export", "ADV-EXP": "Advanced Export",
"DOWNLOAD-XML": "Download XML", "DOWNLOAD-XML": "Download XML",
"DOWNLOAD-DOCX": "Download Document", "DOWNLOAD-DOCX": "Download Document",