Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
3.8 KB
Raw Blame
<%# locals: (entry:, balance_trend: nil, **) %>

<% trade = entry.entryable %>
<% trade_logo_url = trade.security&.display_logo_url %>

<%= turbo_frame_tag dom_id(entry) do %>
  <%= turbo_frame_tag dom_id(trade) do %>
    <div class="group grid grid-cols-12 items-center [html[data-layout-animating]_&:not(:has([aria-expanded=true])):not(:has([role=tooltip]:not(.hidden)))]:[content-visibility:auto] [contain-intrinsic-size:auto_--spacing(18)] <%= entry.excluded ? "text-secondary bg-surface-inset" : "text-primary" %> text-sm font-medium p-4"
         data-controller="clickable-row"
         data-action="click->clickable-row#open">
      <div class="col-span-8 flex items-center gap-4">
        <%= check_box_tag dom_id(entry, "selection"),
                        class: "checkbox checkbox--light hidden lg:block",
                        data: {
                          id: entry.id,
                          entry_type: entry.entryable_type,
                          "bulk-select-target": "row",
                          action: "bulk-select#toggleRowSelection",
                          checkbox_toggle_target: "selectionEntry"
                        } %>

        <div class="max-w-full">
          <%= tag.div class: ["flex items-center gap-3 lg:gap-4 min-w-0"] do %>
            <div class="hidden lg:flex">
              <% if trade_logo_url.present? %>
                <%= image_tag Setting.transform_brand_fetch_url(trade_logo_url),
                    class: "w-9 h-9 rounded-full border border-secondary",
                    loading: "lazy" %>
              <% else %>
                <%= render DS::FilledIcon.new(
                  variant: :text,
                  text: trade.security&.ticker || entry.name,
                  size: "lg",
                  rounded: true
                ) %>
              <% end %>
            </div>

            <div class="flex lg:hidden">
              <%= render "investment_activity/quick_edit_badge", entry: entry, entryable: trade %>
            </div>

            <div class="truncate flex-shrink">
              <%= link_to entry.name,
                        entry_path(entry),
                        data: { turbo_frame: "drawer", turbo_prefetch: false, clickable_row_target: "link" },
                        class: "hover:underline" %>
            </div>

            <% if entry.scheduled? %>
              <div class="flex items-center gap-1 flex-shrink-0">
                <%= render DS::Pill.new(
                  label: t("trades.trade.scheduled"),
                  tone: :neutral,
                  marker: false,
                  icon: "calendar"
                ) %>
                <%= render DS::Tooltip.new(text: t("trades.trade.scheduled_tooltip"), as: :span) %>
              </div>
            <% end %>
          <% end %>
        </div>
      </div>

      <div class="hidden lg:flex col-span-2 items-center">
        <%= render "investment_activity/quick_edit_badge", entry: entry, entryable: trade %>
      </div>

      <div class="shrink-0 col-span-4 lg:col-span-2 ml-auto flex items-center justify-end gap-2">
        <%# Protection indicator - shows on hover when entry is protected from sync %>
        <% if entry.protected_from_sync? && !entry.excluded? %>
          <%= link_to entry_path(entry),
                data: { turbo_frame: "drawer", turbo_prefetch: false },
                class: "invisible group-hover:visible transition-opacity",
                title: t("entries.protection.tooltip") do %>
            <%= icon "lock", size: "sm", class: "text-secondary" %>
          <% end %>
        <% end %>

        <%= content_tag :p,
                    format_money(-entry.amount_money),
                    class: ["privacy-sensitive", "text-green-600": entry.amount.negative?] %>
      </div>
    </div>
  <% end %>
<% end %>