From 74ae77edbc9fd15e588a7d1458c1b7346f64f746 Mon Sep 17 00:00:00 2001 From: apapachristou Date: Mon, 23 Sep 2019 14:06:58 +0300 Subject: [PATCH] Fixes bug on External References undo finalize. (Issue #162) --- .../single-auto-complete-configuration.ts | 2 + .../single-auto-complete.component.html | 1 + .../single/single-auto-complete.component.ts | 5 +++ .../dataset-wizard.component.html | 41 ++++++------------ .../dataset-wizard.component.ts | 25 ++++++----- .../dmp-listing-item.component.html | 2 +- dmp-frontend/src/assets/i18n/en.json | 1 + dmp-frontend/src/assets/scss/blue-theme.scss | 42 ++++++++++++------- .../src/assets/scss/material-dashboard.scss | 3 +- 9 files changed, 67 insertions(+), 55 deletions(-) diff --git a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete-configuration.ts b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete-configuration.ts index 6628279f6..b893bfe9b 100644 --- a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete-configuration.ts +++ b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete-configuration.ts @@ -22,6 +22,8 @@ export interface SingleAutoCompleteConfiguration { titleFn?: (item: any) => string; // Property formating for dropdown subtitleFn?: (item: any) => string; + // Property formating for icon on chip + iconFn?: (item: any) => string; //Extra data passed to query function extraData?: any; // Callback to intercept value assignment based on item selection diff --git a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.html b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.html index 46fd53fe5..fb886bd5f 100644 --- a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.html +++ b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.html @@ -1,6 +1,7 @@
+ {{_iconFn(value)}} {{_displayFn(value)}} cancel diff --git a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts index 1a49d15c1..0650c290f 100644 --- a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts +++ b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts @@ -137,6 +137,11 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl< return null; } + _iconFn(item: any): string { + if (this.configuration.iconFn && item) { return this.configuration.iconFn(item); } + return null; + } + _requestDelay(): number { return this.configuration.requestDelay || this.requestDelay; } diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html index e402503ab..92394f152 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html @@ -12,27 +12,22 @@
- - - + -
@@ -47,14 +42,11 @@
- + - + {{profile.label}} @@ -71,8 +63,7 @@ {{'DATASET-PROFILE-EDITOR.STEPS.PAGES.EXTERNAL-REFERENCES' | translate}} - + @@ -82,27 +73,21 @@ {{'DATASET-PROFILE-EDITOR.STEPS.PAGES.DESCRIPTION' | translate}} - +
+ info_outlined +
{{'DATASET-WIZARD.ACTIONS.INFO' | translate}}
- - + +
- +
diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts index 4d0433a42..635f0bed9 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts @@ -1,7 +1,5 @@ - -import {of as observableOf, Observable } from 'rxjs'; - -import {map, catchError, takeUntil } from 'rxjs/operators'; +import { of as observableOf, Observable } from 'rxjs'; +import { map, catchError, takeUntil } from 'rxjs/operators'; import { Component, OnInit, ViewChild } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; @@ -63,7 +61,6 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr profileUpdateId: string; downloadDocumentId: string; isLinear = false; - hasReversableStatus: boolean = false; constructor( private datasetWizardService: DatasetWizardService, @@ -92,8 +89,9 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr this.dmpAutoCompleteConfiguration = { filterFn: this.searchDmp.bind(this), initialItems: (extraData) => this.searchDmp(''), - displayFn: (item) => item['label'], - titleFn: (item) => item['label'] + displayFn: (item) => (item['status'] ? this.language.instant('TYPES.DATASET-STATUS.FINALISED').toUpperCase() : this.language.instant('TYPES.DATASET-STATUS.DRAFT').toUpperCase()) + ': ' + item['label'], + titleFn: (item) => item['label'], + iconFn: (item) => item['status'] ? 'lock' : 'lock_open' }; const params = this.route.snapshot.params; @@ -137,9 +135,6 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr this.registerFormListeners(); // this.availableProfiles = this.datasetWizardModel.dmp.profiles; - if (this.formGroup.get('dmp').value.status == DmpStatus.Draft && this.formGroup.get('status').value == DatasetStatus.Finalized) { - this.hasReversableStatus = true; - } }, error => { this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATAESET-NOT-FOUND'), SnackBarNotificationLevel.Error); @@ -433,8 +428,16 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr this.submit(); } + hasReversableStatus(): boolean { + return (this.formGroup.get('dmp').value.status == DmpStatus.Draft && this.formGroup.get('status').value == DatasetStatus.Finalized); + } + + hasNotReversableStatus(): boolean { + return (this.formGroup.get('dmp').value.status == DmpStatus.Finalized && this.formGroup.get('status').value == DatasetStatus.Finalized); + } + reverse() { - this.hasReversableStatus = false; + this.viewOnly = false; this.datasetWizardModel.status = DatasetStatus.Draft; setTimeout(x => { this.formGroup = null; }); setTimeout(x => { diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html index 2bdffd51c..e0ff36982 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html @@ -29,7 +29,7 @@
- lock + lock_open lock diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 889bc55ef..4125c87d7 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -415,6 +415,7 @@ "SAVE-AND-FINALISE": "Save and Finalize", "FINALIZE": "Finalize", "REVERSE": "Undo Finalization", + "INFO": "Datasets of finalized DMPs can't revert to unfinalized", "DOWNLOAD-PDF": "Download PDF", "DOWNLOAD-XML": "Download XML", "DOWNLOAD-DOCX": "Download DOCX", diff --git a/dmp-frontend/src/assets/scss/blue-theme.scss b/dmp-frontend/src/assets/scss/blue-theme.scss index d3a21dbd4..52e4e8d81 100644 --- a/dmp-frontend/src/assets/scss/blue-theme.scss +++ b/dmp-frontend/src/assets/scss/blue-theme.scss @@ -35,20 +35,34 @@ $app-blue-theme-primary-palette: ( ); $app-blue-theme-accent-palette: ( - 50: #fce4ec, - 100: #f8bbd0, - 200: #f48fb1, - 300: #f06292, - 400: #ec407a, - 500: #e91e63, - 600: #d81b60, - 700: #c2185b, - 800: #ad1457, - 900: #880e4f, - A100: #ff80ab, - A200: #ff4081, - A400: #f50057, - A700: #c51162, + 50 : #e0f6f3, + 100 : #b3e8e2, + 200 : #80d9cf, + 300 : #4dc9bc, + 400 : #26bead, + 500 : #00b29f, + 600 : #00ab97, + 700 : #00a28d, + 800 : #009983, + 900 : #008a72, + A100 : #b6fff0, + A200 : #83ffe6, + A400 : #50ffdc, + A700 : #36ffd7, + // 50: #fce4ec, + // 100: #f8bbd0, + // 200: #f48fb1, + // 300: #f06292, + // 400: #ec407a, + // 500: #e91e63, + // 600: #d81b60, + // 700: #c2185b, + // 800: #ad1457, + // 900: #880e4f, + // A100: #ff80ab, + // A200: #ff4081, + // A400: #f50057, + // A700: #c51162, contrast: ( 50: $black-87-opacity, 100: $black-87-opacity, diff --git a/dmp-frontend/src/assets/scss/material-dashboard.scss b/dmp-frontend/src/assets/scss/material-dashboard.scss index 03d5f6943..3ca0d9f37 100644 --- a/dmp-frontend/src/assets/scss/material-dashboard.scss +++ b/dmp-frontend/src/assets/scss/material-dashboard.scss @@ -22,7 +22,8 @@ // Define a theme. $custom-theme-primary: mat-palette($app-blue-theme-primary-palette, 900); -$custom-theme-accent: mat-palette($mat-pink, A200, A100, A400); +$custom-theme-accent: mat-palette($app-blue-theme-accent-palette); +// $custom-theme-accent: mat-palette($mat-pink, A200, A100, A400); $custom-theme-warn: mat-palette($mat-red); $custom-theme: mat-light-theme($custom-theme-primary, $custom-theme-accent, $custom-theme-warn); @include angular-material-theme($custom-theme);