Skip to content

Commit

Permalink
* fixed issue with filter popup goes offscreen (#342)
Browse files Browse the repository at this point in the history
* selected filter values now shown on top of the values list (#345)
  • Loading branch information
agnybida committed Oct 29, 2024
1 parent 3c64ca4 commit 012ca3e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deep-see-web",
"version": "4.0.13",
"version": "4.0.14",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config=proxy.conf.samples-bi.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</div>
}
<!-- Filter items -->
@for (v of model.values; track trackByIndex($index, v)) {
@for (v of model.values | selectedFirst; track $index) {
<div class="value-row" (click)="toggleRow(v, $event)">
<input
#inp
Expand Down
35 changes: 28 additions & 7 deletions src/app/components/ui/filter-popup/filter-popup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Inject,
Input,
LOCALE_ID,
OnInit,
OnInit, Pipe, PipeTransform,
ViewChild
} from '@angular/core';
import {StorageService} from '../../../services/storage.service';
Expand Down Expand Up @@ -38,12 +38,29 @@ interface IFilterModel {
to: string;
}

@Pipe({
name: 'selectedFirst',
pure: true,
standalone: true
})
export class SelectedFirstPipe implements PipeTransform {

transform(value: any[]): any[] {
if (!Array.isArray(value)) {
return value; // Return the value unchanged if it's not an array
}

// Sort by `checked` field: `true` comes first, `false` later
return value.sort((a, b) => (a.checked === b.checked) ? 0 : (a.checked ? -1 : 1));
}
}

@Component({
selector: 'dsw-filter-popup',
templateUrl: './filter-popup.component.html',
styleUrls: ['./filter-popup.component.scss'],
standalone: true,
imports: [FormsModule, AutoFocusDirective, DateFilterComponent, I18nPipe],
imports: [FormsModule, AutoFocusDirective, DateFilterComponent, I18nPipe, SelectedFirstPipe],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class FilterPopupComponent implements OnInit, AfterViewInit {
Expand Down Expand Up @@ -93,9 +110,12 @@ export class FilterPopupComponent implements OnInit, AfterViewInit {
return (this.model?.filter?.type === 'radioSet' && this.model?.filter?.action !== 'applyVariable');
}

trackByIndex = (index: number, r: any) => index;

ngAfterViewInit() {
this.fitFiltersIntoScreen();
this.initializeDateFilter();
}

private fitFiltersIntoScreen() {
const el = this.el?.nativeElement;
if (!el) {
return;
Expand All @@ -118,11 +138,8 @@ export class FilterPopupComponent implements OnInit, AfterViewInit {
el.style.maxHeight = (rect.height - delta - 20) + 'px';
}
}

this.initializeDateFilter();
}


initialize(widget: IWidgetDesc, filter: any, dataSource: string) {
this.widget = widget;
// this.source = filter;
Expand Down Expand Up @@ -230,6 +247,10 @@ export class FilterPopupComponent implements OnInit, AfterViewInit {
this.model.to = this.model.values[0].path;
}
}

setTimeout(() => {
this.fitFiltersIntoScreen();
});
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#### 4.0.14
* fixed issue with filter popup goes offscreen (#342)
* selected filter values now shown on top of the values list (#345)

#### 4.0.13
* map widget was rewritten:
* widget was rewritten to use GeoJSON as base format
Expand Down

0 comments on commit 012ca3e

Please sign in to comment.