Commit 3dd57fd2865aeddc617867b34ea9a9c0941ffa3f
1 parent
a3e21068
UI: Redesign search input widget selector
Showing
8 changed files
with
80 additions
and
22 deletions
... | ... | @@ -245,23 +245,24 @@ |
245 | 245 | headerTitle="{{ |
246 | 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 | 250 | [isReadOnly]="true" |
250 | 251 | [isEdit]="false" |
251 | - (closeDetails)="onAddWidgetClosed()"> | |
252 | + backgroundColor="#cfd8dc" | |
253 | + (closeDetails)="onAddWidgetClosed()" | |
254 | + (closeSearch)="onCloseSearchBundle()"> | |
252 | 255 | <div class="prefix-title-buttons" [fxHide]="!widgetsBundle?.title" style="height: 28px; margin-right: 12px"> |
253 | 256 | <button class="tb-mat-28" mat-icon-button type="button" (click)="widgetBundleSelected(null)"> |
254 | 257 | <mat-icon>arrow_back</mat-icon> |
255 | 258 | </button> |
256 | 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 | 266 | </div> |
266 | 267 | <div class="details-buttons" *ngIf="isAddingWidget"> |
267 | 268 | <button mat-button mat-icon-button type="button" | ... | ... |
... | ... | @@ -884,6 +884,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC |
884 | 884 | |
885 | 885 | addWidgetFromType(widget: WidgetInfo) { |
886 | 886 | this.onAddWidgetClosed(); |
887 | + this.widgetTypes = []; | |
888 | + this.searchBundle = ''; | |
887 | 889 | this.widgetComponentService.getWidgetInfo(widget.bundleAlias, widget.typeAlias, widget.isSystemType).subscribe( |
888 | 890 | (widgetTypeInfo) => { |
889 | 891 | const config: WidgetConfig = JSON.parse(widgetTypeInfo.defaultConfig); |
... | ... | @@ -1197,4 +1199,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC |
1197 | 1199 | overlayRef.attach(new ComponentPortal(DisplayWidgetTypesPanelComponent, this.viewContainerRef, injector)); |
1198 | 1200 | this.cd.detectChanges(); |
1199 | 1201 | } |
1202 | + | |
1203 | + onCloseSearchBundle() { | |
1204 | + this.searchBundle = ''; | |
1205 | + } | |
1200 | 1206 | } | ... | ... |
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | <header> |
19 | 19 | <mat-toolbar class="details-toolbar" color="primary" [ngStyle]="{height: headerHeightPx+'px'}"> |
20 | 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 | 22 | <div class="tb-details-title" fxLayout="row" fxLayoutAlign="start center"> |
23 | 23 | <ng-content select=".prefix-title-buttons"></ng-content> |
24 | 24 | <span>{{ headerTitle }}</span> |
... | ... | @@ -28,8 +28,19 @@ |
28 | 28 | <ng-content select=".header-pane"></ng-content> |
29 | 29 | </span> |
30 | 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 | 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 | 44 | <mat-icon class="material-icons">close</mat-icon> |
34 | 45 | </button> |
35 | 46 | </div> |
... | ... | @@ -54,6 +65,6 @@ |
54 | 65 | </section> |
55 | 66 | </mat-toolbar> |
56 | 67 | </header> |
57 | -<div fxFlex class="mat-content"> | |
68 | +<div fxFlex class="mat-content" [ngStyle]="{backgroundColor: backgroundColor}"> | |
58 | 69 | <ng-content></ng-content> |
59 | 70 | </div> | ... | ... |
... | ... | @@ -32,6 +32,8 @@ export class DetailsPanelComponent extends PageComponent { |
32 | 32 | @Input() headerSubtitle = ''; |
33 | 33 | @Input() isReadOnly = false; |
34 | 34 | @Input() isAlwaysEdit = false; |
35 | + @Input() isShowSearch = false; | |
36 | + @Input() backgroundColor = '#FFF'; | |
35 | 37 | |
36 | 38 | theFormValue: FormGroup; |
37 | 39 | |
... | ... | @@ -50,8 +52,11 @@ export class DetailsPanelComponent extends PageComponent { |
50 | 52 | toggleDetailsEditMode = new EventEmitter<boolean>(); |
51 | 53 | @Output() |
52 | 54 | applyDetails = new EventEmitter<void>(); |
55 | + @Output() | |
56 | + closeSearch = new EventEmitter<void>(); | |
53 | 57 | |
54 | 58 | isEditValue = false; |
59 | + showSearchPane = false; | |
55 | 60 | |
56 | 61 | @Output() |
57 | 62 | isEditChange = new EventEmitter<boolean>(); |
... | ... | @@ -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 | 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 | 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 | 28 | </button> |
24 | 29 | </div> | ... | ... |
... | ... | @@ -15,8 +15,10 @@ |
15 | 15 | */ |
16 | 16 | .input-wrapper { |
17 | 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 | 23 | input { |
22 | 24 | width: 100%; |
... | ... | @@ -30,9 +32,24 @@ |
30 | 32 | |
31 | 33 | &::placeholder { |
32 | 34 | color: #fff; |
33 | - opacity: .8; | |
35 | + opacity: .6; | |
34 | 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 | 31 | export class WidgetsBundleSearchComponent implements ControlValueAccessor { |
32 | 32 | |
33 | 33 | searchText: string; |
34 | + focus = false; | |
34 | 35 | |
35 | 36 | @Input() placeholder: string; |
36 | 37 | |
... | ... | @@ -60,8 +61,14 @@ export class WidgetsBundleSearchComponent implements ControlValueAccessor { |
60 | 61 | this.propagateChange(this.searchText); |
61 | 62 | } |
62 | 63 | |
63 | - clear(): void { | |
64 | + clear($event: Event): void { | |
65 | + $event.preventDefault(); | |
66 | + $event.stopPropagation(); | |
64 | 67 | this.searchText = ''; |
65 | 68 | this.updateView(); |
66 | 69 | } |
70 | + | |
71 | + toggleFocus() { | |
72 | + this.focus = !this.focus; | |
73 | + } | |
67 | 74 | } | ... | ... |