From f93d0b5ca7b5e3424337bd1506022423a6cf3da6 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 19 Dec 2024 10:44:32 +0100 Subject: [PATCH] fix: update star icon on star/unstar --- umap/static/umap/js/modules/umap.js | 7 ++++++- umap/static/umap/js/umap.controls.js | 6 +----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/umap/static/umap/js/modules/umap.js b/umap/static/umap/js/modules/umap.js index 258b45dbc..2ae75ccce 100644 --- a/umap/static/umap/js/modules/umap.js +++ b/umap/static/umap/js/modules/umap.js @@ -1346,6 +1346,11 @@ export default class Umap extends ServerStored { el.textContent = this.sync.getNumberOfConnectedPeers() }) }, + 'properties.starred': () => { + Utils.eachElement('.map-star', (el) => { + el.classList.toggle('starred', this.properties.starred) + }) + }, } for (const [field, impact] of Object.entries(impacts)) { if (!fields.length || fields.includes(field)) { @@ -1531,7 +1536,7 @@ export default class Umap extends ServerStored { ? translate('Map has been starred') : translate('Map has been unstarred') ) - this.render(['starred']) + this.render(['properties.starred']) } processFileToImport(file, layer, type) { diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 29c01f8cf..4cdcc15cc 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -541,11 +541,7 @@ U.StarControl = L.Control.Button.extend({ options: { position: 'topleft', title: L._('Star this map'), - }, - - getClassName: function () { - const status = this._umap.properties.starred ? ' starred' : '' - return `leaflet-control-star umap-control${status}` + className: 'leaflet-control-star map-star umap-control', }, onClick: function () {