Skip to content

Commit

Permalink
Load embedded table form when trying to add filters
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Dec 19, 2023
1 parent b35640f commit 585f32a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@ import {
OnDestroy,
OnInit,
Output,

} from '@angular/core';
import { WorkPackageViewFiltersService } from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-filters.service';
import {
WorkPackageViewFiltersService,
} from 'core-app/features/work-packages/routing/wp-view-base/view-services/wp-view-filters.service';
import { DebouncedEventEmitter } from 'core-app/shared/helpers/rxjs/debounced-event-emitter';
import { QueryFilterInstanceResource } from 'core-app/features/hal/resources/query-filter-instance-resource';
import { Observable } from 'rxjs';
import { from, merge, Observable } from 'rxjs';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
import { componentDestroyed } from '@w11k/ngx-componentdestroyed';
import { WorkPackageFiltersService } from 'core-app/features/work-packages/components/filters/wp-filters/wp-filters.service';
import {
WorkPackageFiltersService,
} from 'core-app/features/work-packages/components/filters/wp-filters/wp-filters.service';
import { WorkPackagesListService } from 'core-app/features/work-packages/components/wp-list/wp-list.service';

@Component({
templateUrl: './filter-container.directive.html',
Expand All @@ -66,14 +70,17 @@ export class WorkPackageFilterContainerComponent extends UntilDestroyedMixin imp
readonly wpTableFilters:WorkPackageViewFiltersService,
readonly cdRef:ChangeDetectorRef,
readonly wpFiltersService:WorkPackageFiltersService,
readonly wpListService:WorkPackagesListService,
) {
super();
this.visible$ = this.wpFiltersService.observeUntil(componentDestroyed(this));
}

ngOnInit():void {
this.wpTableFilters
.pristine$()
merge(
this.wpTableFilters.pristine$(),
from(this.wpListService.conditionallyLoadForm()),
)
.pipe(
this.untilDestroyed(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ export class WorkPackagesListService {
public conditionallyLoadForm(query = this.currentQuery):Promise<QueryFormResource> {
const currentForm = this.querySpace.queryForm.value;

if (!query) {
return firstValueFrom(this.queryLoading)
.then((loaded) => this.conditionallyLoadForm(loaded));
}

if (!currentForm || query.$links.update.href !== currentForm.href) {
return this.loadForm(query);
}
Expand Down

0 comments on commit 585f32a

Please sign in to comment.