@@ -105,6 +105,7 @@ defmodule TransportWeb.NeTExReportComponents do
105105 errors = { errors }
106106 validation_report_url = { @ validation_report_url }
107107 pagination = { @ pagination }
108+ results_adapter = { @ results_adapter }
108109 />
109110 """
110111 end
@@ -138,41 +139,55 @@ defmodule TransportWeb.NeTExReportComponents do
138139 end
139140
140141 defp netex_validation_selected_category (
141- % { conn: _ , compliance_check: _ , current_category: _ , errors: _ , validation_report_url: _ , pagination: _ } =
142+ % {
143+ conn: _ ,
144+ compliance_check: _ ,
145+ current_category: _ ,
146+ errors: _ ,
147+ validation_report_url: _ ,
148+ pagination: _ ,
149+ results_adapter: _
150+ } =
142151 assigns
143152 ) do
144153 ~H"""
145154 <% locale = get_session ( @ conn , :locale ) %>
146155 < div class = "selected-category " >
147- < . netex_category_description category = { @ current_category } compliance_check = { @ compliance_check } conn = { @ conn } />
156+ < . netex_category_description
157+ category = { @ current_category }
158+ compliance_check = { @ compliance_check }
159+ conn = { @ conn }
160+ results_adapter = { @ results_adapter }
161+ />
148162 < . netex_category_comment count = { Enum . count ( @ errors ) } category = { @ current_category } />
149163
150- < div :if = { @ current_category == "xsd-schema" and Enum . count ( @ errors ) > 0 } id = "issues-list " >
151- < p >
152- { dgettext (
153- "validations-explanations" ,
154- "Here is a summary of XSD validation errors. Full detail of those errors is available in the <a href=\" %{validation_report_url}\" target=\" _blank\" >CSV report</a>. Those errors are produced by <a href=\" https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html\" target=\" _blank\" >xmllint</a>." ,
155- validation_report_url: @ validation_report_url
156- )
157- |> raw ( ) }
158- </ p >
159- < . non_translated_messages locale = { locale } />
160- < table class = "table netex_xsd_schema " >
161- < tr >
162- < th > { dgettext ( "validations-explanations" , "Occurrences" ) } </ th >
163- < th > { dgettext ( "validations-explanations" , "Message" ) } </ th >
164- </ tr >
165-
166- < tr :for = { xsd_error <- @ errors } class = "message " >
167- < td > { Helpers . format_number ( xsd_error [ "counts" ] , locale: locale ) } </ td >
168- < td lang = "en " > { xsd_error [ "message" ] } </ td >
169- </ tr >
170- </ table >
171- </ div >
172- < div :if = { @ current_category != "xsd-schema" and Enum . count ( @ errors ) > 0 } id = "issues-list " >
173- < . non_translated_messages locale = { locale } />
174- < . netex_generic_issues issues = { @ errors } />
175- { @ pagination }
164+ < div :if = { Enum . count ( @ errors ) > 0 } id = "issues-list " >
165+ <%= if @ current_category == "xsd-schema" do %>
166+ < p >
167+ { dgettext (
168+ "validations-explanations" ,
169+ "Here is a summary of XSD validation errors. Full detail of those errors is available in the <a href=\" %{validation_report_url}\" target=\" _blank\" >CSV report</a>. Those errors are produced by <a href=\" https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html\" target=\" _blank\" >xmllint</a>." ,
170+ validation_report_url: @ validation_report_url
171+ )
172+ |> raw ( ) }
173+ </ p >
174+ < . non_translated_messages locale = { locale } />
175+ < table class = "table netex_xsd_schema " >
176+ < tr >
177+ < th > { dgettext ( "validations-explanations" , "Occurrences" ) } </ th >
178+ < th > { dgettext ( "validations-explanations" , "Message" ) } </ th >
179+ </ tr >
180+
181+ < tr :for = { xsd_error <- @ errors } class = "message " >
182+ < td > { Helpers . format_number ( xsd_error [ "counts" ] , locale: locale ) } </ td >
183+ < td lang = "en " > { xsd_error [ "message" ] } </ td >
184+ </ tr >
185+ </ table >
186+ <% else %>
187+ < . non_translated_messages locale = { locale } />
188+ < . netex_generic_issues issues = { @ errors } />
189+ { @ pagination }
190+ <% end %>
176191 </ div >
177192 </ div >
178193 """
@@ -259,11 +274,33 @@ defmodule TransportWeb.NeTExReportComponents do
259274 """
260275 end
261276
262- defp netex_category_tooltip ( % { category: _ , compliance_check: _ } = assigns ) do
277+ defp with_string ( proc ) do
278+ { :ok , device } = StringIO . open ( "" )
279+
280+ proc . ( device )
281+
282+ StringIO . flush ( device )
283+ end
284+
285+ defp netex_category_tooltip ( % { category: _ , compliance_check: _ , results_adapter: _ , conn: _ } = assigns ) do
263286 ~H"""
287+ <% french_profile = @ results_adapter . french_profile ( ) %>
264288 < p :if = { @ category == "french-profile" } >
265289 < . info_icon /> { french_profile_comment ( @ compliance_check ) }
290+ < button :if = { french_profile } class = "button-outline small secondary " popovertarget = "french-profile-rules " >
291+ < i class = "fa fa-circle-question " aria-hidden = "true " > </ i > { dgettext ( "validations" , "Learn more" ) }
292+ </ button >
266293 </ p >
294+ < dialog :if = { french_profile } id = "french-profile-rules " popover class = "panel inline-help " >
295+ < div class = "header_with_action_bar " >
296+ < h5 > { dgettext ( "validations" , "List of French Profile rules currently checked" ) } </ h5 >
297+ < button popovertarget = "french-profile-rules " popovertargetaction = "hide " class = "small secondary " >
298+ < i class = "fa fa-close " > </ i >
299+ </ button >
300+ </ div >
301+ <% markdown = with_string ( & french_profile . markdown ( & 1 , header_level: 6 ) ) %>
302+ { markdown_to_safe_html! ( markdown ) }
303+ </ dialog >
267304 """
268305 end
269306
@@ -272,6 +309,23 @@ defmodule TransportWeb.NeTExReportComponents do
272309 """
273310 end
274311
312+ defp markdown_to_safe_html! ( markdown ) do
313+ case TransportWeb.MarkdownHandler . markdown_to_safe_html! ( markdown ) do
314+ { :safe , safe } -> { :safe , update_links_target ( safe ) }
315+ otherwise -> otherwise
316+ end
317+ end
318+
319+ defp update_links_target ( html ) do
320+ html
321+ |> Floki . parse_fragment! ( )
322+ |> Floki . traverse_and_update ( fn
323+ { "a" , attrs , children } -> { "a" , [ { "target" , "_blank" } | attrs ] , children }
324+ other -> other
325+ end )
326+ |> Floki . raw_html ( )
327+ end
328+
275329 defp french_profile_comment ( :none ) , do: dgettext ( "validations" , "netex-french-profile-no-compliance" ) |> raw ( )
276330 defp french_profile_comment ( :partial ) , do: dgettext ( "validations" , "netex-french-profile-partial-compliance" ) |> raw ( )
277331 defp french_profile_comment ( :good_enough ) , do: ""
@@ -309,14 +363,19 @@ defmodule TransportWeb.NeTExReportComponents do
309363 Map . reject ( query_params , fn { _ , v } -> is_nil ( v ) end )
310364 end
311365
312- defp netex_category_description ( % { category: _ , compliance_check: _ , conn: _ } = assigns ) do
366+ defp netex_category_description ( % { category: _ , compliance_check: _ , conn: _ , results_adapter: _ } = assigns ) do
313367 ~H"""
314368 <% url = netex_link_to_category ( @ conn , "french-profile" ) %>
315369 <% description = netex_category_description_html ( @ category , url ) %>
316370 < p :if = { description } >
317371 { raw ( description ) }
318372 </ p >
319- < . netex_category_tooltip category = { @ category } compliance_check = { @ compliance_check } />
373+ < . netex_category_tooltip
374+ category = { @ category }
375+ compliance_check = { @ compliance_check }
376+ results_adapter = { @ results_adapter }
377+ conn = { @ conn }
378+ />
320379 """
321380 end
322381
0 commit comments