This is an automated email from the ASF dual-hosted git repository. tobiasistvan pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ambari-logsearch.git
The following commit(s) were added to refs/heads/master by this push: new 5020f56 [AMBARI-24975] Log Search UI: if there are multiple clusters - selecting one of it does not do anything (#50) 5020f56 is described below commit 5020f565c431f88939070c472610ed7ecbb01f6f Author: Istvan Tobias <tobias.ist...@gmail.com> AuthorDate: Fri Nov 30 16:14:57 2018 +0100 [AMBARI-24975] Log Search UI: if there are multiple clusters - selecting one of it does not do anything (#50) --- .../dropdown-list/dropdown-list.component.html | 2 +- .../dropdown-list/dropdown-list.component.ts | 29 +++++++++++----------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/ambari-logsearch-web/src/app/modules/shared/components/dropdown-list/dropdown-list.component.html b/ambari-logsearch-web/src/app/modules/shared/components/dropdown-list/dropdown-list.component.html index 6cea2a1..cc790ab 100644 --- a/ambari-logsearch-web/src/app/modules/shared/components/dropdown-list/dropdown-list.component.html +++ b/ambari-logsearch-web/src/app/modules/shared/components/dropdown-list/dropdown-list.component.html @@ -19,7 +19,7 @@ [attr.role]="item.isDivider ? 'separator' : null" [ngClass]="(item.cssClass || '')" (click)="onItemClick($event)"> <ng-container *ngIf="!item.isDivider"> <span class="list-item-label" *ngIf="isMultipleChoice"> - <input type="checkbox" [attr.id]="(instanceId) + '-' + (item.id || item.value)" [(ngModel)]="item.isChecked" + <input type="checkbox" [attr.id]="(instanceId) + '-' + (item.id || item.value)" [ngModel]="item.isChecked" (change)="changeSelectedItem({value: item.value, isChecked: $event.currentTarget.checked}, $event)"> <label [attr.for]="(instanceId) + '-' + (item.id || item.value)" class="label-container"> <span *ngIf="item.iconClass" [ngClass]="item.iconClass"></span> diff --git a/ambari-logsearch-web/src/app/modules/shared/components/dropdown-list/dropdown-list.component.ts b/ambari-logsearch-web/src/app/modules/shared/components/dropdown-list/dropdown-list.component.ts index 8be7e64..4db1bc5 100644 --- a/ambari-logsearch-web/src/app/modules/shared/components/dropdown-list/dropdown-list.component.ts +++ b/ambari-logsearch-web/src/app/modules/shared/components/dropdown-list/dropdown-list.component.ts @@ -175,20 +175,17 @@ export class DropdownListComponent implements OnInit, OnChanges, AfterViewChecke } selectAll() { - this.items.forEach((item: ListItem) => { - item.isChecked = true; - if (item.onSelect) { - item.onSelect(...this.actionArguments); - } - }); - this.selectedItemChange.emit(this.items); + this.changeSelectedItem(this.items.map((item: ListItem) => ({ + ...item, + isChecked: true + }))); } unSelectAll() { - this.items.forEach((item: ListItem) => { - item.isChecked = false; - }); - this.selectedItemChange.emit(this.items); + this.changeSelectedItem(this.items.map((item: ListItem) => ({ + ...item, + isChecked: false + }))); } private onFilterInputKeyUp(event) { @@ -223,10 +220,12 @@ export class DropdownListComponent implements OnInit, OnChanges, AfterViewChecke } } - changeSelectedItem(item: ListItem, event?: MouseEvent): void { - if (item.onSelect) { - item.onSelect(...this.actionArguments); - } + changeSelectedItem(item: ListItem | ListItem[], event?: MouseEvent): void { + (Array.isArray(item) ? item : [item]).forEach((currentItem: ListItem) => { + if (currentItem.onSelect) { + currentItem.onSelect(...this.actionArguments) + } + }); this.selectedItemChange.emit(item); }