fix and add documents view

This commit is contained in:
2026-10-08 14:39:17 +03:00
parent 548ba43dc2
commit a65d4185f3
29 changed files with 553 additions and 267 deletions
+19 -24
View File
@@ -13,11 +13,9 @@ import {
signal,
} from '@angular/core';
import { Geolocation, type Position } from '@capacitor/geolocation';
import { Store } from '@ngrx/store';
import type { Attraction } from '../../areas/area.models';
import { Icon } from '../../shared/icon/icon';
import { selectCollectedIdSet } from '../../state';
import { MapItemSheet } from '../map-item-sheet/map-item-sheet';
const MAP_KEY = 'bf0a466f-43a6-48c7-b274-7fea5952957b';
@@ -136,7 +134,6 @@ export class CityMap implements AfterViewInit, OnDestroy {
@ViewChild('map', { static: true })
private mapElement!: ElementRef<HTMLElement>;
private readonly store = inject(Store);
private readonly zone = inject(NgZone);
private raster: DgApi | null = null;
private map: DgMap | null = null;
@@ -154,7 +151,6 @@ export class CityMap implements AfterViewInit, OnDestroy {
private readonly markers = new Map<string, DgMarker>();
private readonly mapReady = signal(false);
private placedKey = '';
private readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
private readonly stopFollowing = (): void => {
this.programmaticMove = false;
this.zone.run(() => this.following.set(false));
@@ -182,13 +178,12 @@ export class CityMap implements AfterViewInit, OnDestroy {
constructor() {
effect(() => {
const items = this.attractions();
const ids = this.collectedIds();
if (!this.mapReady()) {
return;
}
this.placeMarkers(items, ids);
this.placeMarkers(items);
});
effect(() => {
@@ -366,7 +361,7 @@ export class CityMap implements AfterViewInit, OnDestroy {
this.watchId = null;
}
private placeMarkers(items: Attraction[], collectedIds: Set<string>): void {
private placeMarkers(items: Attraction[]): void {
const map = this.map;
const api = this.raster;
@@ -381,7 +376,7 @@ export class CityMap implements AfterViewInit, OnDestroy {
const element = this.markerElements.get(item.id);
if (element) {
this.setMarkerIcon(element, collectedIds.has(item.id) || item.visited);
this.setMarkerIcon(element, item);
}
}
@@ -401,10 +396,7 @@ export class CityMap implements AfterViewInit, OnDestroy {
continue;
}
this.markers.set(
item.id,
this.createMarker(api, map, item, collectedIds.has(item.id) || item.visited),
);
this.markers.set(item.id, this.createMarker(api, map, item));
}
if (this.markers.size > 0) {
@@ -412,26 +404,29 @@ export class CityMap implements AfterViewInit, OnDestroy {
}
}
private createMarker(api: DgApi, map: DgMap, landmark: Attraction, collected: boolean): DgMarker {
private createMarker(api: DgApi, map: DgMap, item: Attraction): DgMarker {
const markerElement = document.createElement('button');
markerElement.type = 'button';
markerElement.className = 'city-map__marker';
markerElement.setAttribute('aria-label', landmark.name);
markerElement.innerHTML =
'<span class="city-map__radius"></span><img width="40" height="40" alt="" /><span class="city-map__label"></span>';
markerElement.setAttribute('aria-label', item.name);
markerElement.innerHTML = `<span></span><img width="40" height="40" alt="" /><span class="city-map__label"></span>`;
// '<span class="city-map__radius"></span><img width="40" height="40" alt="" /><span class="city-map__label"></span>';
// Marker with radius
// markerElement.innerHTML =
// '<span class="city-map__radius"></span><img width="40" height="40" alt="" /><span class="city-map__label"></span>';
const label = markerElement.querySelector('.city-map__label');
if (label) {
label.textContent = landmark.name;
label.textContent = item.name;
}
this.markerElements.set(landmark.id, markerElement);
this.setMarkerIcon(markerElement, collected);
this.markerElements.set(item.id, markerElement);
this.setMarkerIcon(markerElement, item);
const marker = this.addHtmlMarker(
api,
map,
[landmark.longitude, landmark.latitude],
[item.longitude, item.latitude],
markerElement,
LANDMARK_SIZE,
1,
@@ -439,7 +434,7 @@ export class CityMap implements AfterViewInit, OnDestroy {
);
marker.on('click', () => {
this.zone.run(() => this.selectLandmark(landmark));
this.zone.run(() => this.selectLandmark(item));
});
return marker;
@@ -491,20 +486,20 @@ export class CityMap implements AfterViewInit, OnDestroy {
return marker;
}
private setMarkerIcon(element: HTMLElement, collected: boolean): void {
private setMarkerIcon(element: HTMLElement, item: Attraction): void {
const img = element.querySelector('img');
if (!img) {
return;
}
const src = collected ? '/assets/icons/check-marker.svg' : '/assets/icons/lock-marker.svg';
const src = item.visited ? '/assets/icons/check-marker.svg' : '/assets/icons/lock-marker.svg';
if (img.getAttribute('src') !== src) {
img.setAttribute('src', src);
}
element.classList.toggle('city-map__marker--open', collected);
element.classList.toggle('city-map__marker--open', item.visited);
}
private selectLandmark(landmark: Attraction): void {