filter
This commit is contained in:
@@ -78,13 +78,17 @@
|
||||
</div>
|
||||
|
||||
<!-- Multi-Select Filter -->
|
||||
<div class="filter-control" *ngIf="filterType === 'multiselect'">
|
||||
<select [(ngModel)]="filterValue"
|
||||
(ngModelChange)="onFilterValueChange($event)"
|
||||
multiple
|
||||
class="clr-select compact-multiselect">
|
||||
<option *ngFor="let option of filterOptions" [value]="option">{{ option }}</option>
|
||||
</select>
|
||||
<div class="filter-control multiselect-container" *ngIf="filterType === 'multiselect'">
|
||||
<div class="checkbox-group">
|
||||
<div class="checkbox-item" *ngFor="let option of filterOptions">
|
||||
<input type="checkbox"
|
||||
[value]="option"
|
||||
[checked]="filterValue && filterValue.includes(option)"
|
||||
(change)="onMultiselectChange(option, $event)"
|
||||
class="clr-checkbox">
|
||||
<label class="checkbox-label">{{ option }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Date Range Filter -->
|
||||
|
||||
@@ -70,6 +70,41 @@
|
||||
min-height: 24px;
|
||||
}
|
||||
|
||||
.multiselect-container {
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
padding: 5px;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.checkbox-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.checkbox-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
font-size: 12px;
|
||||
margin: 0;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.clr-checkbox {
|
||||
margin: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toggle-label {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
|
||||
@@ -201,6 +201,29 @@ export class CompactFilterComponent implements OnInit, OnChanges {
|
||||
this.onFilterValueChange(dateRange);
|
||||
}
|
||||
|
||||
// Handle multiselect checkbox changes
|
||||
onMultiselectChange(option: string, event: any): void {
|
||||
const isChecked = event.target.checked;
|
||||
|
||||
// Ensure filterValue is an array
|
||||
if (!Array.isArray(this.filterValue)) {
|
||||
this.filterValue = [];
|
||||
}
|
||||
|
||||
if (isChecked) {
|
||||
// Add option to selected values if not already present
|
||||
if (!this.filterValue.includes(option)) {
|
||||
this.filterValue = [...this.filterValue, option];
|
||||
}
|
||||
} else {
|
||||
// Remove option from selected values
|
||||
this.filterValue = this.filterValue.filter((val: string) => val !== option);
|
||||
}
|
||||
|
||||
// Emit the change
|
||||
this.onFilterValueChange(this.filterValue);
|
||||
}
|
||||
|
||||
// Load available keys from API
|
||||
loadAvailableKeys(): void {
|
||||
if (this.apiUrl) {
|
||||
|
||||
Reference in New Issue
Block a user