From 3906236b77fe6594f74aaeef9a7ab324deaef4c5 Mon Sep 17 00:00:00 2001 From: Makar Kozlowski Date: Wed, 2 Dec 2020 17:54:08 +0100 Subject: [PATCH] [Feature] Title need on the map download - Fix comments from PR --- src/js/elements/mapchip.js | 8 ++------ src/js/load.js | 2 +- src/js/map/map_download.js | 5 ++--- src/js/setup/choropleth.js | 2 +- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/js/elements/mapchip.js b/src/js/elements/mapchip.js index 290b2d2e9..09e412ca2 100644 --- a/src/js/elements/mapchip.js +++ b/src/js/elements/mapchip.js @@ -6,7 +6,6 @@ const wrapperClsName = 'content__map_current-display'; const mapOptionsClass = '.map-options'; const lightStart = 3; -let title = ''; let subindicatorKey = ''; /** @@ -17,6 +16,7 @@ export class MapChip extends Observable { super(); this.legendColors = legendColors; this.prepareDomElements(); + this.title = ''; } prepareDomElements() { @@ -133,13 +133,9 @@ export class MapChip extends Observable { label = args.indicatorTitle; } - title = `${args.parents.category} by ${label}`; + this.title = `${args.category} by ${label}`; this.updateMapChipText(label); this.showMapChip(args); } - - get title() { - return title; - } } diff --git a/src/js/load.js b/src/js/load.js index 493dd9491..33e63e935 100644 --- a/src/js/load.js +++ b/src/js/load.js @@ -60,7 +60,7 @@ export default function configureApplication(profileId, config) { const zoomToggle = new ZoomToggle(); const preferredChildToggle = new PreferredChildToggle(); const boundaryTypeBox = new BoundaryTypeBox(config.config.preferred_children); - const mapDownload = new MapDownload(); + const mapDownload = new MapDownload(mapchip); // TODO not certain if it is need to register both here and in the controller in loadedGeography // controller.registerWebflowEvents(); diff --git a/src/js/map/map_download.js b/src/js/map/map_download.js index f5e907483..7545805ca 100644 --- a/src/js/map/map_download.js +++ b/src/js/map/map_download.js @@ -1,12 +1,11 @@ import html2canvas from 'html2canvas'; import {Observable, saveAs} from "../utils"; -import {MapChip} from "../elements/mapchip"; export class MapDownload extends Observable { - constructor() { + constructor(mapChip) { super(); - this.mapChip = new MapChip(); + this.mapChip = mapChip; this.prepareDomElements(); } diff --git a/src/js/setup/choropleth.js b/src/js/setup/choropleth.js index 830913d28..524214ded 100644 --- a/src/js/setup/choropleth.js +++ b/src/js/setup/choropleth.js @@ -57,7 +57,7 @@ export function configureChoroplethEvents(controller, objs = {mapcontrol: null, indicators: pp.indicators, subindicatorKey: pp.obj.keys, indicatorTitle: pp.indicatorTitle, - parents: pp.parents + category: pp.parents.category } mapchip.onSubIndicatorChange(args);