Commit 3dd57fd2865aeddc617867b34ea9a9c0941ffa3f

Authored by Vladyslav_Prykhodko
1 parent a3e21068

UI: Redesign search input widget selector

@@ -245,23 +245,24 @@ @@ -245,23 +245,24 @@
245 headerTitle="{{ 245 headerTitle="{{
246 (!widgetsBundle?.title ? 'widget.select-widgets-bundle' : 'dashboard.select-widget-value') | translate: widgetsBundle 246 (!widgetsBundle?.title ? 'widget.select-widgets-bundle' : 'dashboard.select-widget-value') | translate: widgetsBundle
247 }}" 247 }}"
248 - headerHeightPx="120" 248 + headerHeightPx="64"
  249 + [isShowSearch]="true"
249 [isReadOnly]="true" 250 [isReadOnly]="true"
250 [isEdit]="false" 251 [isEdit]="false"
251 - (closeDetails)="onAddWidgetClosed()"> 252 + backgroundColor="#cfd8dc"
  253 + (closeDetails)="onAddWidgetClosed()"
  254 + (closeSearch)="onCloseSearchBundle()">
252 <div class="prefix-title-buttons" [fxHide]="!widgetsBundle?.title" style="height: 28px; margin-right: 12px"> 255 <div class="prefix-title-buttons" [fxHide]="!widgetsBundle?.title" style="height: 28px; margin-right: 12px">
253 <button class="tb-mat-28" mat-icon-button type="button" (click)="widgetBundleSelected(null)"> 256 <button class="tb-mat-28" mat-icon-button type="button" (click)="widgetBundleSelected(null)">
254 <mat-icon>arrow_back</mat-icon> 257 <mat-icon>arrow_back</mat-icon>
255 </button> 258 </button>
256 </div> 259 </div>
257 - <div class="header-pane" *ngIf="isAddingWidget">  
258 - <div fxLayout="row" fxLayoutGap="12px">  
259 - <tb-widgets-bundle-search fxFlex  
260 - [(ngModel)]="searchBundle"  
261 - placeholder="{{ (!widgetsBundle?.title ? 'widgets-bundle.search' : 'widget.search') | translate }}"  
262 - (ngModelChange)="searchBundle = $event">  
263 - </tb-widgets-bundle-search>  
264 - </div> 260 + <div class="search-pane" *ngIf="isAddingWidget" fxLayout="row">
  261 + <tb-widgets-bundle-search fxFlex
  262 + [(ngModel)]="searchBundle"
  263 + placeholder="{{ (!widgetsBundle?.title ? 'widgets-bundle.search' : 'widget.search') | translate }}"
  264 + (ngModelChange)="searchBundle = $event">
  265 + </tb-widgets-bundle-search>
265 </div> 266 </div>
266 <div class="details-buttons" *ngIf="isAddingWidget"> 267 <div class="details-buttons" *ngIf="isAddingWidget">
267 <button mat-button mat-icon-button type="button" 268 <button mat-button mat-icon-button type="button"
@@ -884,6 +884,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC @@ -884,6 +884,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
884 884
885 addWidgetFromType(widget: WidgetInfo) { 885 addWidgetFromType(widget: WidgetInfo) {
886 this.onAddWidgetClosed(); 886 this.onAddWidgetClosed();
  887 + this.widgetTypes = [];
  888 + this.searchBundle = '';
887 this.widgetComponentService.getWidgetInfo(widget.bundleAlias, widget.typeAlias, widget.isSystemType).subscribe( 889 this.widgetComponentService.getWidgetInfo(widget.bundleAlias, widget.typeAlias, widget.isSystemType).subscribe(
888 (widgetTypeInfo) => { 890 (widgetTypeInfo) => {
889 const config: WidgetConfig = JSON.parse(widgetTypeInfo.defaultConfig); 891 const config: WidgetConfig = JSON.parse(widgetTypeInfo.defaultConfig);
@@ -1197,4 +1199,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC @@ -1197,4 +1199,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
1197 overlayRef.attach(new ComponentPortal(DisplayWidgetTypesPanelComponent, this.viewContainerRef, injector)); 1199 overlayRef.attach(new ComponentPortal(DisplayWidgetTypesPanelComponent, this.viewContainerRef, injector));
1198 this.cd.detectChanges(); 1200 this.cd.detectChanges();
1199 } 1201 }
  1202 +
  1203 + onCloseSearchBundle() {
  1204 + this.searchBundle = '';
  1205 + }
1200 } 1206 }
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 <header> 18 <header>
19 <mat-toolbar class="details-toolbar" color="primary" [ngStyle]="{height: headerHeightPx+'px'}"> 19 <mat-toolbar class="details-toolbar" color="primary" [ngStyle]="{height: headerHeightPx+'px'}">
20 <div class="mat-toolbar-tools" fxLayout="row" fxLayoutAlign="start center" style="height: 100%;"> 20 <div class="mat-toolbar-tools" fxLayout="row" fxLayoutAlign="start center" style="height: 100%;">
21 - <div class="mat-toolbar-tools tb-details-title-header" fxFlex fxLayout="column" fxLayoutAlign="start start"> 21 + <div class="mat-toolbar-tools tb-details-title-header" fxFlex fxLayout="column" fxLayoutAlign="start start" [fxHide]="showSearchPane">
22 <div class="tb-details-title" fxLayout="row" fxLayoutAlign="start center"> 22 <div class="tb-details-title" fxLayout="row" fxLayoutAlign="start center">
23 <ng-content select=".prefix-title-buttons"></ng-content> 23 <ng-content select=".prefix-title-buttons"></ng-content>
24 <span>{{ headerTitle }}</span> 24 <span>{{ headerTitle }}</span>
@@ -28,8 +28,19 @@ @@ -28,8 +28,19 @@
28 <ng-content select=".header-pane"></ng-content> 28 <ng-content select=".header-pane"></ng-content>
29 </span> 29 </span>
30 </div> 30 </div>
  31 + <div *ngIf="isShowSearch" [fxHide]="!showSearchPane" fxLayout="row" fxLayoutAlign="start center" style="width: 100%;">
  32 + <button mat-button mat-icon-button (click)="onToggleSearch()">
  33 + <mat-icon class="material-icons">arrow_back</mat-icon>
  34 + </button>
  35 + <div style="width: 100%; margin: 0 20px">
  36 + <ng-content select=".search-pane"></ng-content>
  37 + </div>
  38 + </div>
  39 + <button mat-button mat-icon-button *ngIf="isShowSearch && !showSearchPane" (click)="onToggleSearch()">
  40 + <mat-icon class="material-icons">search</mat-icon>
  41 + </button>
31 <ng-content select=".details-buttons"></ng-content> 42 <ng-content select=".details-buttons"></ng-content>
32 - <button mat-button cdkFocusInitial mat-icon-button (click)="onCloseDetails()"> 43 + <button mat-button mat-icon-button (click)="onCloseDetails()">
33 <mat-icon class="material-icons">close</mat-icon> 44 <mat-icon class="material-icons">close</mat-icon>
34 </button> 45 </button>
35 </div> 46 </div>
@@ -54,6 +65,6 @@ @@ -54,6 +65,6 @@
54 </section> 65 </section>
55 </mat-toolbar> 66 </mat-toolbar>
56 </header> 67 </header>
57 -<div fxFlex class="mat-content"> 68 +<div fxFlex class="mat-content" [ngStyle]="{backgroundColor: backgroundColor}">
58 <ng-content></ng-content> 69 <ng-content></ng-content>
59 </div> 70 </div>
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 :host ::ng-deep { 28 :host ::ng-deep {
29 .mat-toolbar-tools { 29 .mat-toolbar-tools {
30 height: 100%; 30 height: 100%;
31 - min-height: 100px; 31 + min-height: 60px;
32 max-height: 120px; 32 max-height: 120px;
33 &.tb-details-title-header { 33 &.tb-details-title-header {
34 min-width: 0; 34 min-width: 0;
@@ -32,6 +32,8 @@ export class DetailsPanelComponent extends PageComponent { @@ -32,6 +32,8 @@ export class DetailsPanelComponent extends PageComponent {
32 @Input() headerSubtitle = ''; 32 @Input() headerSubtitle = '';
33 @Input() isReadOnly = false; 33 @Input() isReadOnly = false;
34 @Input() isAlwaysEdit = false; 34 @Input() isAlwaysEdit = false;
  35 + @Input() isShowSearch = false;
  36 + @Input() backgroundColor = '#FFF';
35 37
36 theFormValue: FormGroup; 38 theFormValue: FormGroup;
37 39
@@ -50,8 +52,11 @@ export class DetailsPanelComponent extends PageComponent { @@ -50,8 +52,11 @@ export class DetailsPanelComponent extends PageComponent {
50 toggleDetailsEditMode = new EventEmitter<boolean>(); 52 toggleDetailsEditMode = new EventEmitter<boolean>();
51 @Output() 53 @Output()
52 applyDetails = new EventEmitter<void>(); 54 applyDetails = new EventEmitter<void>();
  55 + @Output()
  56 + closeSearch = new EventEmitter<void>();
53 57
54 isEditValue = false; 58 isEditValue = false;
  59 + showSearchPane = false;
55 60
56 @Output() 61 @Output()
57 isEditChange = new EventEmitter<boolean>(); 62 isEditChange = new EventEmitter<boolean>();
@@ -88,4 +93,10 @@ export class DetailsPanelComponent extends PageComponent { @@ -88,4 +93,10 @@ export class DetailsPanelComponent extends PageComponent {
88 } 93 }
89 } 94 }
90 95
  96 + onToggleSearch() {
  97 + this.showSearchPane = !this.showSearchPane;
  98 + if (!this.showSearchPane) {
  99 + this.closeSearch.emit();
  100 + }
  101 + }
91 } 102 }
@@ -15,10 +15,15 @@ @@ -15,10 +15,15 @@
15 limitations under the License. 15 limitations under the License.
16 16
17 --> 17 -->
18 -<div class="input-wrapper" fxLayoutAlign="start center" fxLayoutGap="8px"> 18 +<div class="input-wrapper" [ngClass]="{'focus': focus}" fxLayoutAlign="start center" fxLayoutGap="16px">
19 <mat-icon>search</mat-icon> 19 <mat-icon>search</mat-icon>
20 - <input type="text" [(ngModel)]="searchText" (ngModelChange)="updateSearchText()" [placeholder]=placeholder>  
21 - <button mat-button type="button" *ngIf="searchText" mat-icon-button (click)="clear()">  
22 - <mat-icon>close</mat-icon> 20 + <input type="text"
  21 + [(ngModel)]="searchText"
  22 + (ngModelChange)="updateSearchText()"
  23 + (focus)="toggleFocus()"
  24 + (blur)="toggleFocus()"
  25 + [placeholder]=placeholder>
  26 + <button mat-button type="button" *ngIf="searchText" mat-icon-button (click)="clear($event)">
  27 + <mat-icon class="close">close</mat-icon>
23 </button> 28 </button>
24 </div> 29 </div>
@@ -15,8 +15,10 @@ @@ -15,8 +15,10 @@
15 */ 15 */
16 .input-wrapper { 16 .input-wrapper {
17 background: hsla(0, 0%, 100%, .2); 17 background: hsla(0, 0%, 100%, .2);
18 - padding: 5px 0 5px 10px;  
19 - height: 40px; 18 + border-radius: 8px;
  19 + color: rgb(255, 255, 255, .84);
  20 + padding: 5px 8px 5px 16px;
  21 + height: 46px;
20 22
21 input { 23 input {
22 width: 100%; 24 width: 100%;
@@ -30,9 +32,24 @@ @@ -30,9 +32,24 @@
30 32
31 &::placeholder { 33 &::placeholder {
32 color: #fff; 34 color: #fff;
33 - opacity: .8; 35 + opacity: .6;
34 line-height: 26px; 36 line-height: 26px;
35 } 37 }
36 } 38 }
  39 +
  40 + &.focus {
  41 + background: #fff;
  42 + color: rgba(0,0,0,.54);
  43 +
  44 + input {
  45 + color: #000;
  46 + opacity: .60;
  47 + }
  48 +
  49 + .close {
  50 + color: #000 !important;
  51 + opacity: .54;
  52 + }
  53 + }
37 } 54 }
38 55
@@ -31,6 +31,7 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; @@ -31,6 +31,7 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
31 export class WidgetsBundleSearchComponent implements ControlValueAccessor { 31 export class WidgetsBundleSearchComponent implements ControlValueAccessor {
32 32
33 searchText: string; 33 searchText: string;
  34 + focus = false;
34 35
35 @Input() placeholder: string; 36 @Input() placeholder: string;
36 37
@@ -60,8 +61,14 @@ export class WidgetsBundleSearchComponent implements ControlValueAccessor { @@ -60,8 +61,14 @@ export class WidgetsBundleSearchComponent implements ControlValueAccessor {
60 this.propagateChange(this.searchText); 61 this.propagateChange(this.searchText);
61 } 62 }
62 63
63 - clear(): void { 64 + clear($event: Event): void {
  65 + $event.preventDefault();
  66 + $event.stopPropagation();
64 this.searchText = ''; 67 this.searchText = '';
65 this.updateView(); 68 this.updateView();
66 } 69 }
  70 +
  71 + toggleFocus() {
  72 + this.focus = !this.focus;
  73 + }
67 } 74 }