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";
export interface DatasetOverviewModel {
id: String;
label: String;
id: string;
label: string;
status: any;
datasetTemplate: DatasetProfileModel;
}

View File

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

View File

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

View File

@ -19,7 +19,7 @@ export interface DmpModel {
description: String;
project: ProjectListingModel;
datasets: DatasetModel[];
datasetsToBeFinalized: String[];
datasetsToBeFinalized: string[];
profiles: DmpProfile[];
organisations: OrganizationModel[];
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 { DmpOverviewModel } from '../../model/dmp/dmp-overview';
import { DatasetListingModel } from '../../model/dataset/dataset-listing';
import { DatasetsToBeFinalized } from '../../model/dataset/datasets-toBeFinalized';
@Injectable()
export class DmpService {
@ -83,6 +84,14 @@ export class DmpService {
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 {
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 { FormGroup, FormControl } from '@angular/forms';
import { FormGroup, FormControl, FormArray } from '@angular/forms';
import { MatDialog, MatSnackBar } from '@angular/material';
import { ActivatedRoute, Params, Router } from '@angular/router';
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 { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
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 { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component';
import { UserInfoListingModel } from '../../../core/model/user/user-info-listing';
@ -259,7 +259,6 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
onCallbackError(error: any) {
this.setErrorModel(error.error);
//this.validateAllFormFields(this.formGroup);
}
@ -435,22 +434,31 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
}
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, {
maxWidth: '500px',
data: {
formGroup: this.formGroup,
dmp: this.dmp,
isWizard: false,
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'),
submitFunction: () => {
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result && !result.cancelled) {
this.formGroup.get('status').setValue(DmpStatus.Finalized);
this.formGroup.get('datasetsToBeFinalized').setValue(result.datasetsToBeFinalized);
this.formSubmit();
dialogRef.close();
}
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { });
}
}

View File

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

View File

@ -1,4 +1,76 @@
<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 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 *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()">
@ -41,7 +113,7 @@
<div *ngIf="datasetsDraft.length > 0" class="pt-4 pb-2">
<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">
<mat-list-option [value]='dataset.id'>
{{ dataset.label }}
@ -79,7 +151,8 @@
<h4 class="col-11 ml-auto mt-1 mb-4">{{ label }}</h4>
</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-accordion>
</div>
@ -95,11 +168,10 @@
<div mat-dialog-actions class="d-flex justify-content-end">
<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 class="col-auto">
<button mat-raised-button cdkFocusInitial type="button" (click)="cancel()"
class="cancel">{{ data.cancelButton }}</button>
<button mat-raised-button cdkFocusInitial (click)="close()" class="cancel">{{ data.cancelButton }}</button>
</div>
</div>
</form>
</form> -->

View File

@ -1,16 +1,9 @@
import { Component, Inject, OnInit, ViewChild } from '@angular/core';
import { AbstractControl, FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { MatDialogRef, MatSelectionList, MAT_DIALOG_DATA } from '@angular/material';
import { Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { Router } from '@angular/router';
import { takeUntil } from 'rxjs/operators';
import { BaseComponent } from '../../../../core/common/base/base.component';
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 { DatasetOverviewModel } from '../../../../core/model/dataset/dataset-overview';
@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 {
@ViewChild('datasetsDraftSelectionList') selectionList: MatSelectionList;
public formGroup: FormGroup;
public submitFunction: () => any;
public dmp: DmpModel;
public datasetsFinalized: DatasetListingModel[];
public datasetsDraft: DatasetListingModel[];
public allDatasets: DatasetListingModel[] = [];
public allDatasetLabels: String[] = [];
public isWizard: boolean;
inputModel: DmpFinalizeDialogInput;
outputModel: DmpFinalizeDialogOutput;
constructor(
public router: Router,
public dialogRef: MatDialogRef<DmpFinalizeDialogComponent>,
public dmpService: DatasetService,
public datasetService: DatasetService,
@Inject(MAT_DIALOG_DATA) public data: any
) {
super();
this.submitFunction = data['submitFunction'];
this.dmp = data['dmp'];
this.formGroup = data['formGroup'];
this.isWizard = data['isWizard'];
this.inputModel = data['dialogInputModel'];
this.outputModel = { datasetsToBeFinalized: [] };
}
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)]
});
}
}
ngOnInit(): void { }
onSubmit() {
this.touchAllFormFields(this.formGroup);
if (!this.formGroup.valid) { return; }
this.submitFunction();
this.dialogRef.close(this.outputModel);
}
minLengthArray(min: number) {
return (c: AbstractControl): { [key: string]: any } => {
if (c.value.length >= min) {
return null;
}
return { 'minLengthArray': { valid: false } };
};
getFinalizedDatasets() {
return this.inputModel.datasets.filter(x => x.status === DatasetStatus.Finalized);
}
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);
});
}
}
isDraft(dataset: DatasetOverviewModel) {
if (dataset.status == DatasetStatus.Draft) { return true }
else { return false }
getDraftDatasets() {
return this.inputModel.datasets.filter(x => x.status === DatasetStatus.Draft);
}
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">
<h4 class="card-title">{{ dmp.label }}</h4>
</div>
<div *ngIf="!isPublic" class="d-flex ml-auto p-2">
<button *ngIf="dmp.status == 0" mat-icon-button [matMenuTriggerFor]="actionsMenu" class="ml-auto more-icon"
<div class="d-flex ml-auto p-2">
<button *ngIf="isDraftDmp(dmp)" mat-icon-button [matMenuTriggerFor]="actionsMenu" class="ml-auto more-icon"
(click)="$event.stopImmediatePropagation();">
<mat-icon class="more-horiz">more_horiz</mat-icon>
</button>
@ -27,6 +27,12 @@
<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 }}
</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 class="row ml-2">
@ -63,10 +69,10 @@
<div class="row">
<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)">
<mat-icon *ngIf="isDraft(dataset)" class="draft-bookmark">bookmark</mat-icon>
<mat-icon *ngIf="!isDraft(dataset)" class="finalized-bookmark">bookmark</mat-icon>
<h4 *ngIf="isDraft(dataset)"><span>{{ 'TYPES.DMP.DRAFT' | translate }}:</span> {{ dataset.label }}</h4>
<h4 *ngIf="!isDraft(dataset)">{{ dataset.label }}</h4>
<mat-icon *ngIf="isDraftDataset(dataset)" class="draft-bookmark">bookmark</mat-icon>
<mat-icon *ngIf="!isDraftDataset(dataset)" class="finalized-bookmark">bookmark</mat-icon>
<h4 *ngIf="isDraftDataset(dataset)"><span>{{ 'TYPES.DMP.DRAFT' | translate }}:</span> {{ dataset.label }}</h4>
<h4 *ngIf="!isDraftDataset(dataset)">{{ dataset.label }}</h4>
<div matTooltip="{{ dataset.datasetTemplate.label }}" class="chip">
{{ dataset.datasetTemplate.label }}</div>
</div>

View File

@ -1,22 +1,27 @@
import { Component, OnInit } from '@angular/core';
import { Params, ActivatedRoute, Router } from '@angular/router';
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 { FormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material';
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
import { UiNotificationService, SnackBarNotificationLevel } from '../../../core/services/notification/ui-notification-service';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import * as FileSaver from 'file-saver';
import { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component';
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 { 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({
selector: 'app-dmp-overview',
@ -27,7 +32,8 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
dmp: DmpOverviewModel;
isNew = true;
isPublic = false;
isFinalized = false;
hasPublishButton: boolean = true;
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of();
constructor(
@ -64,7 +70,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
}
else if (publicId != null) {
this.isNew = false;
this.isPublic = true;
this.isFinalized = true;
this.dmpService.getOverviewSinglePublic(publicId)
.pipe(takeUntil(this._destroyed))
.subscribe(data => {
@ -95,7 +101,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
}
datasetsClicked(dmpId: String) {
if(!this.isPublic)
if (!this.isFinalized)
this.router.navigate(['/datasets'], { queryParams: { dmpId: dmpId } });
else
this.router.navigate(['/explore'], { queryParams: { dmpId: dmpId } });
@ -242,8 +248,59 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
}
}
isDraft(dataset: DatasetOverviewModel) {
if (dataset.status == DatasetStatus.Draft) { return true }
else { return false }
isDraftDataset(dataset: DatasetOverviewModel) {
return dataset.status == DatasetStatus.Draft;
}
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 { FormGroup, FormControl } from "@angular/forms";
import { DatasetDescriptionFormEditorModel } from "../../misc/dataset-description-form/dataset-description-form.model";
export class QuickWizardDatasetDescriptionModel extends DatasetDescriptionFormEditorModel {
public datasetLabel: string;
//public status: number;
fromModel(item: DatasetProfileDefinitionModel): DatasetDescriptionFormEditorModel {
super.fromModel(item);

View File

@ -1,24 +1,24 @@
import { Component, OnInit, ViewChild } from '@angular/core';
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 { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model';
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 { 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 { 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 { 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({
selector: 'app-quick-wizard-editor-component',
@ -31,7 +31,8 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
@ViewChild('stepper') stepper: MatStepper;
@ViewChild(DatasetEditorWizardComponent) datasetEditorWizardComponent: DatasetEditorWizardComponent;
isNew = true;
quickWizard: QuickWizardEditorWizardModel
quickWizard: QuickWizardEditorWizardModel;
allDatasets: DmpFinalizeDialogDataset[] = [];
formGroup: FormGroup = null;
constructor(
@ -39,6 +40,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
private route: ActivatedRoute,
public router: Router,
public language: TranslateService,
public datasetService: DatasetService,
public quickWizardService: QuickWizardService,
private uiNotificationService: UiNotificationService,
private dialog: MatDialog
@ -85,39 +87,39 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
}
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, {
maxWidth: '500px',
data: {
formGroup: this.formGroup,
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'),
isWizard: true,
dialogInputModel: dialogInputModel,
confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'),
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) {
for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) {
control.get('status').setValue(DatasetStatus.Finalized);
}
this.formGroup.get('dmp').get('status').setValue(DmpStatus.Finalized);
this.onSubminSaveAndFinalize();
} else {
return;
}
dialogRef.close();
this.onSubmitSaveAndFinalize();
}
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
});
}
hasDatasets() {
if ((this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
return true;
} else {
return false;
}
return (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0;
}
public isFormValid() {
@ -139,7 +141,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
}
}
onSubminSaveAndFinalize() {
onSubmitSaveAndFinalize() {
this.quickWizardService.createQuickWizard(this.formGroup.getRawValue())
.pipe(takeUntil(this._destroyed))
.subscribe(

View File

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