From 71d0e35eecbee8f105c0c6912981bd750ba4bf3a Mon Sep 17 00:00:00 2001 From: miguelzinh3 Date: Fri, 6 Oct 2023 04:01:00 -0300 Subject: [PATCH] feat: add custom placeholder to Map plugin --- .../migrations/0004_maps_search_placeholder.py | 18 ++++++++++++++++++ app/contrib/frontend/maps/models.py | 1 + .../frontend/maps/static/maps/js/maps.js | 3 ++- .../maps/templates/maps/plugins/map.html | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 app/contrib/frontend/maps/migrations/0004_maps_search_placeholder.py diff --git a/app/contrib/frontend/maps/migrations/0004_maps_search_placeholder.py b/app/contrib/frontend/maps/migrations/0004_maps_search_placeholder.py new file mode 100644 index 00000000..988d28c8 --- /dev/null +++ b/app/contrib/frontend/maps/migrations/0004_maps_search_placeholder.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2 on 2023-10-06 06:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('maps', '0003_auto_20231005_1327'), + ] + + operations = [ + migrations.AddField( + model_name='maps', + name='search_placeholder', + field=models.CharField(blank=True, max_length=80, verbose_name='Placeholder do Campo de Busca'), + ), + ] diff --git a/app/contrib/frontend/maps/models.py b/app/contrib/frontend/maps/models.py index 80971811..e919b31a 100644 --- a/app/contrib/frontend/maps/models.py +++ b/app/contrib/frontend/maps/models.py @@ -26,3 +26,4 @@ class Maps(CMSPlugin): ) point_a = models.FileField(upload_to="maps/icons/", blank=True, null=True) point_b = models.FileField(upload_to="maps/icons/", blank=True, null=True) + search_placeholder = models.CharField("Placeholder do Campo de Busca", max_length=80, blank=True) diff --git a/app/contrib/frontend/maps/static/maps/js/maps.js b/app/contrib/frontend/maps/static/maps/js/maps.js index 1e12976d..a192aead 100644 --- a/app/contrib/frontend/maps/static/maps/js/maps.js +++ b/app/contrib/frontend/maps/static/maps/js/maps.js @@ -30,13 +30,14 @@ L.Control.Search = L.Control.extend({ }, onAdd: function () { const container = L.DomUtil.create("div", "autocomplete-container"); + const searchPlaceholder = mapWrapper.dataset.mapsSearchplaceholder; L.DomEvent.disableClickPropagation(container); container.insertAdjacentHTML( "beforeend", `
- +
` ); diff --git a/app/contrib/frontend/maps/templates/maps/plugins/map.html b/app/contrib/frontend/maps/templates/maps/plugins/map.html index 850daa77..ae2cbed3 100644 --- a/app/contrib/frontend/maps/templates/maps/plugins/map.html +++ b/app/contrib/frontend/maps/templates/maps/plugins/map.html @@ -12,6 +12,7 @@ data-maps-geojson="{{ instance.geojson.url }}" {% if instance.point_a %}data-maps-icons-point-A="{{ instance.point_a.url }}"{% endif %} {% if instance.point_b %}data-maps-icons-point-B="{{ instance.point_b.url }}"{% endif %} + data-maps-searchplaceholder="{{ instance.search_placeholder }}" data-maps-linecolor="{{ instance.line_color }}">