RED-2543: Doughnut chart - fixed visually disabling selection

This commit is contained in:
Adina Țeudan 2021-10-22 01:08:07 +03:00
parent a62cdf6eaa
commit 14811688f9
2 changed files with 11 additions and 4 deletions

View File

@ -28,7 +28,7 @@
(click)="val.key && selectValue(val.key)"
*ngFor="let val of config"
[class.active]="filterChecked$(val.key) | async"
[class.filter-disabled]="!val.key || (statusFilters$ | async)?.length === 0"
[class.filter-disabled]="!val.key || !filtersEnabled"
>
<iqser-status-bar
[configs]="[

View File

@ -12,6 +12,8 @@ export interface DoughnutChartConfig {
active?: boolean;
}
const FILTER_KEY = 'statusFilters';
@Component({
selector: 'redaction-simple-doughnut-chart',
templateUrl: './simple-doughnut-chart.component.html',
@ -25,6 +27,7 @@ export class SimpleDoughnutChartComponent implements OnChanges {
@Input() direction: 'row' | 'column' = 'column';
@Input() totalType: 'sum' | 'count' = 'sum';
@Input() counterText: string;
readonly filtersEnabled: boolean;
chartData: any[] = [];
perimeter: number;
@ -32,9 +35,11 @@ export class SimpleDoughnutChartComponent implements OnChanges {
cy = 0;
size = 0;
readonly statusFilters$ = this.filterService.getFilterModels$('statusFilters') ?? of([]);
readonly statusFilters$ = this.filterService.getFilterModels$(FILTER_KEY) ?? of([]);
constructor(readonly filterService: FilterService) {}
constructor(readonly filterService: FilterService) {
this.filtersEnabled = !!this.filterService.filterGroups.find(g => g.slug === FILTER_KEY);
}
get circumference(): number {
return 2 * Math.PI * this.radius;
@ -90,6 +95,8 @@ export class SimpleDoughnutChartComponent implements OnChanges {
}
selectValue(key: string): void {
this.filterService.toggleFilter('statusFilters', key);
if (this.filtersEnabled) {
this.filterService.toggleFilter(FILTER_KEY, key);
}
}
}