Skip to content

Commit

Permalink
Dataset#details : ajout modal pour conversion auto NeTEx
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti committed Feb 19, 2025
1 parent 1fb477d commit 09aa127
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -635,3 +635,12 @@ hr {
}
}
}

.modal .button__group {
a.button:hover {
background-color: var(--theme-secondary-darken) !important;
}
a.button.secondary:hover {
background-color: var(--darkest-grey) !important;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@
<div class="resource-actions">
<div>
<%= for {_, %{format: human_format, stable_url: stable_url}} <- Enum.sort_by(conversions, fn {_, %{format: format}} -> format end, :asc) do %>
<a class="download-button" rel="nofollow" href={stable_url}>
<%
modal_id = "modal-netex-conversion-#{:erlang.phash2(stable_url)}"
href = if human_format == "NeTEx", do: "#" <> modal_id, else: stable_url
%>

<a class="download-button" rel="nofollow" href={href}>
<button class="button-outline secondary no-border small">
<i class="icon icon--download" aria-hidden="true"></i><%= dgettext("page-dataset-details", "Download") %> <%= human_format %>
</button>
</a>
<%= if human_format == "NeTEx" do
render(TransportWeb.DatasetView, "_netex_conversion_modal.html",
stable_url: stable_url,
modal_id: modal_id
)
end %>
<% end %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div class="modal__backdrop" id={@modal_id}>
<div class="modal">
<p>
<%= dgettext(
"page-dataset-details",
"Automatic NeTEx conversion are created from the associated GTFS file and don't contain additional information which can be described in NeTEx."
) %>
</p>
<p class="notification warning">
<%= raw(
dgettext(
"page-dataset-details",
"Automatic NeTEx conversions will not be available <b>after 2025-06-01</b>."
)
) %>
</p>
<div class="form__group button__group">
<a class="classic button" rel="nofollow" href={@stable_url}>
<i class="icon icon--download" aria-hidden="true"></i><%= dgettext(
"page-dataset-details",
"Download the automatic NeTEx conversion"
) %>
</a>
<a href="#" class="classic button secondary">
<%= dgettext("page-dataset-details", "Cancel") %>
</a>
</div>
</div>
</div>
16 changes: 16 additions & 0 deletions apps/transport/priv/gettext/en/LC_MESSAGES/page-dataset-details.po
Original file line number Diff line number Diff line change
Expand Up @@ -721,3 +721,19 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "This unofficial dataset is provided experimentally. Do not use it for travel information purpose."
msgstr ""

#, elixir-autogen, elixir-format
msgid "Automatic NeTEx conversion are created from the associated GTFS file and don't contain additional information which can be described in NeTEx."
msgstr ""

#, elixir-autogen, elixir-format
msgid "Automatic NeTEx conversions will not be available <b>after 2025-06-01</b>."
msgstr ""

#, elixir-autogen, elixir-format
msgid "Cancel"
msgstr ""

#, elixir-autogen, elixir-format
msgid "Download the automatic NeTEx conversion"
msgstr ""
16 changes: 16 additions & 0 deletions apps/transport/priv/gettext/fr/LC_MESSAGES/page-dataset-details.po
Original file line number Diff line number Diff line change
Expand Up @@ -721,3 +721,19 @@ msgstr "Données sous la responsabilité de"
#, elixir-autogen, elixir-format
msgid "This unofficial dataset is provided experimentally. Do not use it for travel information purpose."
msgstr "Ce jeu de données non officiel est publié à titre expérimental. Veuillez ne pas le réutiliser à des fins d’information voyageur."

#, elixir-autogen, elixir-format
msgid "Automatic NeTEx conversion are created from the associated GTFS file and don't contain additional information which can be described in NeTEx."
msgstr "Les conversions automatiques NeTEx sont générées à partir du fichier GTFS associé et ne contiennent pas d'informations supplémentaires qui peuvent être décrites en NeTEx."

#, elixir-autogen, elixir-format
msgid "Automatic NeTEx conversions will not be available <b>after 2025-06-01</b>."
msgstr "Les conversions automatiques NeTEx ne seront plus disponibles <b>après le 01/06/2025</b>."

#, elixir-autogen, elixir-format
msgid "Cancel"
msgstr "Annuler"

#, elixir-autogen, elixir-format
msgid "Download the automatic NeTEx conversion"
msgstr "Télécharger la conversion automatique NeTEx"
16 changes: 16 additions & 0 deletions apps/transport/priv/gettext/page-dataset-details.pot
Original file line number Diff line number Diff line change
Expand Up @@ -721,3 +721,19 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "This unofficial dataset is provided experimentally. Do not use it for travel information purpose."
msgstr ""

#, elixir-autogen, elixir-format
msgid "Automatic NeTEx conversion are created from the associated GTFS file and don't contain additional information which can be described in NeTEx."
msgstr ""

#, elixir-autogen, elixir-format
msgid "Automatic NeTEx conversions will not be available <b>after 2025-06-01</b>."
msgstr ""

#, elixir-autogen, elixir-format
msgid "Cancel"
msgstr ""

#, elixir-autogen, elixir-format
msgid "Download the automatic NeTEx conversion"
msgstr ""
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ defmodule TransportWeb.DatasetControllerTest do
convert_from: "GTFS",
convert_to: "NeTEx",
converter: DB.DataConversion.converter_to_use("NeTEx"),
payload: %{"permanent_url" => conversion_url = "https://super-cellar-url.com/netex"}
payload: %{"permanent_url" => other_conversion_url = "https://super-cellar-url.com/netex"}
)

Transport.History.Fetcher.Mock
Expand All @@ -77,8 +77,23 @@ defmodule TransportWeb.DatasetControllerTest do
html_response = conn |> get(dataset_path(conn, :details, dataset.slug)) |> html_response(200)
assert html_response =~ "Conversions automatiques"
assert html_response =~ "NeTEx"
assert html_response =~ conversion_path(conn, :get, resource.id, :NeTEx)
refute html_response =~ conversion_url

# NeTEx conversion's URL is displayed in a modal with 2 buttons
netex_url = conversion_url(TransportWeb.Endpoint, :get, resource.id, :NeTEx)

assert [
{"a", [{"class", "classic button"}, {"rel", "nofollow"}, {"href", ^netex_url}],
[
{"i", _, []},
"Télécharger la conversion automatique NeTEx\n "
]},
{"a", [{"href", "#"}, {"class", "classic button secondary"}], ["\nAnnuler\n "]}
] =
html_response
|> Floki.parse_document!()
|> Floki.find(".modal .button__group .button")

refute html_response =~ other_conversion_url
refute html_response =~ "GeoJSON"
end
end
Expand Down

0 comments on commit 09aa127

Please sign in to comment.