~ihabunek/triglav

9876d35df9782a2f368ee22cf296c7692472562f — Ivan Habunek a month ago 29b1f73 upgrade
wip
M lib/triglav/public_transport/validation/errors.ex => lib/triglav/public_transport/validation/errors.ex +2 -2
@@ 3,7 3,7 @@ defmodule Triglav.PublicTransport.Validation.Errors do
  alias Triglav.PublicTransport.Schemas.{Feed, Route, RouteRelationPlatform}
  alias Triglav.Schemas.Osmosis.{Relation, RelationMember, Way}

  import Phoenix.LiveView.Helpers
  use Phoenix.Component

  @spec no_relations(Feed.t(), Route.t()) :: Error.t()
  def no_relations(feed, route) do


@@ 315,7 315,7 @@ defmodule Triglav.PublicTransport.Validation.Errors do
    }

    ~H"""
    Route member #<%= sequence_id %>: one-way way #<%= way_id %> "<%= name %>" traveresed in wrong direction.
    Route member #<%= @sequence_id %>: one-way way #<%= @way_id %> "<%= @name %>" traveresed in wrong direction.
    <a class="josm-remote" href={@href} target="josm">Load</a>
    """
  end

M lib/triglav_web.ex => lib/triglav_web.ex +1 -2
@@ 59,12 59,11 @@ defmodule TriglavWeb do
  defp view_helpers do
    quote do
      # Use all HTML functionality (forms, tags, etc)
      use Phoenix.HTML
      import Phoenix.HTML

      # Import basic rendering functionality (render, render_layout, etc)
      import Phoenix.View

      import TriglavWeb.ErrorHelpers
      import TriglavWeb.OsmHelpers
      import TriglavWeb.ViewHelpers
      alias TriglavWeb.Router.Helpers, as: Routes

M lib/triglav_web/components/poi.ex => lib/triglav_web/components/poi.ex +7 -3
@@ 22,9 22,11 @@ defmodule TriglavWeb.Components.Poi do
        end)
        |> Enum.join(", ")

      assigns = assign(assigns, summary: summary, diffs: diffs)

      ~H"""
      <details>
        <summary><%= summary %></summary>
        <summary><%= @summary %></summary>

        <table class="border border-gray-300">
          <thead>


@@ 35,7 37,7 @@ defmodule TriglavWeb.Components.Poi do
            </tr>
          </thead>
          <tbody>
            <%= for {key, poi_value, osm_value, cmd} <- diffs do %>
            <%= for {key, poi_value, osm_value, cmd} <- @diffs do %>
              <tr>
                  <td><%= key %></td>
                <%= if cmd == :same do %>


@@ 66,6 68,8 @@ defmodule TriglavWeb.Components.Poi do

      """
    else
      assigns = assign(assigns, tags: poi_node.tags)

      ~H"""
      <details>
        <summary>Show tags</summary>


@@ 77,7 81,7 @@ defmodule TriglavWeb.Components.Poi do
            </tr>
          </thead>
          <tbody>
            <%= for {key, value} <- poi_node.tags do %>
            <%= for {key, value} <- @tags do %>
              <tr>
                <td><%= key %></td>
                <td><%= value %></td>

M lib/triglav_web/components/public_transport.ex => lib/triglav_web/components/public_transport.ex +25 -24
@@ 7,28 7,30 @@ defmodule TriglavWeb.Components.PublicTransport do
  import TriglavWeb.ViewHelpers

  def navbar(assigns) do
    pages = [
      %{
        name: "Routes",
        path: Routes.public_transport_path(assigns.conn, :routes, assigns.feed.operator.slug),
        active: "routes" in assigns.conn.path_info
      },
      %{
        name: "Stops",
        path: Routes.public_transport_path(assigns.conn, :stops, assigns.feed.operator.slug),
        active: List.last(assigns.conn.path_info) == "stops"
      },
      %{
        name: "Errors",
        path: Routes.public_transport_path(assigns.conn, :errors_list, assigns.feed.operator.slug),
        active: "errors" in assigns.conn.path_info
      },
      %{
        name: "Data",
        path: Routes.public_transport_path(assigns.conn, :data, assigns.feed.operator.slug),
        active: List.last(assigns.conn.path_info) == "data"
      }
    ]
    pages =
      [
        %{
          name: "Routes",
          path: Routes.public_transport_path(assigns.conn, :routes, assigns.feed.operator.slug),
          active: "routes" in assigns.conn.path_info
        },
        %{
          name: "Stops",
          path: Routes.public_transport_path(assigns.conn, :stops, assigns.feed.operator.slug),
          active: List.last(assigns.conn.path_info) == "stops"
        },
        %{
          name: "Errors",
          path: Routes.public_transport_path(assigns.conn, :errors_list, assigns.feed.operator.slug),
          active: "errors" in assigns.conn.path_info
        },
        %{
          name: "Data",
          path: Routes.public_transport_path(assigns.conn, :data, assigns.feed.operator.slug),
          active: List.last(assigns.conn.path_info) == "data"
        }
      ]
      |> Enum.map(&Map.put(&1, :class, classes(["text-white", %{"font-bold" => &1.active}])))

    assigns = assign(assigns, :pages, pages)



@@ 37,8 39,7 @@ defmodule TriglavWeb.Components.PublicTransport do
      <div class="container flex space-x-10 items-baseline">
        <b class="text-lg"><%= @feed.operator.ref %></b>
        <%= for page <- @pages do %>
          <% class = classes(["text-white", %{"font-bold" => page.active}]) %>
          <a class={class} href={page.path}><%= page.name %></a>
          <a class={page.class} href={page.path}><%= page.name %></a>
        <% end %>
      </div>
    </nav>

D lib/triglav_web/views/error_helpers.ex => lib/triglav_web/views/error_helpers.ex +0 -30
@@ 1,30 0,0 @@
defmodule TriglavWeb.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

M lib/triglav_web/views/osm_helpers.ex => lib/triglav_web/views/osm_helpers.ex +2 -2
@@ 169,9 169,9 @@ defmodule TriglavWeb.OsmHelpers do

    ~H"""
    <ul class="list-none ml-0">
      <%= for {master, routes} <- @annotated_masters do %>
      <%= for {master, master_routes} <- @annotated_masters do %>
        <li><%= osm_link(master, name: true, tags: ["type", "ref"]) %></li>
        <%= for {_id, route} <- routes do %>
        <%= for {_id, route} <- master_routes do %>
          <%= if route do %>
            <li>↳ <%= osm_link(route, name: true, tags: ["type", "ref"]) %></li>
          <% end %>

M mix.exs => mix.exs +1 -1
@@ 52,7 52,7 @@ defmodule Triglav.MixProject do
      {:parent, "~> 0.12.1"},
      {:phoenix, "~> 1.6.0"},
      {:phoenix_ecto, "~> 4.1"},
      {:phoenix_html, "~> 3.0"},
      {:phoenix_html, "~> 4.0"},
      {:phoenix_live_dashboard, "~> 0.5"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:plug_cowboy, "~> 2.0"},

M mix.lock => mix.lock +4 -4
@@ 39,10 39,10 @@
  "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
  "phoenix": {:hex, :phoenix, "1.6.16", "e5bdd18c7a06da5852a25c7befb72246de4ddc289182285f8685a40b7b5f5451", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 1.0 or ~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e15989ff34f670a96b95ef6d1d25bad0d9c50df5df40b671d8f4a669e050ac39"},
  "phoenix_ecto": {:hex, :phoenix_ecto, "4.5.0", "1a1f841ccda19b15f1d82968840a5b895c5f687b6734e430e4b2dbe035ca1837", [:mix], [{:ecto, "~> 3.5", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.1", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "13990570fde09e16959ef214501fe2813e1192d62ca753ec8798980580436f94"},
  "phoenix_html": {:hex, :phoenix_html, "3.3.3", "380b8fb45912b5638d2f1d925a3771b4516b9a78587249cabe394e0a5d579dc9", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "923ebe6fec6e2e3b3e569dfbdc6560de932cd54b000ada0208b5f45024bdd76c"},
  "phoenix_live_dashboard": {:hex, :phoenix_live_dashboard, "0.6.5", "1495bb014be12c9a9252eca04b9af54246f6b5c1e4cd1f30210cd00ec540cf8e", [:mix], [{:ecto, "~> 3.6.2 or ~> 3.7", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_mysql_extras, "~> 0.3", [hex: :ecto_mysql_extras, repo: "hexpm", optional: true]}, {:ecto_psql_extras, "~> 0.7", [hex: :ecto_psql_extras, repo: "hexpm", optional: true]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.17.7", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6.0", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "ef4fa50dd78364409039c99cf6f98ab5209b4c5f8796c17f4db118324f0db852"},
  "phoenix_html": {:hex, :phoenix_html, "4.1.1", "4c064fd3873d12ebb1388425a8f2a19348cef56e7289e1998e2d2fa758aa982e", [:mix], [], "hexpm", "f2f2df5a72bc9a2f510b21497fd7d2b86d932ec0598f0210fed4114adc546c6f"},
  "phoenix_live_dashboard": {:hex, :phoenix_live_dashboard, "0.8.3", "7ff51c9b6609470f681fbea20578dede0e548302b0c8bdf338b5a753a4f045bf", [:mix], [{:ecto, "~> 3.6.2 or ~> 3.7", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_mysql_extras, "~> 0.5", [hex: :ecto_mysql_extras, repo: "hexpm", optional: true]}, {:ecto_psql_extras, "~> 0.7", [hex: :ecto_psql_extras, repo: "hexpm", optional: true]}, {:ecto_sqlite3_extras, "~> 1.1.7 or ~> 1.2.0", [hex: :ecto_sqlite3_extras, repo: "hexpm", optional: true]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19 or ~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6 or ~> 1.0", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "f9470a0a8bae4f56430a23d42f977b5a6205fdba6559d76f932b876bfaec652d"},
  "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.3.3", "3a53772a6118d5679bf50fc1670505a290e32a1d195df9e069d8c53ab040c054", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "766796676e5f558dbae5d1bdb066849673e956005e3730dfd5affd7a6da4abac"},
  "phoenix_live_view": {:hex, :phoenix_live_view, "0.17.7", "05a42377075868a678d446361effba80cefef19ab98941c01a7a4c7560b29121", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.5.9 or ~> 1.6.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.1", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "25eaf41028eb351b90d4f69671874643a09944098fefd0d01d442f40a6091b6f"},
  "phoenix_live_view": {:hex, :phoenix_live_view, "0.20.11", "63975ad42e09f21ad0db53e6ee449804c844995019d133fee275900f29e4a099", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6.15 or ~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.3 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.15", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "56eb5a75e0981ce362b0daf50a6c1a6385863a767db3ae06ae17461458da0bc8"},
  "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.3", "3168d78ba41835aecad272d5e8cd51aa87a7ac9eb836eabc42f6e57538e3731d", [:mix], [], "hexpm", "bba06bc1dcfd8cb086759f0edc94a8ba2bc8896d5331a1e2c2902bf8e36ee502"},
  "phoenix_template": {:hex, :phoenix_template, "1.0.4", "e2092c132f3b5e5b2d49c96695342eb36d0ed514c5b252a77048d5969330d639", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "2c0c81f0e5c6753faf5cca2f229c9709919aba34fab866d3bc05060c9c444206"},
  "phoenix_view": {:hex, :phoenix_view, "2.0.3", "4d32c4817fce933693741deeb99ef1392619f942633dde834a5163124813aad3", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}], "hexpm", "cd34049af41be2c627df99cd4eaa71fc52a328c0c3d8e7d4aa28f880c30e7f64"},


@@ 60,7 60,7 @@
  "table_rex": {:hex, :table_rex, "4.0.0", "3c613a68ebdc6d4d1e731bc973c233500974ec3993c99fcdabb210407b90959b", [:mix], [], "hexpm", "c35c4d5612ca49ebb0344ea10387da4d2afe278387d4019e4d8111e815df8f55"},
  "tailwind": {:hex, :tailwind, "0.1.9", "25ba09d42f7bfabe170eb67683a76d6ec2061952dc9bd263a52a99ba3d24bd4d", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "9213f87709c458aaec313bb5f2df2b4d2cedc2b630e4ae821bf3c54c47a56d0b"},
  "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
  "telemetry_metrics": {:hex, :telemetry_metrics, "0.6.1", "315d9163a1d4660aedc3fee73f33f1d355dcc76c5c3ab3d59e76e3edf80eef1f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7be9e0871c41732c233be71e4be11b96e56177bf15dde64a8ac9ce72ac9834c6"},
  "telemetry_metrics": {:hex, :telemetry_metrics, "0.6.2", "2caabe9344ec17eafe5403304771c3539f3b6e2f7fb6a6f602558c825d0d0bfb", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "9b43db0dc33863930b9ef9d27137e78974756f5f198cae18409970ed6fa5b561"},
  "telemetry_poller": {:hex, :telemetry_poller, "1.0.0", "db91bb424e07f2bb6e73926fcafbfcbcb295f0193e0a00e825e589a0a47e8453", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b3a24eafd66c3f42da30fc3ca7dda1e9d546c12250a2d60d7b81d264fbec4f6e"},
  "tesla": {:hex, :tesla, "1.4.4", "bb89aa0c9745190930366f6a2ac612cdf2d0e4d7fff449861baa7875afd797b2", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:finch, "~> 0.3", [hex: :finch, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, "~> 1.3", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "d5503a49f9dec1b287567ea8712d085947e247cb11b06bc54adb05bfde466457"},
  "tzdata": {:hex, :tzdata, "1.1.1", "20c8043476dfda8504952d00adac41c6eda23912278add38edc140ae0c5bcc46", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "a69cec8352eafcd2e198dea28a34113b60fdc6cb57eb5ad65c10292a6ba89787"},