Fixes bug on External References undo finalize. (Issue #162)

This commit is contained in:
apapachristou 2019-09-23 14:06:58 +03:00
parent 47f939af81
commit 74ae77edbc
9 changed files with 67 additions and 55 deletions

View File

@ -22,6 +22,8 @@ export interface SingleAutoCompleteConfiguration {
titleFn?: (item: any) => string; titleFn?: (item: any) => string;
// Property formating for dropdown // Property formating for dropdown
subtitleFn?: (item: any) => string; subtitleFn?: (item: any) => string;
// Property formating for icon on chip
iconFn?: (item: any) => string;
//Extra data passed to query function //Extra data passed to query function
extraData?: any; extraData?: any;
// Callback to intercept value assignment based on item selection // Callback to intercept value assignment based on item selection

View File

@ -1,6 +1,7 @@
<div class="row auto-complete"> <div class="row auto-complete">
<mat-chip-list #chipList [disabled]="disabled" class="chip-list"> <mat-chip-list #chipList [disabled]="disabled" class="chip-list">
<mat-chip *ngIf="value" [removable]="true" (removed)="chipRemove()"> <mat-chip *ngIf="value" [removable]="true" (removed)="chipRemove()">
<mat-icon matChipRemove *ngIf="_iconFn(value)" class="ml-0 mr-1">{{_iconFn(value)}}</mat-icon>
{{_displayFn(value)}} {{_displayFn(value)}}
<mat-icon matChipRemove *ngIf="!disabled">cancel</mat-icon> <mat-icon matChipRemove *ngIf="!disabled">cancel</mat-icon>
</mat-chip> </mat-chip>

View File

@ -137,6 +137,11 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
return null; return null;
} }
_iconFn(item: any): string {
if (this.configuration.iconFn && item) { return this.configuration.iconFn(item); }
return null;
}
_requestDelay(): number { _requestDelay(): number {
return this.configuration.requestDelay || this.requestDelay; return this.configuration.requestDelay || this.requestDelay;
} }

View File

@ -12,27 +12,22 @@
</div> </div>
</div> </div>
<div class="d-flex ml-auto p-2" *ngIf="datasetWizardModel && !isNew"> <div class="d-flex ml-auto p-2" *ngIf="datasetWizardModel && !isNew">
<button mat-icon-button [matMenuTriggerFor]="actionsMenu" class="ml-auto more-icon" <button mat-icon-button [matMenuTriggerFor]="actionsMenu" class="ml-auto more-icon" *ngIf="!publicMode" (click)="$event.stopImmediatePropagation();">
*ngIf="!publicMode" (click)="$event.stopImmediatePropagation();">
<mat-icon class="more-horiz">more_horiz</mat-icon> <mat-icon class="more-horiz">more_horiz</mat-icon>
</button> </button>
<mat-menu #actionsMenu="matMenu"> <mat-menu #actionsMenu="matMenu">
<button mat-menu-item (click)="openDmpSearchDialogue()" class="menu-item"> <button mat-menu-item (click)="openDmpSearchDialogue()" class="menu-item">
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}} <mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
</button> </button>
<button mat-menu-item *ngIf="!viewOnly && !isCopy" <button mat-menu-item *ngIf="!viewOnly && !isCopy" (click)="openConfirm(formGroup.get('label').value, formGroup.get('id').value)" class="menu-item">
(click)="openConfirm(formGroup.get('label').value, formGroup.get('id').value)"
class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }} <mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}
</button> </button>
<button mat-menu-item (click)="advancedClicked()" class="menu-item"> <button mat-menu-item (click)="advancedClicked()" class="menu-item">
<mat-icon>save_alt</mat-icon>{{ 'DMP-LISTING.ACTIONS.ADV-EXP' | translate }} <mat-icon>save_alt</mat-icon>{{ 'DMP-LISTING.ACTIONS.ADV-EXP' | translate }}
</button> </button>
<button mat-menu-item *ngIf="needsUpdate()" class="menu-item" <button mat-menu-item *ngIf="needsUpdate()" class="menu-item" (click)="openUpdateDatasetProfileDialogue();">{{ 'DATASET-WIZARD.ACTIONS.UPDATE-DATASET-PROFILE' | translate }}</button>
(click)="openUpdateDatasetProfileDialogue();">{{ 'DATASET-WIZARD.ACTIONS.UPDATE-DATASET-PROFILE' | translate }}</button>
</mat-menu> </mat-menu>
<button mat-raised-button color="primary" (click)="downloadPDF()" <button mat-raised-button color="primary" (click)="downloadPDF()" class="lightblue-btn ml-2 text-uppercase">
class="lightblue-btn ml-2 text-uppercase">
<mat-icon>save_alt</mat-icon> {{ 'DMP-LISTING.ACTIONS.EXPORT' | translate }} <mat-icon>save_alt</mat-icon> {{ 'DMP-LISTING.ACTIONS.EXPORT' | translate }}
</button> </button>
</div> </div>
@ -47,14 +42,11 @@
</ng-template> </ng-template>
<form *ngIf="formGroup" [formGroup]="formGroup" class="p-3"> <form *ngIf="formGroup" [formGroup]="formGroup" class="p-3">
<mat-form-field class="col-md-6"> <mat-form-field class="col-md-6">
<app-single-auto-complete [required]="true" [formControl]="formGroup.get('dmp')" <app-single-auto-complete [required]="true" [formControl]="formGroup.get('dmp')" placeholder="{{'DATASET-EDITOR.FIELDS.DMP' | translate}}" [configuration]="dmpAutoCompleteConfiguration">
placeholder="{{'DATASET-EDITOR.FIELDS.DMP' | translate}}"
[configuration]="dmpAutoCompleteConfiguration">
</app-single-auto-complete> </app-single-auto-complete>
</mat-form-field> </mat-form-field>
<mat-form-field class="col-md-6"> <mat-form-field class="col-md-6">
<mat-select placeholder=" {{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" <mat-select placeholder=" {{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" [required]="true" formControlName="profile">
[required]="true" formControlName="profile">
<mat-option *ngFor="let profile of availableProfiles" [value]="profile.id"> <mat-option *ngFor="let profile of availableProfiles" [value]="profile.id">
{{profile.label}} {{profile.label}}
</mat-option> </mat-option>
@ -71,8 +63,7 @@
{{'DATASET-PROFILE-EDITOR.STEPS.PAGES.EXTERNAL-REFERENCES' | translate}} {{'DATASET-PROFILE-EDITOR.STEPS.PAGES.EXTERNAL-REFERENCES' | translate}}
</ng-template> </ng-template>
<form *ngIf="formGroup" [formGroup]="formGroup" class="p-3"> <form *ngIf="formGroup" [formGroup]="formGroup" class="p-3">
<app-dataset-external-references-editor-component [formGroup]="formGroup" <app-dataset-external-references-editor-component [formGroup]="formGroup" [viewOnly]="viewOnly"></app-dataset-external-references-editor-component>
[viewOnly]="viewOnly"></app-dataset-external-references-editor-component>
</form> </form>
</mat-tab> </mat-tab>
<mat-tab [disabled]="isNew && (formGroup.get('profile').disabled || formGroup.get('profile').invalid)"> <mat-tab [disabled]="isNew && (formGroup.get('profile').disabled || formGroup.get('profile').invalid)">
@ -82,27 +73,21 @@
{{'DATASET-PROFILE-EDITOR.STEPS.PAGES.DESCRIPTION' | translate}} {{'DATASET-PROFILE-EDITOR.STEPS.PAGES.DESCRIPTION' | translate}}
</div> </div>
</ng-template> </ng-template>
<app-dataset-description-form <app-dataset-description-form *ngIf="formGroup && datasetWizardModel && datasetWizardModel.datasetProfileDefinition" [form]="this.formGroup.get('datasetProfileDefinition')" [visibilityRules]="datasetWizardModel.datasetProfileDefinition.rules" [datasetProfileId]="formGroup.get('profile').value">
*ngIf="formGroup && datasetWizardModel && datasetWizardModel.datasetProfileDefinition"
[form]="this.formGroup.get('datasetProfileDefinition')"
[visibilityRules]="datasetWizardModel.datasetProfileDefinition.rules"
[datasetProfileId]="formGroup.get('profile').value">
</app-dataset-description-form> </app-dataset-description-form>
</mat-tab> </mat-tab>
</mat-tab-group> </mat-tab-group>
<div class="actions"> <div class="actions">
<mat-icon *ngIf="hasNotReversableStatus()" color="accent" class="align-self-center mr-1">info_outlined</mat-icon>
<div *ngIf="hasNotReversableStatus()" class="align-self-center mr-3">{{'DATASET-WIZARD.ACTIONS.INFO' | translate}}</div>
<button mat-raised-button (click)="cancel()" type="button" class="cancelButton" color="primary"> <button mat-raised-button (click)="cancel()" type="button" class="cancelButton" color="primary">
{{'DMP-EDITOR.ACTIONS.CANCEL' | translate}} {{'DMP-EDITOR.ACTIONS.CANCEL' | translate}}
</button> </button>
<button *ngIf="datasetWizardModel.status == 0 || isNew" mat-raised-button [disabled]="!isSemiFormValid(formGroup)" class="saveButton" color="primary" (click)="save();" <button *ngIf="datasetWizardModel.status == 0 || isNew" mat-raised-button [disabled]="!isSemiFormValid(formGroup)" class="saveButton" color="primary" (click)="save();" type="button">{{ 'DATASET-WIZARD.ACTIONS.SAVE' | translate }}</button>
type="button">{{ 'DATASET-WIZARD.ACTIONS.SAVE' | translate }}</button> <button *ngIf="datasetWizardModel.status == 0 || isNew" mat-raised-button [disabled]="!formGroup.valid" class="finalizeButton" color="primary" (click)="saveFinalize();" type="button">{{ 'DATASET-WIZARD.ACTIONS.FINALIZE' | translate }}</button>
<button *ngIf="datasetWizardModel.status == 0 || isNew" mat-raised-button [disabled]="!formGroup.valid" class="finalizeButton" color="primary"
(click)="saveFinalize();"
type="button">{{ 'DATASET-WIZARD.ACTIONS.FINALIZE' | translate }}</button>
<div class="fill-space"></div> <div class="fill-space"></div>
<button *ngIf="hasReversableStatus" mat-raised-button class="reverseButton" color="primary" (click)="reverse();" <button *ngIf="hasReversableStatus()" mat-raised-button class="reverseButton" color="primary" (click)="reverse()" type="button">{{ 'DATASET-WIZARD.ACTIONS.REVERSE' | translate }}</button>
type="button">{{ 'DATASET-WIZARD.ACTIONS.REVERSE' | translate }}</button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -1,7 +1,5 @@
import { of as observableOf, Observable } from 'rxjs';
import {of as observableOf, Observable } from 'rxjs'; import { map, catchError, takeUntil } from 'rxjs/operators';
import {map, catchError, takeUntil } from 'rxjs/operators';
import { Component, OnInit, ViewChild } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms'; import { FormControl, FormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
@ -63,7 +61,6 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
profileUpdateId: string; profileUpdateId: string;
downloadDocumentId: string; downloadDocumentId: string;
isLinear = false; isLinear = false;
hasReversableStatus: boolean = false;
constructor( constructor(
private datasetWizardService: DatasetWizardService, private datasetWizardService: DatasetWizardService,
@ -92,8 +89,9 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.dmpAutoCompleteConfiguration = { this.dmpAutoCompleteConfiguration = {
filterFn: this.searchDmp.bind(this), filterFn: this.searchDmp.bind(this),
initialItems: (extraData) => this.searchDmp(''), initialItems: (extraData) => this.searchDmp(''),
displayFn: (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'] titleFn: (item) => item['label'],
iconFn: (item) => item['status'] ? 'lock' : 'lock_open'
}; };
const params = this.route.snapshot.params; const params = this.route.snapshot.params;
@ -137,9 +135,6 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.registerFormListeners(); this.registerFormListeners();
// this.availableProfiles = this.datasetWizardModel.dmp.profiles; // 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 => { error => {
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATAESET-NOT-FOUND'), SnackBarNotificationLevel.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(); 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() { reverse() {
this.hasReversableStatus = false; this.viewOnly = false;
this.datasetWizardModel.status = DatasetStatus.Draft; this.datasetWizardModel.status = DatasetStatus.Draft;
setTimeout(x => { this.formGroup = null; }); setTimeout(x => { this.formGroup = null; });
setTimeout(x => { setTimeout(x => {

View File

@ -29,7 +29,7 @@
<div class="row"> <div class="row">
<div class="col-12 d-flex flex-wrap"> <div class="col-12 d-flex flex-wrap">
<mat-icon *ngIf="isDraft" matTooltip="{{'DMP-LISTING.TOOLTIP.DMP-STATUS.DRAFT' | translate}}" class="draft-icon"> <mat-icon *ngIf="isDraft" matTooltip="{{'DMP-LISTING.TOOLTIP.DMP-STATUS.DRAFT' | translate}}" class="draft-icon">
lock lock_open
</mat-icon> </mat-icon>
<mat-icon *ngIf="isFinalized && !isPublished" matTooltip="{{'DMP-LISTING.TOOLTIP.DMP-STATUS.FINALIZED' | translate}}"> <mat-icon *ngIf="isFinalized && !isPublished" matTooltip="{{'DMP-LISTING.TOOLTIP.DMP-STATUS.FINALIZED' | translate}}">
lock lock

View File

@ -415,6 +415,7 @@
"SAVE-AND-FINALISE": "Save and Finalize", "SAVE-AND-FINALISE": "Save and Finalize",
"FINALIZE": "Finalize", "FINALIZE": "Finalize",
"REVERSE": "Undo Finalization", "REVERSE": "Undo Finalization",
"INFO": "Datasets of finalized DMPs can't revert to unfinalized",
"DOWNLOAD-PDF": "Download PDF", "DOWNLOAD-PDF": "Download PDF",
"DOWNLOAD-XML": "Download XML", "DOWNLOAD-XML": "Download XML",
"DOWNLOAD-DOCX": "Download DOCX", "DOWNLOAD-DOCX": "Download DOCX",

View File

@ -35,20 +35,34 @@ $app-blue-theme-primary-palette: (
); );
$app-blue-theme-accent-palette: ( $app-blue-theme-accent-palette: (
50: #fce4ec, 50 : #e0f6f3,
100: #f8bbd0, 100 : #b3e8e2,
200: #f48fb1, 200 : #80d9cf,
300: #f06292, 300 : #4dc9bc,
400: #ec407a, 400 : #26bead,
500: #e91e63, 500 : #00b29f,
600: #d81b60, 600 : #00ab97,
700: #c2185b, 700 : #00a28d,
800: #ad1457, 800 : #009983,
900: #880e4f, 900 : #008a72,
A100: #ff80ab, A100 : #b6fff0,
A200: #ff4081, A200 : #83ffe6,
A400: #f50057, A400 : #50ffdc,
A700: #c51162, 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: ( contrast: (
50: $black-87-opacity, 50: $black-87-opacity,
100: $black-87-opacity, 100: $black-87-opacity,

View File

@ -22,7 +22,8 @@
// Define a theme. // Define a theme.
$custom-theme-primary: mat-palette($app-blue-theme-primary-palette, 900); $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-warn: mat-palette($mat-red);
$custom-theme: mat-light-theme($custom-theme-primary, $custom-theme-accent, $custom-theme-warn); $custom-theme: mat-light-theme($custom-theme-primary, $custom-theme-accent, $custom-theme-warn);
@include angular-material-theme($custom-theme); @include angular-material-theme($custom-theme);