~ihabunek/triglav

58ec56e4a8c6af46e4195bd9a1d27541f434882d — Ivan Habunek 1 year, 7 months ago 15c8554 poi
Highlight distant mappings
2 files changed, 11 insertions(+), 4 deletions(-)

M lib/triglav_web/templates/poi/nodes.html.heex
M lib/triglav_web/views/view_helpers.ex
M lib/triglav_web/templates/poi/nodes.html.heex => lib/triglav_web/templates/poi/nodes.html.heex +10 -4
@@ 17,14 17,20 @@
        <th>JOSM</th>
      </tr>
      <%= for node <- @nodes do %>
        <% {lon, lat} = node.geometry.coordinates %>
        <% osm_element = if node.mapping, do: node.mapping.osm_node || node.mapping.osm_way %>
        <%
          mapping = node.mapping
          {lon, lat} = node.geometry.coordinates
          osm_element = if mapping, do: mapping.osm_node || mapping.osm_way
          distance_class = classes(["text-center", error: mapping && mapping.distance > 50])
        %>
        <tr>
          <td><%= node.ref %></td>
          <td><%= node.name %></td>
          <%= if node.mapping do %>
          <%= if mapping do %>
            <td><%= osm_link(osm_element) %></td>
            <td class="text-right"><%= round(node.mapping.distance) %>m</td>
            <td class={distance_class}>
              <%= round(mapping.distance) %>m
            </td>
          <% else %>
            <td colspan="2">
              <%= josm_add_node(lat, lon, node.tags) %>

M lib/triglav_web/views/view_helpers.ex => lib/triglav_web/views/view_helpers.ex +1 -0
@@ 27,6 27,7 @@ defmodule TriglavWeb.ViewHelpers do
    String.starts_with?(conn.request_path, path)
  end

  def classes({class, condition}), do: if(condition, do: class, else: "")
  def classes(input) when is_atom(input), do: to_string(input)
  def classes(input) when is_binary(input), do: input
  def classes(input) when is_list(input), do: Enum.map_join(input, " ", &classes/1)