Skip to content

Commit

Permalink
♻️ Rename map attributes to territory-location and region-location
Browse files Browse the repository at this point in the history
Why:
- Removes the ambiguity of using "location" for both of them, as in the
  SPA version.
- Enables adding territory-number and potentially other attributes, as
  will be needed for the neighborhood map.
  • Loading branch information
luontola committed Jul 11, 2024
1 parent a18f130 commit ebeee7c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/territory_bro/ui/printout_templates.clj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
[:div {:class (:root styles)}

[:div {:class (:minimap styles)}
[:territory-mini-map {:territory (:location territory)
[:territory-mini-map {:territory-location (:location territory)
:congregation-boundary congregation-boundary
:enclosing-region enclosing-region
:enclosing-minimap-viewport enclosing-minimap-viewport}]]
Expand All @@ -57,7 +57,7 @@
[:div {:class (:map styles)}
(print-date-notice
print-date
[:territory-map {:location (:location territory)
[:territory-map {:territory-location (:location territory)
:map-raster map-raster
:printout true}])]

Expand All @@ -79,7 +79,7 @@
[:div {:class (:root styles)}

[:div {:class (:minimap styles)}
[:territory-mini-map {:territory (:location territory)
[:territory-mini-map {:territory-location (:location territory)
:congregation-boundary congregation-boundary
:enclosing-region enclosing-region
:enclosing-minimap-viewport enclosing-minimap-viewport}]]
Expand All @@ -93,7 +93,7 @@
[:div {:class (:map styles)}
(print-date-notice
print-date
[:territory-map {:territory (:location territory)
[:territory-map {:territory-location (:location territory)
:map-raster map-raster
:printout true}])]

Expand All @@ -114,7 +114,7 @@
[:div {:class (:map styles)}
(print-date-notice
print-date
[:region-map {:region (:location region)
[:region-map {:region-location (:location region)
:territories territories
:map-raster map-raster
:printout true}])]]))))
2 changes: 1 addition & 1 deletion src/territory_bro/ui/territory_page.clj
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@

[:div.pure-u-1.pure-u-lg-2-3.pure-u-xl-3-4
[:div {:class (:map styles)}
[:territory-map {:location (:location territory)
[:territory-map {:territory-location (:location territory)
:map-raster "osmhd"
:printout false}]]
[:div.no-print
Expand Down
6 changes: 3 additions & 3 deletions test/territory_bro/ui/printout_templates_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
Please keep this card in the envelope. Do not soil, mark or bend it.
Each time the territory is covered, please inform the brother who cares for the territory files.")
(html/visible-text html)))
(is (str/includes? html "territory=\"MULTIPOLYGON(territory)\""))
(is (str/includes? html "territory-location=\"MULTIPOLYGON(territory)\""))
(is (str/includes? html "congregation-boundary=\"MULTIPOLYGON(congregation boundary)\""))
(is (str/includes? html "enclosing-region=\"MULTIPOLYGON(region)\""))
(is (str/includes? html "enclosing-minimap-viewport=\"POLYGON(minimap viewport)\""))
Expand All @@ -86,7 +86,7 @@
Please keep this card in the envelope. Do not soil, mark or bend it.
Each time the territory is covered, please inform the brother who cares for the territory files.")
(html/visible-text html)))
(is (str/includes? html "territory=\"MULTIPOLYGON(territory)\""))
(is (str/includes? html "territory-location=\"MULTIPOLYGON(territory)\""))
(is (str/includes? html "congregation-boundary=\"MULTIPOLYGON(congregation boundary)\""))
(is (str/includes? html "enclosing-region=\"MULTIPOLYGON(region)\""))
(is (str/includes? html "enclosing-minimap-viewport=\"POLYGON(minimap viewport)\""))
Expand All @@ -105,6 +105,6 @@
"The Region
Printed 2024-07-10 with TerritoryBro.com")
(html/visible-text html)))
(is (str/includes? html "region=\"MULTIPOLYGON(region)\""))
(is (str/includes? html "region-location=\"MULTIPOLYGON(region)\""))
(is (str/includes? html "territories=\"[{"number":"123","location":"MULTIPOLYGON(territory)"}]\""))
(is (str/includes? html "map-raster=\"osmhd\"")))))
4 changes: 3 additions & 1 deletion web/src/maps/RegionMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export default class RegionMap extends OpenLayersMap<Props> {

export class RegionMapElement extends OpenLayersMapElement {
createMap({root, mapRaster}) {
const region = {location: this.getAttribute("region")};
const region = {
location: this.getAttribute("region-location")
};
const territories = JSON.parse(this.getAttribute("territories") ?? "[]");
const map = initRegionMap(root, region as Region, territories);
map.setStreetsLayerRaster(mapRaster);
Expand Down
8 changes: 5 additions & 3 deletions web/src/maps/TerritoryMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ export default class TerritoryMap extends OpenLayersMap<Props> {
}

export class TerritoryMapElement extends OpenLayersMapElement {
createMap({root, printout, mapRaster}) {
const location = this.getAttribute("location");
const map = initTerritoryMap(root, {location} as Territory, printout)
createMap({root, mapRaster, printout}) {
const territory = {
location: this.getAttribute("territory-location")
};
const map = initTerritoryMap(root, territory as Territory, printout)
map.setStreetsLayerRaster(mapRaster);
return map
}
Expand Down
2 changes: 1 addition & 1 deletion web/src/maps/TerritoryMiniMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class TerritoryMiniMap extends OpenLayersMap<Props> {
export class TerritoryMiniMapElement extends OpenLayersMapElement {
createMap({root}) {
const territory = {
location: this.getAttribute("territory"),
location: this.getAttribute("territory-location"),
enclosingMinimapViewport: this.getAttribute("enclosing-minimap-viewport"),
enclosingRegion: this.getAttribute("enclosing-region"),
};
Expand Down

0 comments on commit ebeee7c

Please sign in to comment.