Skip to content

Commit

Permalink
Merge pull request #357 from swisstopo/bugfix/asset-356-studies-versc…
Browse files Browse the repository at this point in the history
…hwinden

Bugfix 356: Studies verschwinden, wenn man ein Detail anwählt
  • Loading branch information
daniel-va authored Nov 26, 2024
2 parents edf63be + 0495380 commit 4ffebb9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion apps/client-asset-sg/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"assets": ["apps/client-asset-sg/src/favicon.ico", "apps/client-asset-sg/src/assets"],
"styles": ["apps/client-asset-sg/src/styles.scss"],
"scripts": [],
"allowedCommonJsDependencies": ["tsafe", "xml-utils", "pbf", "rbush", "earcut", "@prisma/client"]
"allowedCommonJsDependencies": ["tsafe", "xml-utils", "pbf", "rbush", "earcut", "@prisma/client", "validator"]
},
"configurations": {
"production": {
Expand Down
11 changes: 6 additions & 5 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,8 +130,8 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy {
this.controller.addControl(this.controls.draw);

this.subscription.add(
this.store.select(selectHasDefaultFilters).subscribe((hasDefaultFilters) => {
if (hasDefaultFilters) {
this.store.select(selectIsSearchQueryEmpty).subscribe((isSearchQueryEmpty) => {
if (isSearchQueryEmpty) {
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((hasNoActiveFilters) => {
this.controller.setShowHeatmap(hasNoActiveFilters);
})
);
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,9 +221,9 @@ export class AssetSearchEffects {
this.actions$.pipe(
ofType(actions.updateResults),
map(({ results }) => results.page.total !== 0),
withLatestFrom(this.store.select(selectHasDefaultFilters)),
map(([hasResults, hasNoFilters]) =>
!hasResults || hasNoFilters ? actions.closeResults() : actions.openResults()
withLatestFrom(this.store.select(selectIsSearchQueryEmpty)),
map(([hasResults, isSearchQueryEmpty]) =>
!hasResults || isSearchQueryEmpty ? 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
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4ffebb9

Please sign in to comment.