From 5526a3f4d2632bbd4765a4571a28655262e054b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Tue, 2 Apr 2024 10:27:01 +0200 Subject: [PATCH] fix: Fix module location for some utils. --- umap/static/umap/js/modules/utils.js | 23 +++++++++++++++++++++++ umap/static/umap/js/umap.autocomplete.js | 2 +- umap/static/umap/js/umap.core.js | 2 +- umap/static/umap/js/umap.js | 2 +- umap/static/umap/js/umap.layer.js | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/umap/static/umap/js/modules/utils.js b/umap/static/umap/js/modules/utils.js index 64dead17..125945ee 100644 --- a/umap/static/umap/js/modules/utils.js +++ b/umap/static/umap/js/modules/utils.js @@ -200,6 +200,19 @@ export function usableOption(options, option) { return options[option] !== undefined && options[option] !== '' } +/** + * Processes a template string by replacing placeholders with corresponding + * data values. + * + * Supports dot notation for nested objects and optional static fallbacks. + * If a value is not found, the placeholder is replaced with an empty string + * or left unchanged when 'ignore' is true. + * + * @param {string} str - The template string with placeholders. + * @param {Object} data - The data object from which to pull replacement values. + * @param {boolean} [ignore=false] - If true, leaves placeholders unchanged when no value is found. + * @returns {string} The processed string with placeholders replaced. + */ export function greedyTemplate(str, data, ignore) { function getValue(data, path) { let value = data @@ -310,6 +323,16 @@ export function isDataImage(value) { return value && value.length && value.startsWith('data:image') } +/** + * Normalizes the input string by converting to lowercase + * and removing diacritics. + * + * If the input is nullish, it defaults to an empty string. + * + * @param {string} s - The string to be normalized. + * @returns {string} - The normalized string with lowercase + * characters and no diacritics. + */ export function normalize(s) { return (s || '') .toLowerCase() diff --git a/umap/static/umap/js/umap.autocomplete.js b/umap/static/umap/js/umap.autocomplete.js index c63679e1..3da1bdeb 100644 --- a/umap/static/umap/js/umap.autocomplete.js +++ b/umap/static/umap/js/umap.autocomplete.js @@ -153,7 +153,7 @@ U.AutoComplete = L.Class.extend({ this.displaySelected(choice) this.hide() if (this.options.callback) { - U.Utils.bind(this.options.callback, this)(choice) + L.Util.bind(this.options.callback, this)(choice) } } }, diff --git a/umap/static/umap/js/umap.core.js b/umap/static/umap/js/umap.core.js index 58acb343..2c8da683 100644 --- a/umap/static/umap/js/umap.core.js +++ b/umap/static/umap/js/umap.core.js @@ -128,7 +128,7 @@ L.DomUtil.createCopiableInput = (parent, label, value) => { '', wrapper, '', - () => U.Utils.copyToClipboard(input.value), + () => L.Util.copyToClipboard(input.value), this ) button.title = L._('copy') diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 7aa515f9..132b773e 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -1032,7 +1032,7 @@ U.Map = L.Map.extend({ { label: L._('Copy link'), callback: () => { - U.Utils.copyToClipboard(data.permissions.anonymous_edit_url) + L.Util.copyToClipboard(data.permissions.anonymous_edit_url) this.ui.alert({ content: L._('Secret edit link copied to clipboard!'), level: 'info', diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index 02c92d40..21ae6189 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -760,7 +760,7 @@ U.DataLayer = L.Evented.extend({ U.Utils.sortFeatures(features, this.map.getOption('sortKey'), L.lang) this._index = [] for (let i = 0; i < features.length; i++) { - this._index.push(U.Utils.stamp(features[i])) + this._index.push(L.Util.stamp(features[i])) } },