Skip to content

Commit

Permalink
feat: add custom placeholder to Map plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelzinh3 committed Oct 6, 2023
1 parent c6f6982 commit 71d0e35
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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'),
),
]
1 change: 1 addition & 0 deletions app/contrib/frontend/maps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion app/contrib/frontend/maps/static/maps/js/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
`<div class="auto-search-wrapper loupe">
<input type="text" id="show-all-values" autocomplete="off" placeholder="Encontre a linha" />
<input type="text" id="show-all-values" autocomplete="off" placeholder="${searchPlaceholder}" />
</div>`
);

Expand Down
1 change: 1 addition & 0 deletions app/contrib/frontend/maps/templates/maps/plugins/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}">
</div>

Expand Down

0 comments on commit 71d0e35

Please sign in to comment.