UI: Redesign search input widget selector

This commit is contained in:
Vladyslav_Prykhodko 2021-03-04 19:38:30 +02:00
parent a3e2106888
commit 3dd57fd286
8 changed files with 80 additions and 22 deletions

View File

@ -245,23 +245,24 @@
headerTitle="{{ headerTitle="{{
(!widgetsBundle?.title ? 'widget.select-widgets-bundle' : 'dashboard.select-widget-value') | translate: widgetsBundle (!widgetsBundle?.title ? 'widget.select-widgets-bundle' : 'dashboard.select-widget-value') | translate: widgetsBundle
}}" }}"
headerHeightPx="120" headerHeightPx="64"
[isShowSearch]="true"
[isReadOnly]="true" [isReadOnly]="true"
[isEdit]="false" [isEdit]="false"
(closeDetails)="onAddWidgetClosed()"> backgroundColor="#cfd8dc"
(closeDetails)="onAddWidgetClosed()"
(closeSearch)="onCloseSearchBundle()">
<div class="prefix-title-buttons" [fxHide]="!widgetsBundle?.title" style="height: 28px; margin-right: 12px"> <div class="prefix-title-buttons" [fxHide]="!widgetsBundle?.title" style="height: 28px; margin-right: 12px">
<button class="tb-mat-28" mat-icon-button type="button" (click)="widgetBundleSelected(null)"> <button class="tb-mat-28" mat-icon-button type="button" (click)="widgetBundleSelected(null)">
<mat-icon>arrow_back</mat-icon> <mat-icon>arrow_back</mat-icon>
</button> </button>
</div> </div>
<div class="header-pane" *ngIf="isAddingWidget"> <div class="search-pane" *ngIf="isAddingWidget" fxLayout="row">
<div fxLayout="row" fxLayoutGap="12px"> <tb-widgets-bundle-search fxFlex
<tb-widgets-bundle-search fxFlex [(ngModel)]="searchBundle"
[(ngModel)]="searchBundle" placeholder="{{ (!widgetsBundle?.title ? 'widgets-bundle.search' : 'widget.search') | translate }}"
placeholder="{{ (!widgetsBundle?.title ? 'widgets-bundle.search' : 'widget.search') | translate }}" (ngModelChange)="searchBundle = $event">
(ngModelChange)="searchBundle = $event"> </tb-widgets-bundle-search>
</tb-widgets-bundle-search>
</div>
</div> </div>
<div class="details-buttons" *ngIf="isAddingWidget"> <div class="details-buttons" *ngIf="isAddingWidget">
<button mat-button mat-icon-button type="button" <button mat-button mat-icon-button type="button"

View File

@ -884,6 +884,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
addWidgetFromType(widget: WidgetInfo) { addWidgetFromType(widget: WidgetInfo) {
this.onAddWidgetClosed(); this.onAddWidgetClosed();
this.widgetTypes = [];
this.searchBundle = '';
this.widgetComponentService.getWidgetInfo(widget.bundleAlias, widget.typeAlias, widget.isSystemType).subscribe( this.widgetComponentService.getWidgetInfo(widget.bundleAlias, widget.typeAlias, widget.isSystemType).subscribe(
(widgetTypeInfo) => { (widgetTypeInfo) => {
const config: WidgetConfig = JSON.parse(widgetTypeInfo.defaultConfig); const config: WidgetConfig = JSON.parse(widgetTypeInfo.defaultConfig);
@ -1197,4 +1199,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
overlayRef.attach(new ComponentPortal(DisplayWidgetTypesPanelComponent, this.viewContainerRef, injector)); overlayRef.attach(new ComponentPortal(DisplayWidgetTypesPanelComponent, this.viewContainerRef, injector));
this.cd.detectChanges(); this.cd.detectChanges();
} }
onCloseSearchBundle() {
this.searchBundle = '';
}
} }

View File

@ -18,7 +18,7 @@
<header> <header>
<mat-toolbar class="details-toolbar" color="primary" [ngStyle]="{height: headerHeightPx+'px'}"> <mat-toolbar class="details-toolbar" color="primary" [ngStyle]="{height: headerHeightPx+'px'}">
<div class="mat-toolbar-tools" fxLayout="row" fxLayoutAlign="start center" style="height: 100%;"> <div class="mat-toolbar-tools" fxLayout="row" fxLayoutAlign="start center" style="height: 100%;">
<div class="mat-toolbar-tools tb-details-title-header" fxFlex fxLayout="column" fxLayoutAlign="start start"> <div class="mat-toolbar-tools tb-details-title-header" fxFlex fxLayout="column" fxLayoutAlign="start start" [fxHide]="showSearchPane">
<div class="tb-details-title" fxLayout="row" fxLayoutAlign="start center"> <div class="tb-details-title" fxLayout="row" fxLayoutAlign="start center">
<ng-content select=".prefix-title-buttons"></ng-content> <ng-content select=".prefix-title-buttons"></ng-content>
<span>{{ headerTitle }}</span> <span>{{ headerTitle }}</span>
@ -28,8 +28,19 @@
<ng-content select=".header-pane"></ng-content> <ng-content select=".header-pane"></ng-content>
</span> </span>
</div> </div>
<div *ngIf="isShowSearch" [fxHide]="!showSearchPane" fxLayout="row" fxLayoutAlign="start center" style="width: 100%;">
<button mat-button mat-icon-button (click)="onToggleSearch()">
<mat-icon class="material-icons">arrow_back</mat-icon>
</button>
<div style="width: 100%; margin: 0 20px">
<ng-content select=".search-pane"></ng-content>
</div>
</div>
<button mat-button mat-icon-button *ngIf="isShowSearch && !showSearchPane" (click)="onToggleSearch()">
<mat-icon class="material-icons">search</mat-icon>
</button>
<ng-content select=".details-buttons"></ng-content> <ng-content select=".details-buttons"></ng-content>
<button mat-button cdkFocusInitial mat-icon-button (click)="onCloseDetails()"> <button mat-button mat-icon-button (click)="onCloseDetails()">
<mat-icon class="material-icons">close</mat-icon> <mat-icon class="material-icons">close</mat-icon>
</button> </button>
</div> </div>
@ -54,6 +65,6 @@
</section> </section>
</mat-toolbar> </mat-toolbar>
</header> </header>
<div fxFlex class="mat-content"> <div fxFlex class="mat-content" [ngStyle]="{backgroundColor: backgroundColor}">
<ng-content></ng-content> <ng-content></ng-content>
</div> </div>

View File

@ -28,7 +28,7 @@
:host ::ng-deep { :host ::ng-deep {
.mat-toolbar-tools { .mat-toolbar-tools {
height: 100%; height: 100%;
min-height: 100px; min-height: 60px;
max-height: 120px; max-height: 120px;
&.tb-details-title-header { &.tb-details-title-header {
min-width: 0; min-width: 0;

View File

@ -32,6 +32,8 @@ export class DetailsPanelComponent extends PageComponent {
@Input() headerSubtitle = ''; @Input() headerSubtitle = '';
@Input() isReadOnly = false; @Input() isReadOnly = false;
@Input() isAlwaysEdit = false; @Input() isAlwaysEdit = false;
@Input() isShowSearch = false;
@Input() backgroundColor = '#FFF';
theFormValue: FormGroup; theFormValue: FormGroup;
@ -50,8 +52,11 @@ export class DetailsPanelComponent extends PageComponent {
toggleDetailsEditMode = new EventEmitter<boolean>(); toggleDetailsEditMode = new EventEmitter<boolean>();
@Output() @Output()
applyDetails = new EventEmitter<void>(); applyDetails = new EventEmitter<void>();
@Output()
closeSearch = new EventEmitter<void>();
isEditValue = false; isEditValue = false;
showSearchPane = false;
@Output() @Output()
isEditChange = new EventEmitter<boolean>(); isEditChange = new EventEmitter<boolean>();
@ -88,4 +93,10 @@ export class DetailsPanelComponent extends PageComponent {
} }
} }
onToggleSearch() {
this.showSearchPane = !this.showSearchPane;
if (!this.showSearchPane) {
this.closeSearch.emit();
}
}
} }

View File

@ -15,10 +15,15 @@
limitations under the License. limitations under the License.
--> -->
<div class="input-wrapper" fxLayoutAlign="start center" fxLayoutGap="8px"> <div class="input-wrapper" [ngClass]="{'focus': focus}" fxLayoutAlign="start center" fxLayoutGap="16px">
<mat-icon>search</mat-icon> <mat-icon>search</mat-icon>
<input type="text" [(ngModel)]="searchText" (ngModelChange)="updateSearchText()" [placeholder]=placeholder> <input type="text"
<button mat-button type="button" *ngIf="searchText" mat-icon-button (click)="clear()"> [(ngModel)]="searchText"
<mat-icon>close</mat-icon> (ngModelChange)="updateSearchText()"
(focus)="toggleFocus()"
(blur)="toggleFocus()"
[placeholder]=placeholder>
<button mat-button type="button" *ngIf="searchText" mat-icon-button (click)="clear($event)">
<mat-icon class="close">close</mat-icon>
</button> </button>
</div> </div>

View File

@ -15,8 +15,10 @@
*/ */
.input-wrapper { .input-wrapper {
background: hsla(0, 0%, 100%, .2); background: hsla(0, 0%, 100%, .2);
padding: 5px 0 5px 10px; border-radius: 8px;
height: 40px; color: rgb(255, 255, 255, .84);
padding: 5px 8px 5px 16px;
height: 46px;
input { input {
width: 100%; width: 100%;
@ -30,9 +32,24 @@
&::placeholder { &::placeholder {
color: #fff; color: #fff;
opacity: .8; opacity: .6;
line-height: 26px; line-height: 26px;
} }
} }
&.focus {
background: #fff;
color: rgba(0,0,0,.54);
input {
color: #000;
opacity: .60;
}
.close {
color: #000 !important;
opacity: .54;
}
}
} }

View File

@ -31,6 +31,7 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
export class WidgetsBundleSearchComponent implements ControlValueAccessor { export class WidgetsBundleSearchComponent implements ControlValueAccessor {
searchText: string; searchText: string;
focus = false;
@Input() placeholder: string; @Input() placeholder: string;
@ -60,8 +61,14 @@ export class WidgetsBundleSearchComponent implements ControlValueAccessor {
this.propagateChange(this.searchText); this.propagateChange(this.searchText);
} }
clear(): void { clear($event: Event): void {
$event.preventDefault();
$event.stopPropagation();
this.searchText = ''; this.searchText = '';
this.updateView(); this.updateView();
} }
toggleFocus() {
this.focus = !this.focus;
}
} }