Skip to content

Commit

Permalink
Fix studies being invisible when asset is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-va committed Nov 26, 2024
1 parent ade30e0 commit 9b98dcf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
9 changes: 5 additions & 4 deletions libs/asset-viewer/src/lib/components/map/map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
selectAssetSearchPolygon,
selectAssetSearchResultData,
selectCurrentAssetDetail,
selectHasDefaultFilters,
selectHasNoActiveFilters,
selectIsSearchQueryEmpty,
selectStudies,
} from '../../state/asset-search/asset-search.selector';
import { AppStateWithMapControl } from '../../state/map-control/map-control.reducer';
Expand Down Expand Up @@ -129,7 +130,7 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy {
this.controller.addControl(this.controls.draw);

this.subscription.add(
this.store.select(selectHasDefaultFilters).subscribe((hasDefaultFilters) => {
this.store.select(selectIsSearchQueryEmpty).subscribe((hasDefaultFilters) => {
if (hasDefaultFilters) {
this.controls.zoom.resetZoom();
}
Expand All @@ -155,8 +156,8 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy {

private initializeStoreBindings() {
this.subscription.add(
this.store.select(selectHasDefaultFilters).subscribe((showStudies) => {
this.controller.setShowHeatmap(showStudies);
this.store.select(selectHasNoActiveFilters).subscribe((basDefaultFilters) => {
this.controller.setShowHeatmap(basDefaultFilters);
})
);
this.subscription.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
selectAssetSearchIsInitialized,
selectAssetSearchQuery,
selectCurrentAssetDetail,
selectHasDefaultFilters,
selectIsSearchQueryEmpty,
selectSearchLoadingState,
selectStudies,
} from './asset-search.selector';
Expand Down Expand Up @@ -221,7 +221,7 @@ export class AssetSearchEffects {
this.actions$.pipe(
ofType(actions.updateResults),
map(({ results }) => results.page.total !== 0),
withLatestFrom(this.store.select(selectHasDefaultFilters)),
withLatestFrom(this.store.select(selectIsSearchQueryEmpty)),
map(([hasResults, hasNoFilters]) =>
!hasResults || hasNoFilters ? actions.closeResults() : actions.openResults()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ export const selectAssetSearchTotalResults = createSelector(assetSearchFeature,
export const selectCurrentAssetDetail = createSelector(assetSearchFeature, (state) => state.currentAsset);
export const selectStudies = createSelector(assetSearchFeature, (state) => state.studies);

export const selectHasDefaultFilters = createSelector(
export const selectHasNoActiveFilters = createSelector(assetSearchFeature, ({ query }) => hasNoActiveFilters(query));

export const selectIsSearchQueryEmpty = createSelector(
assetSearchFeature,
({ query, currentAsset }) =>
currentAsset == null && Object.values(query).every((value) => value === undefined || value == false)
({ query, currentAsset }) => currentAsset == null && hasNoActiveFilters(query)
);

const hasNoActiveFilters = (query: AssetSearchQuery): boolean =>
Object.values(query).every((value) => value === undefined || value == false);

export const selectCurrentAssetDetailVM = createSelector(
fromAppShared.selectRDReferenceData,
selectCurrentAssetDetail,
Expand Down

0 comments on commit 9b98dcf

Please sign in to comment.