Merge branch 'ui-refactoring' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-refactoring

This commit is contained in:
Diamantis Tziotzios 2019-02-15 12:26:37 +02:00
commit 80570787d0
11 changed files with 80 additions and 48 deletions

View File

@ -134,7 +134,7 @@ public class WordBuilder {
public void createCompositeFields(List<FieldSet> compositeFields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService) { public void createCompositeFields(List<FieldSet> compositeFields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService) {
if (createListing) this.addListing(mainDocumentPart, indent, true, true); if (createListing) this.addListing(mainDocumentPart, indent, true, true);
compositeFields.forEach(compositeField -> { compositeFields.forEach(compositeField -> {
if (visibilityRuleService.isElementVisible(compositeField.getId())) { if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) {
if (compositeField.getTitle() != null && !compositeField.getTitle().isEmpty() && !createListing) { if (compositeField.getTitle() != null && !compositeField.getTitle().isEmpty() && !createListing) {
XWPFParagraph paragraph = addParagraphContent(compositeField.getNumbering() + " " + compositeField.getTitle(), mainDocumentPart, ParagraphStyle.HEADER3, numId); XWPFParagraph paragraph = addParagraphContent(compositeField.getNumbering() + " " + compositeField.getTitle(), mainDocumentPart, ParagraphStyle.HEADER3, numId);
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl(); CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
@ -175,11 +175,6 @@ public class WordBuilder {
return paragraph; return paragraph;
} }
public void addStyling(List<TextStyle> styles, String color) {
}
public void addListing(XWPFDocument document, int indent, Boolean question, Boolean hasIndication) { public void addListing(XWPFDocument document, int indent, Boolean question, Boolean hasIndication) {
CTLvl cTLvl = this.cTAbstractNum.addNewLvl(); CTLvl cTLvl = this.cTAbstractNum.addNewLvl();
@ -237,4 +232,7 @@ public class WordBuilder {
return null; return null;
} }
private boolean hasVisibleFields(FieldSet compositeFields, VisibilityRuleService visibilityRuleService) {
return compositeFields.getFields().stream().anyMatch(field -> visibilityRuleService.isElementVisible(field.getId()));
}
} }

View File

@ -66,7 +66,7 @@ public class ExportXmlBuilder {
public Element createCompositeFields(List<FieldSet> compositeFields, VisibilityRuleService visibilityRuleService, Document element) { public Element createCompositeFields(List<FieldSet> compositeFields, VisibilityRuleService visibilityRuleService, Document element) {
Element elementComposites = element.createElement("composite-fields"); Element elementComposites = element.createElement("composite-fields");
compositeFields.forEach(compositeField -> { compositeFields.forEach(compositeField -> {
if (visibilityRuleService.isElementVisible(compositeField.getId())) { if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) {
Element composite = element.createElement("composite-field"); Element composite = element.createElement("composite-field");
composite.setAttribute("id", compositeField.getId()); composite.setAttribute("id", compositeField.getId());
if (compositeField.getTitle() != null && !compositeField.getTitle().isEmpty()) { if (compositeField.getTitle() != null && !compositeField.getTitle().isEmpty()) {
@ -101,4 +101,8 @@ public class ExportXmlBuilder {
}); });
return elementFields; return elementFields;
} }
private boolean hasVisibleFields(FieldSet compositeFields, VisibilityRuleService visibilityRuleService) {
return compositeFields.getFields().stream().anyMatch(field -> visibilityRuleService.isElementVisible(field.getId()));
}
} }

View File

@ -271,7 +271,7 @@
<table border="0" cellpadding="0" cellspacing="0"> <table border="0" cellpadding="0" cellspacing="0">
<tbody> <tbody>
<tr> <tr>
<td> <a href="{host}/dmps/invitation/{invitationID}" target="_blank">Join</a> </td> <td> <a href="{host}/plans/invitation/{invitationID}" target="_blank">Join</a> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -88,6 +88,13 @@ const appRoutes: Routes = [
breadcrumb: true breadcrumb: true
}, },
}, },
{
path: 'login/admin',
loadChildren: './ui/auth/admin-login/admin-login.module#AdminLoginModule',
data: {
breadcrumb: true
},
},
{ {
path: 'login', path: 'login',
loadChildren: './ui/auth/login/login.module#LoginModule', loadChildren: './ui/auth/login/login.module#LoginModule',

View File

@ -11,6 +11,7 @@ import { BaseService } from '../../common/base/base.service';
import { Credential } from '../../model/auth/credential'; import { Credential } from '../../model/auth/credential';
import { LoginInfo } from '../../model/auth/login-info'; import { LoginInfo } from '../../model/auth/login-info';
import { Principal } from '../../model/auth/Principal'; import { Principal } from '../../model/auth/Principal';
import { UiNotificationService, SnackBarNotificationLevel } from '../notification/ui-notification-service';
@Injectable() @Injectable()
@ -20,9 +21,10 @@ export class AuthService extends BaseService {
constructor( constructor(
private http: HttpClient, private http: HttpClient,
public snackBar: MatSnackBar, private snackBar: MatSnackBar,
public language: TranslateService, private language: TranslateService,
public router: Router private router: Router,
private uiNotificationService: UiNotificationService
) { ) {
super(); super();
this.actionUrl = environment.Server + 'auth/'; this.actionUrl = environment.Server + 'auth/';
@ -133,18 +135,12 @@ export class AuthService extends BaseService {
} }
public onLogOutSuccess(logoutMessage: any) { public onLogOutSuccess(logoutMessage: any) {
this.snackBar.openFromComponent(SnackBarNotificationComponent, { this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-LOGOUT'), SnackBarNotificationLevel.Success);
data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-LOGOUT', language: this.language },
duration: 3000,
});
this.router.navigate(['/login']); this.router.navigate(['/login']);
} }
public onLogOutError(errorMessage: string) { public onLogOutError(errorMessage: string) {
this.snackBar.openFromComponent(SnackBarNotificationComponent, { this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGOUT'), SnackBarNotificationLevel.Error);
data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGOUT', language: this.language },
duration: 3000,
});
this.router.navigate(['/login']); this.router.navigate(['/login']);
} }
} }

View File

@ -1,10 +1,10 @@
<div class="row multiple-auto-complete"> <div class="row multiple-auto-complete">
<mat-chip-list #chipList ngDefaultControl class="col multi-chip-list"> <mat-chip-list #chipList ngDefaultControl class="col multi-chip-list" [disabled]="disabled">
<mat-chip *ngFor="let selectedItem of _chipItems()" [disabled]="disabled" [selectable]="selectable" [removable]="removable" (removed)="_removeSelectedItem(selectedItem)"> <mat-chip *ngFor="let selectedItem of _chipItems()" [disabled]="disabled" [selectable]="selectable" [removable]="removable" (removed)="_removeSelectedItem(selectedItem)">
{{this._displayFn(selectedItem)}} {{this._displayFn(selectedItem)}}
<mat-icon matChipRemove *ngIf="!disabled && removable">cancel</mat-icon> <mat-icon matChipRemove *ngIf="!disabled && removable">cancel</mat-icon>
</mat-chip> </mat-chip>
<input matInput #textInput autocomplete="off" (focus)="_onInputFocus()" [placeholder]="placeholder" [ngModel]="_inputValue" (ngModelChange)="_inputValueChange($event)" [matAutocomplete]="auto" [matChipInputFor]="chipList" [matChipInputSeparatorKeyCodes]="separatorKeysCodes" [matChipInputAddOnBlur]="addOnBlur" (matChipInputTokenEnd)="_addItem($event)" (click)="_onInputClick($event)" /> <input matInput #textInput autocomplete="off" (focus)="_onInputFocus()" [disabled]="disabled" [placeholder]="placeholder" [ngModel]="_inputValue" (ngModelChange)="_inputValueChange($event)" [matAutocomplete]="auto" [matChipInputFor]="chipList" [matChipInputSeparatorKeyCodes]="separatorKeysCodes" [matChipInputAddOnBlur]="addOnBlur" (matChipInputTokenEnd)="_addItem($event)" (click)="_onInputClick($event)" />
</mat-chip-list> </mat-chip-list>
<mat-progress-spinner mode="indeterminate" class="multi-loading-bar col-auto" [class.not-loading]="!loading" [diameter]="22"></mat-progress-spinner> <mat-progress-spinner mode="indeterminate" class="multi-loading-bar col-auto" [class.not-loading]="!loading" [diameter]="22"></mat-progress-spinner>
<mat-autocomplete #auto="matAutocomplete" [displayWith]="_displayFn.bind(this)" (optionSelected)="_optionSelected($event)"> <mat-autocomplete #auto="matAutocomplete" [displayWith]="_displayFn.bind(this)" (optionSelected)="_optionSelected($event)">

View File

@ -1,6 +1,13 @@
<div class="row auto-complete"> <div class="row auto-complete">
<input matInput class="col" autocomplete="off" [placeholder]="placeholder" [matAutocomplete]="auto" [ngModel]="_inputValue" (ngModelChange)="_inputValueChange($event)" [disabled]="disabled" (focus)="_onInputFocus()"> <mat-chip-list #chipList [disabled]="disabled" class="chip-list">
<mat-progress-spinner mode="indeterminate" [class.not-loading]="!loading" [diameter]="17"></mat-progress-spinner> <mat-chip *ngIf="value" [removable]="true" (removed)="chipRemove()">
{{_displayFn(value)}}
<mat-icon matChipRemove *ngIf="!disabled">cancel</mat-icon>
</mat-chip>
<input matInput class="col" autocomplete="off" [placeholder]="placeholder" [matAutocomplete]="auto" [ngModel]="_inputValue" (ngModelChange)="_inputValueChange($event)" [disabled]="disabled || (value != null && value !== '')" (focus)="_onInputFocus()" [matChipInputFor]="chipList" [matChipInputSeparatorKeyCodes]="separatorKeysCodes" [matChipInputAddOnBlur]="true">
</mat-chip-list>
<mat-progress-spinner class="progress-loader" mode="indeterminate" [class.not-loading]="!loading" [diameter]="17"></mat-progress-spinner>
<mat-autocomplete #auto="matAutocomplete" [displayWith]="_displayFn.bind(this)" (optionSelected)="_optionSelected($event)"> <mat-autocomplete #auto="matAutocomplete" [displayWith]="_displayFn.bind(this)" (optionSelected)="_optionSelected($event)">
<span *ngIf="_groupedItems"> <span *ngIf="_groupedItems">
<mat-optgroup *ngFor="let group of _groupedItems | async" [label]="group.title"> <mat-optgroup *ngFor="let group of _groupedItems | async" [label]="group.title">

View File

@ -5,9 +5,18 @@
.not-loading { .not-loading {
display: none; display: none;
} }
.chip-list {
width: 100%;
}
.progress-loader {
position: absolute;
right: 0;
}
} }
.two-line-mat-option { .two-line-mat-option {
height: 3.5em; height: 3.5em;
line-height: 1.2em; line-height: 1.2em;
} }

View File

@ -1,4 +1,5 @@
import { FocusMonitor } from '@angular/cdk/a11y'; import { FocusMonitor } from '@angular/cdk/a11y';
import { COMMA, ENTER } from '@angular/cdk/keycodes';
import { Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Optional, Output, Self } from '@angular/core'; import { Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Optional, Output, Self } from '@angular/core';
import { ControlValueAccessor, NgControl } from '@angular/forms'; import { ControlValueAccessor, NgControl } from '@angular/forms';
import { MatAutocompleteSelectedEvent, MatFormFieldControl } from '@angular/material'; import { MatAutocompleteSelectedEvent, MatFormFieldControl } from '@angular/material';
@ -36,6 +37,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
private requestDelay = 200; //ms private requestDelay = 200; //ms
private minFilteringChars = 1; private minFilteringChars = 1;
private loadDataOnStart = true; private loadDataOnStart = true;
separatorKeysCodes: number[] = [ENTER, COMMA];
get empty() { get empty() {
return !this._inputValue || this._inputValue.length === 0; return !this._inputValue || this._inputValue.length === 0;
@ -73,7 +75,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
} }
set value(value: any | null) { set value(value: any | null) {
this._selectedValue = value; this._selectedValue = value;
this._inputValue = value; if (value && value != "") { this._inputValue = " "; }
this.stateChanges.next(); this.stateChanges.next();
} }
private _selectedValue; private _selectedValue;
@ -147,6 +149,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
_optionSelected(event: MatAutocompleteSelectedEvent) { _optionSelected(event: MatAutocompleteSelectedEvent) {
this._setValue(this.configuration.valueAssign ? this.configuration.valueAssign(event.option.value) : event.option.value); this._setValue(this.configuration.valueAssign ? this.configuration.valueAssign(event.option.value) : event.option.value);
//this._inputValue = " ";
this.stateChanges.next(); this.stateChanges.next();
this.optionSelected.emit(event.option.value); this.optionSelected.emit(event.option.value);
} }
@ -212,6 +215,10 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
} }
} }
chipRemove(): void {
this.value = null;
}
ngOnDestroy() { ngOnDestroy() {
this.stateChanges.complete(); this.stateChanges.complete();
this.fm.stopMonitoring(this.elRef.nativeElement); this.fm.stopMonitoring(this.elRef.nativeElement);

View File

@ -4,31 +4,31 @@
<div class="row col-md-6 col-sm-6 col-md-offset-3 col-sm-offset-3"> <div class="row col-md-6 col-sm-6 col-md-offset-3 col-sm-offset-3">
<div class="card col-md-8 col-md-offset-2"> <div class="card col-md-8 col-md-offset-2">
<div class="card-header"> <div class="card-header">
<h4>Login</h4> <h4>Admin Login</h4>
<div class="social-btns"> </div>
<div> <!-- <div class="social-btns">
<div class="card-form"> <div>
<div class="form-row"> <div class="card-form">
<i class="material-icons">person</i> <div class="form-row">
<mat-form-field color="accent"> <i class="material-icons">person</i> -->
<input type="text" [(ngModel)]="credential.username" matInput placeholder="Username" /> <mat-form-field color="accent">
</mat-form-field> <input type="text" [(ngModel)]="credential.username" matInput placeholder="Username" />
</div> </mat-form-field>
<div class="form-row"> <!-- </div>
<i class="material-icons">lock_outline</i> <div class="form-row"> -->
<mat-form-field color="accent"> <!-- <i class="material-icons">lock_outline</i> -->
<input type="password" [(ngModel)]="credential.secret" matInput placeholder="Password" /> <mat-form-field color="accent">
</mat-form-field> <input type="password" [(ngModel)]="credential.secret" matInput placeholder="Password" />
</div> </mat-form-field>
</div> <!-- </div>
<div class="card-footer"> </div> -->
<button mat-button (click)="nativeLogin()">LOGIN</button> <div>
</div> <button mat-raised-button color="primary" (click)="nativeLogin()">LOGIN</button>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- </div>
</div> -->

View File

@ -16,7 +16,7 @@ import { AuthService } from '../../../core/services/auth/auth.service';
export class AdminLoginComponent extends BaseComponent implements OnInit { export class AdminLoginComponent extends BaseComponent implements OnInit {
public auth2: any; public auth2: any;
public credential: Credential; public credential: Credential;
constructor( constructor(
private authService: AuthService, private authService: AuthService,
@ -29,6 +29,10 @@ export class AdminLoginComponent extends BaseComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.credential = {
username: null,
secret: null
}
} }
public nativeLogin() { public nativeLogin() {