refs #1138 Fix advance search bug
testing/ogGui-multibranch/pipeline/head This commit is unstable
Details
testing/ogGui-multibranch/pipeline/head This commit is unstable
Details
parent
9304f95dfa
commit
ef0fdb9b34
|
@ -106,7 +106,6 @@
|
|||
|
||||
</ng-container>
|
||||
|
||||
<button mat-raised-button color="primary" (click)="toggleSelectAll()">Seleccionar/Deseleccionar Todos</button>
|
||||
<button mat-raised-button color="primary" (click)="saveFilters()" i18n="@@saveFiltersButton">Guardar
|
||||
Filtros</button>
|
||||
<button mat-raised-button color="accent" (click)="sendActions()" i18n="@@sendFiltersButton"
|
||||
|
@ -128,7 +127,7 @@
|
|||
'card-off': result.status === 'off'
|
||||
}">
|
||||
<mat-checkbox
|
||||
[checked]="isSelected(result.name)"
|
||||
[(ngModel)]="result.selected"
|
||||
(change)="onCheckboxChange($event, result.name, result['@id'])"
|
||||
class="result-checkbox">
|
||||
</mat-checkbox>
|
||||
|
@ -152,7 +151,7 @@
|
|||
<ng-container *ngIf="viewMode === 'list'">
|
||||
<div class="result-list" *ngFor="let result of filteredResults">
|
||||
<mat-card class="result-card-list">
|
||||
<mat-checkbox [checked]="isSelected(result.name)" (change)="onCheckboxChange($event, result.name, result['@id'])" class="result-checkbox"></mat-checkbox>
|
||||
<mat-checkbox [(ngModel)]="result.selected" (change)="onCheckboxChange($event, result.name, result['@id'])" class="result-checkbox"></mat-checkbox>
|
||||
<mat-card-title class="result-title">{{ result.name }}</mat-card-title>
|
||||
<mat-card-content class="result-content">
|
||||
<p class="result-type">{{ result.type !== 'client' ? result.type : '' }}</p>
|
||||
|
|
|
@ -25,7 +25,6 @@ import {
|
|||
} from "../../../ogboot/pxe-boot-files/create-pxeBootFile/create-pxe-boot-file/create-pxe-boot-file.component";
|
||||
import { JoyrideService } from 'ngx-joyride';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-advanced-search',
|
||||
templateUrl: './advanced-search.component.html',
|
||||
|
@ -390,29 +389,37 @@ export class AdvancedSearchComponent {
|
|||
|
||||
}
|
||||
|
||||
|
||||
onCheckboxChange(event: any, name: string, uuid: string) {
|
||||
if (event.checked) {
|
||||
this.selectedElements.push(uuid);
|
||||
if (!this.selectedElements.includes(uuid)) {
|
||||
this.selectedElements.push(uuid);
|
||||
}
|
||||
} else {
|
||||
const index = this.selectedElements.indexOf(name);
|
||||
const index = this.selectedElements.indexOf(uuid);
|
||||
if (index > -1) {
|
||||
this.selectedElements.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
this.isAllSelected = this.selectedElements.length === this.filteredResults.length;
|
||||
|
||||
this.isAllSelected = this.filteredResults.every(result =>
|
||||
this.selectedElements.includes(result['@id'])
|
||||
);
|
||||
}
|
||||
|
||||
toggleSelectAll() {
|
||||
this.isAllSelected = !this.isAllSelected;
|
||||
|
||||
|
||||
if (this.isAllSelected) {
|
||||
this.selectedElements = this.filteredResults.map(result => result['@id']);
|
||||
} else {
|
||||
this.selectedElements = [];
|
||||
}
|
||||
|
||||
this.filteredResults.forEach(result => {
|
||||
result.selected = this.isAllSelected;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
isSelected(name: string): boolean {
|
||||
return this.selectedElements.includes(name);
|
||||
|
|
Loading…
Reference in New Issue