Adds dialog on DMP option "Save and Finalize" - (Issue #110)

This commit is contained in:
apapachristou 2019-06-21 16:55:38 +03:00
parent 9de8e7d723
commit 3242654e77
9 changed files with 213 additions and 272 deletions

View File

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

View File

@ -24,7 +24,7 @@
<div class="card-footer">
<h4 class="text-uppercase"><strong>Login</strong></h4>
<br />
<h5>You dont need to have a registered account for OpenDMP</h5>
<h5>{{ 'HOME.LOGIN' | translate }}</h5>
</div>
</div>
</div>

View File

@ -3,7 +3,7 @@
<div *ngIf="dmp" class="card">
<div class="card-header card-header-plain d-flex">
<div *ngIf="!isNew" class="card-desc d-flex flex-column justify-content-center">
<h4 class="card-title">{{ dmp.label }}</h4>
<h4 class="card-title">{{ formGroup.get('label').value }}</h4>
</div>
<div *ngIf="isNew" class="card-desc new-dmp d-flex flex-column justify-content-center">
<h4 class="card-title">{{ 'DMP-EDITOR.TITLE.NEW' | translate }}</h4>
@ -83,26 +83,20 @@
</button>
</div>
<div *ngIf="isNew">
<button mat-raised-button color="primary" (click)="cancelCreation()" type="button"
<button mat-raised-button color="primary" (click)="cancel()" type="button"
class="text-uppercase mr-2">
{{'DMP-EDITOR.ACTIONS.CANCEL' | translate}}
</button>
</div>
<!-- <div class="col"></div> -->
<!-- <div class="col-auto" *ngIf="!isNew && this.formGroup.enabled">
<button mat-raised-button color="primary" type="button" (click)="delete()">
{{'DMP-EDITOR.ACTIONS.DELETE' | translate}}
</button>
</div> -->
<div *ngIf="this.formGroup.enabled">
<div *ngIf="formGroup.enabled">
<button *ngIf="!isNew" mat-raised-button type="submit" [disabled]="!formGroup.valid" class="text-uppercase dark-theme mr-2" color="primary">
{{'DMP-EDITOR.ACTIONS.SAVE-CHANGES' | translate}}
</button>
<button *ngIf="isNew" mat-raised-button type="submit" [disabled]="!formGroup.valid" class="text-uppercase dark-theme mr-2" color="primary">
<button *ngIf="isNew" mat-raised-button type="submit" [disabled]="!formGroup.valid" class="text-uppercase dark-theme mr-2" color="primary">
{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}
</button>
</div>
<div *ngIf="this.formGroup.enabled">
<div *ngIf="formGroup.enabled">
<button type="button" mat-raised-button color="primary" [disabled]="!formGroup.valid" class="text-uppercase mr-2"
(click)="saveAndFinalize()">{{'DMP-EDITOR.ACTIONS.FINALISE' | translate}}
</button>
@ -113,191 +107,3 @@
</div>
</div>
</div>
<!-- <div class="main-content">
<div class="container-fluid">
<div class="dmp-editor">
<div>
<mat-card-title *ngIf="isNew">{{'DMP-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
<mat-card-title *ngIf="!isNew">
<h3>{{formGroup?.get('label')?.value}} </h3>
</mat-card-title>
</div>
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
<mat-card>
<mat-card-header>
<div class="col-12 row">
<div class="col"></div>
<div *ngIf="!isNew" class="col-auto">
<div class="row actions-row">
<div class="col-auto" *ngIf="!editMode && formGroup.get('status').value !== 1">
<button mat-icon-button (click)="enableForm()">
<mat-icon class="mat-24">edit</mat-icon>
</button>
</div>
<div class="col-auto" *ngIf="editMode && formGroup.get('status').value !== 1">
<button mat-icon-button (click)="disableForm()">
<mat-icon class="mat-24">lock</mat-icon>
</button>
</div>
<div class="col-auto">
<button mat-button type="button" *ngIf="!isPublic" (click)="redirectToDatasets()">
<mat-icon>arrow_right_alt</mat-icon>
<span>{{'DMP-EDITOR.ACTIONS.GO-TO-DATASETS' | translate}}</span>
</button>
</div>
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item *ngIf="!isPublic" (click)="newVersion(dmp.id, dmp.label)">
<mat-icon>queue</mat-icon>{{'DMP-LISTING.ACTIONS.NEW-VERSION' | translate}}
</button>
<button mat-menu-item *ngIf="!isPublic" (click)="clone(dmp.id)">
<mat-icon>filter_none</mat-icon>{{'DMP-LISTING.ACTIONS.CLONE' | translate}}
</button>
<button mat-menu-item *ngIf="!isPublic" (click)="viewVersions(dmp.groupId, dmp.label)">
<mat-icon>library_books</mat-icon>{{'DMP-LISTING.ACTIONS.VIEW-VERSION' | translate}}
</button>
<button mat-menu-item (click)="downloadXml(dmp.id)">
<mat-icon>save_alt</mat-icon>{{'DMP-LISTING.ACTIONS.DOWNLOAD-XML' | translate}}
</button>
<button mat-menu-item (click)="downloadDocx(dmp.id)">
<mat-icon>save_alt</mat-icon>{{'DMP-LISTING.ACTIONS.DOWNLOAD-DOCX' | translate}}
</button>
<button mat-menu-item (click)="downloadPDF(dmp.id)">
<mat-icon>save_alt</mat-icon>{{'DMP-LISTING.ACTIONS.DOWNLOAD-PDF' | translate}}
</button>
</mat-menu>
<button mat-icon-button class="col-auto" type="button" [matMenuTriggerFor]="actionsMenu">
<mat-icon>more_vert</mat-icon>
</button>
</div>
</div>
</div>
</mat-card-header>
<mat-card-content>
<div class="row">
<mat-form-field class="col-md-12">
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label"
formControlName="label" required>
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">
{{formGroup.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('label').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-12">
<textarea matInput class="description-area"
placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description">
</textarea> -->
<!-- <mat-error *ngIf="formGroup.get('description').hasError('backendError')">
{{formGroup.get('description').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('description').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' |
translate}}</mat-error> -->
<!-- </mat-form-field>
<mat-form-field class="col-md-6">
<app-single-auto-complete required='true' [formControl]="formGroup.get('project')"
placeholder="{{this.languageResolverService.getBy('dmpEditor') | translate}}"
[configuration]="projectAutoCompleteConfiguration">
</app-single-auto-complete>
<mat-error *ngIf="formGroup.get('project').hasError('backendError')">
{{formGroup.get('project').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('project').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> -->
<!-- <app-dynamic-fields-project [formGroup]="formGroup"></app-dynamic-fields-project> -->
<!-- <mat-form-field class="col-md-6">
<app-multiple-auto-complete required='true' [formControl]="formGroup.get('profiles')"
placeholder="{{'DMP-EDITOR.FIELDS.PROFILES' | translate}}"
[configuration]="profilesAutoCompleteConfiguration">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('profiles').hasError('backendError')">
{{formGroup.get('profiles').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('profiles').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<button matSuffix mat-icon-button type="button" [disabled]="formGroup.get('profiles').disabled"
(click)="availableProfiles()">
<mat-icon>view_list</mat-icon>
</button>
</mat-form-field> -->
<!-- <button mat-button (click)="availableProfiles()">View All</button> -->
<!-- <mat-form-field class="col-md-6">
<app-multiple-auto-complete [formControl]="formGroup.get('organisations')"
placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}"
[configuration]="organisationsAutoCompleteConfiguration">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('organisations').hasError('backendError')">
{{formGroup.get('organisations').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('organisations').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' |
translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-6">
<app-multiple-auto-complete [formControl]="formGroup.get('researchers')"
placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}"
[configuration]="researchersAutoCompleteConfiguration">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('researchers').hasError('backendError')">
{{formGroup.get('researchers').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('researchers').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' |
translate}}</mat-error>
<button matSuffix mat-icon-button [disabled]="formGroup.get('researchers').disabled"
type="button" (click)="addResearcher()">
<mat-icon>add_circle</mat-icon>
</button>
</mat-form-field> -->
<!-- <h4 mat-subheader class="col-12">{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}</h4> -->
<!-- <mat-form-field class="col-md-6">
<app-single-auto-complete [required]='false' [formControl]="formGroup.get('profile')"
placeholder="{{'DMP-EDITOR.FIELDS.PROFILE' | translate}}"
[configuration]="dmpProfileAutoCompleteConfiguration">
</app-single-auto-complete>
</mat-form-field>
<mat-form-field class="col-md-6">
<input matInput placeholder="Version" disabled
[value]="formGroup.get('version').value== undefined ?0 :formGroup.get('version').value">
</mat-form-field> -->
<!-- <app-dynamic-dmp-field-resolver *ngIf="dmp.definition" class="col-md-12"
[formGroup]="formGroup" [dmpProfileDefinition]=dmp.definition></app-dynamic-dmp-field-resolver> -->
<!-- <app-dynamic-dmp-field-resolver *ngIf="selectedDmpProfileDefinition" class="col-md-12"
[formGroup]="formGroup" [dmpProfileDefinition]="selectedDmpProfileDefinition">
</app-dynamic-dmp-field-resolver>
<div class="col-md-12">
<mat-list *ngIf="associatedUsers?.length" role="list" class="col-md-12">
<h3 mat-subheader>Associated Users</h3>
<mat-list-item role="listitem" *ngFor="let user of associatedUsers">
<mat-icon mat-list-icon>person</mat-icon>
<div>{{user.name}}</div>
</mat-list-item>
</mat-list>
</div>
<div class="col-md-12">
<div class="row">
<div class="col-auto"><button mat-raised-button color="primary" (click)="cancel(dmp.id)"
type="button">{{'DMP-EDITOR.ACTIONS.CANCEL'
| translate}}</button></div>
<div class="col"></div>
<div class="col-auto" *ngIf="!isNew && this.formGroup.enabled"><button mat-raised-button
color="primary" type="button"
(click)="delete()">{{'DMP-EDITOR.ACTIONS.DELETE' | translate}}</button></div>
<div class="col-auto" *ngIf="this.formGroup.enabled"><button mat-raised-button
color="primary" type="submit">{{'DMP-EDITOR.ACTIONS.SAVE'
| translate}}</button></div>
<div class="col-auto" *ngIf="dmp.lockable && this.formGroup.enabled"><button type="button"
mat-raised-button color="primary"
(click)="saveAndFinalize()">{{'DMP-EDITOR.ACTIONS.FINALISE' | translate}}</button>
</div>
</div>
</div>
</div>
</mat-card-content>
</mat-card>
</form> -->
<!-- <div *ngIf="formGroup"> {{ formGroup.value | json }}</div> -->
<!-- </div>
</div>
</div> -->

View File

@ -1,5 +1,5 @@
import { Component, OnInit, ViewContainerRef } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { FormGroup, FormControl } from '@angular/forms';
import { MatDialog, MatSnackBar } from '@angular/material';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
@ -11,16 +11,11 @@ import { BaseComponent } from '../../../core/common/base/base.component';
import { DmpStatus } from '../../../core/common/enum/dmp-status';
import { Status } from '../../../core/common/enum/Status';
import { DataTableRequest } from '../../../core/model/data-table/data-table-request';
import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing';
import { DatasetProfileModel } from '../../../core/model/dataset/dataset-profile';
import { DmpProfileDefinition } from '../../../core/model/dmp-profile/dmp-profile';
import { DmpProfileListing } from '../../../core/model/dmp-profile/dmp-profile-listing';
import { DmpModel } from '../../../core/model/dmp/dmp';
import { ExternalSourceItemModel } from '../../../core/model/external-sources/external-source-item';
import { ProjectListingModel } from '../../../core/model/project/project-listing';
import { UserModel } from '../../../core/model/user/user';
import { BaseCriteria } from '../../../core/query/base-criteria';
import { DatasetProfileCriteria } from '../../../core/query/dataset-profile/dataset-profile-criteria';
import { DmpProfileCriteria } from '../../../core/query/dmp/dmp-profile-criteria';
import { ProjectCriteria } from '../../../core/query/project/project-criteria';
import { RequestItem } from '../../../core/query/request-item';
@ -29,20 +24,17 @@ import { DmpService } from '../../../core/services/dmp/dmp.service';
import { ExternalSourcesService } from '../../../core/services/external-sources/external-sources.service';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
import { ProjectService } from '../../../core/services/project/project.service';
import { MultipleAutoCompleteConfiguration } from '../../../library/auto-complete/multiple/multiple-auto-complete-configuration';
import { SingleAutoCompleteConfiguration } from '../../../library/auto-complete/single/single-auto-complete-configuration';
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
import { LanguageResolverService } from '../../../services/language-resolver/language-resolver.service';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
import { AddResearcherComponent } from './add-researcher/add-researcher.component';
import { AvailableProfilesComponent } from './available-profiles/available-profiles.component';
import { DmpEditorModel } from './dmp-editor.model';
import { DmpFinalizeDialogComponent } 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';
import { ProjectTabModel } from './project-tab/project-tab-model';
import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing';
@Component({
selector: 'app-dmp-editor-component',
@ -163,19 +155,19 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
//this.registerFormEventsForDmpProfile(this.dmp.definition);
if (!this.editMode || this.dmp.status === Status.Inactive) { this.formGroup.disable(); }
// if (!this.isAuthenticated) {
const breadcrumbs = [];
breadcrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-PUBLIC-DMPS').toUpperCase(), url: '/plans' });
breadcrumbs.push({ parentComponentName: null, label: this.dmp.label, url: '/plans/publicEdit/' + this.dmp.id });
this.breadCrumbs = Observable.of(breadcrumbs);
// this.breadCrumbs = Observable.of([
// {
// parentComponentName: 'DmpListingComponent',
// label: this.language.instant('NAV-BAR.MY-DMPS'),
// url: 'plans',
// notFoundResolver: [await this.projectService.getSingle(this.dmp.project.id).map(x => ({ label: x.label, url: '/projects/edit/' + x.id }) as BreadcrumbItem).toPromise()]
// }]
// );
this.associatedUsers = data.associatedUsers;
const breadcrumbs = [];
breadcrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-PUBLIC-DMPS').toUpperCase(), url: '/plans' });
breadcrumbs.push({ parentComponentName: null, label: this.dmp.label, url: '/plans/publicEdit/' + this.dmp.id });
this.breadCrumbs = Observable.of(breadcrumbs);
// this.breadCrumbs = Observable.of([
// {
// parentComponentName: 'DmpListingComponent',
// label: this.language.instant('NAV-BAR.MY-DMPS'),
// url: 'plans',
// notFoundResolver: [await this.projectService.getSingle(this.dmp.project.id).map(x => ({ label: x.label, url: '/projects/edit/' + x.id }) as BreadcrumbItem).toPromise()]
// }]
// );
this.associatedUsers = data.associatedUsers;
// }
});
} else {
@ -274,12 +266,11 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
}
public cancel(id: String): void {
this.router.navigate(['/plans/overview/' + id]);
// this.router.navigate(['/plans']);
}
public cancelCreation(): void {
this.router.navigate(['/plans']);
if (id != null) {
this.router.navigate(['/plans/overview/' + id]);
} else {
this.router.navigate(['/plans']);
}
}
public invite(): void {
@ -440,15 +431,22 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
saveAndFinalize() {
const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, {
maxWidth: '500px',
data: {
submitFunction: (items: DatasetListingModel[]) => {
formGroup: this.formGroup,
dmp: this.dmp,
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: () => {
this.formGroup.get('status').setValue('1');
this.formGroup.addControl('datasets', new FormControl(items));
this.formSubmit();
dialogRef.close();
},
dmp: this.dmp
}
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
});
}
}

View File

@ -31,6 +31,7 @@ export class DmpEditorModel {
public researchers: ResearcherModel[] = [];
public profiles: DmpProfile[] = [];
public datasets: DatasetModel[] = [];
public datasetsToBeFinalized: String[] = [];
public associatedUsers: UserModel[] = [];
public users: UserInfoListingModel[] = [];
public definition: DmpProfileDefinition;
@ -51,6 +52,7 @@ export class DmpEditorModel {
this.researchers = item.researchers;
this.profiles = item.profiles;
this.datasets = item.datasets;
this.datasetsToBeFinalized = item.datasetsToBeFinalized;
this.associatedUsers = item.associatedUsers;
this.users = item.users;
if (item.definition) { this.definition = item.definition; }
@ -74,6 +76,8 @@ export class DmpEditorModel {
organisations: [{ value: this.organisations, disabled: disabled }, context.getValidation('organisations').validators],
researchers: [{ value: this.researchers, disabled: disabled }, context.getValidation('researchers').validators],
profiles: [{ value: this.profiles, disabled: disabled }, context.getValidation('profiles').validators],
datasets: [{ value: this.datasets, disabled: disabled }, context.getValidation('datasets').validators],
datasetsToBeFinalized: [{ value: this.datasetsToBeFinalized, disabled: disabled }, context.getValidation('datasetsToBeFinalized').validators],
associatedUsers: [{ value: this.associatedUsers, disabled: disabled }, context.getValidation('associatedUsers').validators],
users: [{ value: this.users, disabled: disabled }, context.getValidation('users').validators]
});
@ -98,6 +102,8 @@ export class DmpEditorModel {
baseContext.validation.push({ key: 'organisations', validators: [BackendErrorValidator(this.validationErrorModel, 'organisations')] });
baseContext.validation.push({ key: 'researchers', validators: [BackendErrorValidator(this.validationErrorModel, 'researchers')] });
baseContext.validation.push({ key: 'profiles', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'profiles')] });
baseContext.validation.push({ key: 'datasets', validators: [BackendErrorValidator(this.validationErrorModel, 'datasets')] });
baseContext.validation.push({ key: 'datasetsToBeFinalized', validators: [BackendErrorValidator(this.validationErrorModel, 'datasetsToBeFinalized')] });
baseContext.validation.push({ key: 'associatedUsers', validators: [BackendErrorValidator(this.validationErrorModel, 'associatedUsers')] });
baseContext.validation.push({ key: 'users', validators: [BackendErrorValidator(this.validationErrorModel, 'users')] });

View File

@ -1,35 +1,71 @@
<form *ngIf="formGroup" (ngSubmit)="onSubmit()">
<div mat-dialog-title>
</div>
<div mat-dialog-content *ngIf="datasetsFinalized && datasetsDraft">
<div *ngIf="datasetsFinalized.length > 0">
<h4>{{'DMP-FINALISE-DIALOG.ALREADY-FINALISED-DATASETS' | translate}}</h4>
<mat-list>
<!-- <mat-list-item *ngFor="let dataset of datasetsFinalized; let len = length"> -->
<mat-list-item *ngFor="let dataset of datasetsFinalized">
<div>{{ dataset.label }}</div>
</mat-list-item>
</mat-list>
<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 *ngIf="datasetsDraft.length > 0">
<h4>{{'DMP-FINALISE-DIALOG.FINALISE-TITLE' | translate}}</h4>
<mat-selection-list #datasetsDraftSelectionList [formControl]="this.formGroup.get('datasets')">
<!-- <div class="styleBorder" *ngFor="let dataset of datasetsDraft; let len = length"> -->
<div class="styleBorder" *ngFor="let dataset of datasetsDraft">
<mat-list-option [value]='dataset'>
</div>
<div mat-dialog-content *ngIf="datasetsFinalized && datasetsDraft" 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">
{{ formGroup.get('label').value }}
</mat-panel-description>
</mat-expansion-panel-header>
{{ formGroup.get('description').value }}
</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 *ngFor="let dataset of allDatasets" class="row pl-3 datasets">
<mat-icon *ngIf="isDraft(dataset)" class="col-1 draft-bookmark">bookmark</mat-icon>
<mat-icon *ngIf="!isDraft(dataset)" class="col-1 finalized-bookmark">bookmark</mat-icon>
<h4 *ngIf="isDraft(dataset)" class="col-11 ml-auto mt-1 mb-4">
<span>{{ 'TYPES.DATASET-STATUS.DRAFT' | translate }}:</span>
{{ dataset.label }}</h4>
<h4 *ngIf="!isDraft(dataset)" class="col-11 ml-auto mt-1 mb-4">{{ dataset.label }}</h4>
</div>
</mat-expansion-panel>
</mat-accordion>
<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')">
<div class="styleBorder" *ngFor="let dataset of datasetsDraft">
<mat-list-option [value]='dataset.id'>
{{ dataset.label }}
</mat-list-option>
</div>
</mat-selection-list>
</div>minLengthArray
<mat-error *ngIf="formGroup.get('datasets').errors?.minLengthArray">{{'DMP-FINALISE-DIALOG.VALIDATION.AT-LEAST-ONE-DATASET-FINALISED'
| translate}}</mat-error>
</div>
<mat-error *ngIf="datasetsFinalized.length == 0">{{'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 color="primary" type="submit">
{{'DMP-FINALISE-DIALOG.SUBMIT' | translate}}
</button>
<div>
<mat-error class="row pt-2 pb-2 pl-4 pr-4" >
{{ 'DMP-FINALISE-DIALOG.IMPACT' | translate }}
</mat-error>
<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 type="submit" class="confirm">{{ data.confirmButton }}</button>
</div>
<div class="col-auto">
<button mat-raised-button cdkFocusInitial type="button" (click)="cancel()"
class="cancel">{{ data.cancelButton }}</button>
</div>
</div>
</form>

View File

@ -1,5 +1,69 @@
.styleBorder {
border: 0.2em solid lightgray;
border-radius: 0.5em;
margin-bottom: 0.5em;
}
border: 0.2em solid lightgray;
border-radius: 0.5em;
margin-bottom: 0.5em;
}
.confirmation-dialog {
.confirmation-message {
padding-bottom: 20px;
}
.close-btn {
margin-left: auto;
cursor: pointer;
}
.cancel {
background-color: #aaaaaa;
color: #ffffff;
}
.confirm {
background-color: #ba2c2c;
color: #ffffff;
}
}
.dataset-card {
display: flex;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
border-radius: 6px;
color: #333333;
background: #fff;
width: 100%;
min-height: 90%;
max-height: 90%;
margin-top: 1em;
margin-bottom: 1em;
cursor: pointer;
box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.14);
}
.draft-bookmark {
color: #e7e6e6;
display: inline;
padding: 0;
}
.finalized-bookmark {
color: #92d050;
display: inline;
padding: 0;
}
.dmp-title {
font-weight: 500;
color: black;
}
.close-btn {
margin-left: auto;
cursor: pointer;
}
.datasets span {
color: #4687f0;
}

View File

@ -10,6 +10,7 @@ import { DatasetListingModel } from '../../../../core/model/dataset/dataset-list
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',
@ -20,10 +21,11 @@ export class DmpFinalizeDialogComponent extends BaseComponent implements OnInit
@ViewChild('datasetsDraftSelectionList') selectionList: MatSelectionList;
public formGroup: FormGroup;
public submitFunction: (items: DatasetListingModel[]) => any;
public submitFunction: () => any;
public dmp: DmpModel;
public datasetsFinalized: DatasetListingModel[];
public datasetsDraft: DatasetListingModel[];
public allDatasets: DatasetListingModel[] = [];
constructor(
public router: Router,
public dialogRef: MatDialogRef<DmpFinalizeDialogComponent>,
@ -33,6 +35,7 @@ export class DmpFinalizeDialogComponent extends BaseComponent implements OnInit
super();
this.submitFunction = data['submitFunction'];
this.dmp = data['dmp'];
this.formGroup = data['formGroup'];
}
ngOnInit(): void {
@ -49,7 +52,10 @@ export class DmpFinalizeDialogComponent extends BaseComponent implements OnInit
.pipe(takeUntil(this._destroyed))
.subscribe(result => {
this.datasetsFinalized = result;
this.createFormGroup();
// this.createFormGroup();
this.datasetsFinalized.forEach(element => {
this.allDatasets.push(element);
});
});
}
@ -62,20 +68,24 @@ export class DmpFinalizeDialogComponent extends BaseComponent implements OnInit
.pipe(takeUntil(this._destroyed))
.subscribe(result => {
this.datasetsDraft = result;
this.datasetsDraft.forEach(element => {
this.allDatasets.push(element);
});
});
}
createFormGroup() {
this.formGroup = new FormBuilder().group({
datasets: [this.datasetsFinalized, this.minLengthArray(1)]
});
if (this.datasetsFinalized.length > 0) {
this.formGroup = new FormBuilder().group({
datasets: [this.datasetsFinalized, 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);
this.submitFunction();
}
minLengthArray(min: number) {
@ -101,4 +111,18 @@ export class DmpFinalizeDialogComponent extends BaseComponent implements OnInit
});
}
}
isDraft(dataset: DatasetOverviewModel) {
if (dataset.status == 0) { return true }
else { return false }
}
close() {
this.dialogRef.close(false);
}
cancel() {
this.dialogRef.close(false);
}
}

View File

@ -35,6 +35,7 @@
"CONFIRMATION-DIALOG": {
"DELETE-ITEM": "Delete this item?",
"DELETE-USER": "Remove this collaborator?",
"FINALIZE-ITEM": "Finalize this item?",
"ACTIONS": {
"CONFIRM": "Yes",
"No": "No",
@ -51,7 +52,8 @@
},
"HOME": {
"DMPS": "DMPs",
"DATASETS": "Datasets"
"DATASETS": "Datasets",
"LOGIN": "You dont need to have a registered account for OpenDMP"
},
"NAV-BAR": {
"BREADCRUMB-ROOT": "Dashboard",
@ -842,13 +844,17 @@
}
},
"DMP-FINALISE-DIALOG": {
"DMP": "DMP",
"DATASETS": "Datasets",
"SUBMIT": "Submit",
"FINALISE-TITLE": "Do you want to finalise any of the following Datasets?",
"FINALISE-TITLE": "Do you want to finalise any of the following Draft Datasets?",
"ALREADY-FINALISED-DATASETS": "Already Finalized Datasets",
"NONE": "None",
"VALIDATION": {
"AT-LEAST-ONE-DATASET-FINALISED": "You need to have at least one Dataset Finalized"
}
},
"IMPACT": "This action will finalize your DMP, and you won't be able to edit it again. Unfinalized Datasets will stay Draft.",
"AFTER-FINALIZATION": "After finalizing your DMP you can Publish it, and it'll be publicly available to the OpenDMP tool."
},
"DRAFTS": {
"FOR-DMP": "For DMP:",