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) {
if (createListing) this.addListing(mainDocumentPart, indent, true, true);
compositeFields.forEach(compositeField -> {
if (visibilityRuleService.isElementVisible(compositeField.getId())) {
if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) {
if (compositeField.getTitle() != null && !compositeField.getTitle().isEmpty() && !createListing) {
XWPFParagraph paragraph = addParagraphContent(compositeField.getNumbering() + " " + compositeField.getTitle(), mainDocumentPart, ParagraphStyle.HEADER3, numId);
CTDecimalNumber number = paragraph.getCTP().getPPr().getNumPr().addNewIlvl();
@ -175,11 +175,6 @@ public class WordBuilder {
return paragraph;
}
public void addStyling(List<TextStyle> styles, String color) {
}
public void addListing(XWPFDocument document, int indent, Boolean question, Boolean hasIndication) {
CTLvl cTLvl = this.cTAbstractNum.addNewLvl();
@ -237,4 +232,7 @@ public class WordBuilder {
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) {
Element elementComposites = element.createElement("composite-fields");
compositeFields.forEach(compositeField -> {
if (visibilityRuleService.isElementVisible(compositeField.getId())) {
if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) {
Element composite = element.createElement("composite-field");
composite.setAttribute("id", compositeField.getId());
if (compositeField.getTitle() != null && !compositeField.getTitle().isEmpty()) {
@ -101,4 +101,8 @@ public class ExportXmlBuilder {
});
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">
<tbody>
<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>
</tbody>
</table>

View File

@ -88,6 +88,13 @@ const appRoutes: Routes = [
breadcrumb: true
},
},
{
path: 'login/admin',
loadChildren: './ui/auth/admin-login/admin-login.module#AdminLoginModule',
data: {
breadcrumb: true
},
},
{
path: 'login',
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 { LoginInfo } from '../../model/auth/login-info';
import { Principal } from '../../model/auth/Principal';
import { UiNotificationService, SnackBarNotificationLevel } from '../notification/ui-notification-service';
@Injectable()
@ -20,9 +21,10 @@ export class AuthService extends BaseService {
constructor(
private http: HttpClient,
public snackBar: MatSnackBar,
public language: TranslateService,
public router: Router
private snackBar: MatSnackBar,
private language: TranslateService,
private router: Router,
private uiNotificationService: UiNotificationService
) {
super();
this.actionUrl = environment.Server + 'auth/';
@ -133,18 +135,12 @@ export class AuthService extends BaseService {
}
public onLogOutSuccess(logoutMessage: any) {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.SUCCESSFUL-LOGOUT', language: this.language },
duration: 3000,
});
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-LOGOUT'), SnackBarNotificationLevel.Success);
this.router.navigate(['/login']);
}
public onLogOutError(errorMessage: string) {
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
data: { message: 'GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGOUT', language: this.language },
duration: 3000,
});
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-LOGOUT'), SnackBarNotificationLevel.Error);
this.router.navigate(['/login']);
}
}

View File

@ -1,10 +1,10 @@
<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)">
{{this._displayFn(selectedItem)}}
<mat-icon matChipRemove *ngIf="!disabled && removable">cancel</mat-icon>
</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-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)">

View File

@ -1,6 +1,13 @@
<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-progress-spinner mode="indeterminate" [class.not-loading]="!loading" [diameter]="17"></mat-progress-spinner>
<mat-chip-list #chipList [disabled]="disabled" class="chip-list">
<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)">
<span *ngIf="_groupedItems">
<mat-optgroup *ngFor="let group of _groupedItems | async" [label]="group.title">

View File

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

View File

@ -1,4 +1,5 @@
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 { ControlValueAccessor, NgControl } from '@angular/forms';
import { MatAutocompleteSelectedEvent, MatFormFieldControl } from '@angular/material';
@ -36,6 +37,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
private requestDelay = 200; //ms
private minFilteringChars = 1;
private loadDataOnStart = true;
separatorKeysCodes: number[] = [ENTER, COMMA];
get empty() {
return !this._inputValue || this._inputValue.length === 0;
@ -73,7 +75,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
}
set value(value: any | null) {
this._selectedValue = value;
this._inputValue = value;
if (value && value != "") { this._inputValue = " "; }
this.stateChanges.next();
}
private _selectedValue;
@ -147,6 +149,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
_optionSelected(event: MatAutocompleteSelectedEvent) {
this._setValue(this.configuration.valueAssign ? this.configuration.valueAssign(event.option.value) : event.option.value);
//this._inputValue = " ";
this.stateChanges.next();
this.optionSelected.emit(event.option.value);
}
@ -212,6 +215,10 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
}
}
chipRemove(): void {
this.value = null;
}
ngOnDestroy() {
this.stateChanges.complete();
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="card col-md-8 col-md-offset-2">
<div class="card-header">
<h4>Login</h4>
<div class="social-btns">
<div>
<div class="card-form">
<div class="form-row">
<i class="material-icons">person</i>
<mat-form-field color="accent">
<input type="text" [(ngModel)]="credential.username" matInput placeholder="Username" />
</mat-form-field>
</div>
<div class="form-row">
<i class="material-icons">lock_outline</i>
<mat-form-field color="accent">
<input type="password" [(ngModel)]="credential.secret" matInput placeholder="Password" />
</mat-form-field>
</div>
</div>
<div class="card-footer">
<button mat-button (click)="nativeLogin()">LOGIN</button>
</div>
</div>
</div>
<h4>Admin Login</h4>
</div>
<!-- <div class="social-btns">
<div>
<div class="card-form">
<div class="form-row">
<i class="material-icons">person</i> -->
<mat-form-field color="accent">
<input type="text" [(ngModel)]="credential.username" matInput placeholder="Username" />
</mat-form-field>
<!-- </div>
<div class="form-row"> -->
<!-- <i class="material-icons">lock_outline</i> -->
<mat-form-field color="accent">
<input type="password" [(ngModel)]="credential.secret" matInput placeholder="Password" />
</mat-form-field>
<!-- </div>
</div> -->
<div>
<button mat-raised-button color="primary" (click)="nativeLogin()">LOGIN</button>
</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 {
public auth2: any;
public credential: Credential;
public credential: Credential;
constructor(
private authService: AuthService,
@ -29,6 +29,10 @@ export class AdminLoginComponent extends BaseComponent implements OnInit {
ngOnInit() {
this.credential = {
username: null,
secret: null
}
}
public nativeLogin() {