Skip to content

Commit

Permalink
maps/react: fix react map namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
vellip committed Jan 29, 2025
1 parent b0cfac3 commit 897c879
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion adhocracy4/maps_react/templatetags/react_maps_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def react_choose_point(polygon, point, name):
}

return format_html(
'<div data-a4-widget="choose-point" ' 'data-attributes="{attributes}"></div>',
'<div data-a4-widget="react-choose-point" '
'data-attributes="{attributes}"></div>',
attributes=json.dumps(attributes),
)
8 changes: 4 additions & 4 deletions adhocracy4/maps_react/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ def __init__(self, polygon, attrs=None):
super().__init__(attrs)

class Media:
js = ("a4maps_choose_point.js",)
js = ("a4maps_react_choose_point.js",)

css = {"all": ["a4maps_choose_point.css"]}
css = {"all": ["a4maps_react_choose_point.css"]}

def render(self, name, value, attrs, renderer=None):
if not finders.find("a4maps_choose_point.js"):
if not finders.find("a4maps_react_choose_point.js"):
raise ImproperlyConfigured(
"Configure your frontend build tool to generate a4maps_choose_point.js."
"Configure your frontend build tool to generate a4maps_react_choose_point.js."
)

context = {
Expand Down
4 changes: 2 additions & 2 deletions tests/maps_react/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_react_maps_without_point(rf, area_settings):
}
}
expected = format_html(
'<div data-a4-widget="choose-point" data-attributes="{attributes}"></div>',
'<div data-a4-widget="react-choose-point" data-attributes="{attributes}"></div>',
attributes=json.dumps(attrs),
)

Expand Down Expand Up @@ -50,7 +50,7 @@ def test_react_maps_with_point(rf, area_settings):
}
}
expected = format_html(
'<div data-a4-widget="choose-point" data-attributes="{attributes}"></div>',
'<div data-a4-widget="react-choose-point" data-attributes="{attributes}"></div>',
attributes=json.dumps(attrs),
)

Expand Down
2 changes: 1 addition & 1 deletion tests/maps_react/test_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_choose_point_widget(area_settings):
expected = format_html(
"""
<div data-a4-widget="choose-point" data-attributes="{attributes}"></div>
<div data-a4-widget="react-choose-point" data-attributes="{attributes}"></div>
<input id="id_test_filter" type="hidden" name="test_filter" value="test_val1">
""",
attributes=json.dumps(attrs),
Expand Down

0 comments on commit 897c879

Please sign in to comment.