rewrite
This commit is contained in:
parent
ba8f072d23
commit
2c935df494
110 changed files with 1350 additions and 8011 deletions
30
eisrom_ui/lib/eisrom_ui_web/views/error_helpers.ex
Normal file
30
eisrom_ui/lib/eisrom_ui_web/views/error_helpers.ex
Normal file
|
@ -0,0 +1,30 @@
|
|||
defmodule EisromUiWeb.ErrorHelpers do
|
||||
@moduledoc """
|
||||
Conveniences for translating and building error messages.
|
||||
"""
|
||||
|
||||
use Phoenix.HTML
|
||||
|
||||
@doc """
|
||||
Generates tag for inlined form input errors.
|
||||
"""
|
||||
def error_tag(form, field) do
|
||||
Enum.map(Keyword.get_values(form.errors, field), fn error ->
|
||||
content_tag(:span, translate_error(error),
|
||||
class: "invalid-feedback",
|
||||
phx_feedback_for: input_name(form, field)
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Translates an error message.
|
||||
"""
|
||||
def translate_error({msg, opts}) do
|
||||
# Because the error messages we show in our forms and APIs
|
||||
# are defined inside Ecto, we need to translate them dynamically.
|
||||
Enum.reduce(opts, msg, fn {key, value}, acc ->
|
||||
String.replace(acc, "%{#{key}}", fn _ -> to_string(value) end)
|
||||
end)
|
||||
end
|
||||
end
|
16
eisrom_ui/lib/eisrom_ui_web/views/error_view.ex
Normal file
16
eisrom_ui/lib/eisrom_ui_web/views/error_view.ex
Normal file
|
@ -0,0 +1,16 @@
|
|||
defmodule EisromUiWeb.ErrorView do
|
||||
use EisromUiWeb, :view
|
||||
|
||||
# If you want to customize a particular status code
|
||||
# for a certain format, you may uncomment below.
|
||||
# def render("500.html", _assigns) do
|
||||
# "Internal Server Error"
|
||||
# end
|
||||
|
||||
# By default, Phoenix returns the status message from
|
||||
# the template name. For example, "404.html" becomes
|
||||
# "Not Found".
|
||||
def template_not_found(template, _assigns) do
|
||||
Phoenix.Controller.status_message_from_template(template)
|
||||
end
|
||||
end
|
7
eisrom_ui/lib/eisrom_ui_web/views/layout_view.ex
Normal file
7
eisrom_ui/lib/eisrom_ui_web/views/layout_view.ex
Normal file
|
@ -0,0 +1,7 @@
|
|||
defmodule EisromUiWeb.LayoutView do
|
||||
use EisromUiWeb, :view
|
||||
|
||||
# Phoenix LiveDashboard is available only in development by default,
|
||||
# so we instruct Elixir to not warn if the dashboard route is missing.
|
||||
@compile {:no_warn_undefined, {Routes, :live_dashboard_path, 2}}
|
||||
end
|
3
eisrom_ui/lib/eisrom_ui_web/views/page_view.ex
Normal file
3
eisrom_ui/lib/eisrom_ui_web/views/page_view.ex
Normal file
|
@ -0,0 +1,3 @@
|
|||
defmodule EisromUiWeb.PageView do
|
||||
use EisromUiWeb, :view
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue