Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
6.0 KB
Raw Blame
<%= content_for :page_title, t(".page_title") %>

<div class="space-y-6">
  <%= settings_section title: t(".title"), subtitle: t(".subtitle") do %>
    <%= form_with url: settings_debug_path, method: :get, class: "grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4 items-end" do |f| %>
      <div>
        <%= f.label :category, t(".filters.category"), class: "block text-sm font-medium text-primary mb-1" %>
        <%= f.select :category, options_for_select([[t(".filters.all"), ""]] + @categories.map { |value| [value, value] }, params[:category]), {}, class: "rounded-lg border border-primary px-3 py-2 text-sm bg-container-inset text-primary w-full" %>
      </div>
      <div>
        <%= f.label :level, t(".filters.level"), class: "block text-sm font-medium text-primary mb-1" %>
        <%= f.select :level, options_for_select([[t(".filters.all"), ""]] + @levels.map { |value| [value, value] }, params[:level]), {}, class: "rounded-lg border border-primary px-3 py-2 text-sm bg-container-inset text-primary w-full" %>
      </div>
      <div>
        <%= f.label :source, t(".filters.source"), class: "block text-sm font-medium text-primary mb-1" %>
        <%= f.select :source, options_for_select([[t(".filters.all"), ""]] + @sources.map { |value| [value, value] }, params[:source]), {}, class: "rounded-lg border border-primary px-3 py-2 text-sm bg-container-inset text-primary w-full" %>
      </div>
      <div>
        <%= f.label :provider_key, t(".filters.provider"), class: "block text-sm font-medium text-primary mb-1" %>
        <%= f.select :provider_key, options_for_select([[t(".filters.all"), ""]] + @provider_keys.map { |value| [value, value] }, params[:provider_key]), {}, class: "rounded-lg border border-primary px-3 py-2 text-sm bg-container-inset text-primary w-full" %>
      </div>
      <div>
        <%= f.label :start_date, t(".filters.start_date"), class: "block text-sm font-medium text-primary mb-1" %>
        <%= f.date_field :start_date, value: @start_date || params[:start_date], class: "rounded-lg border border-primary px-3 py-2 text-sm bg-container-inset text-primary w-full" %>
      </div>
      <div>
        <%= f.label :end_date, t(".filters.end_date"), class: "block text-sm font-medium text-primary mb-1" %>
        <%= f.date_field :end_date, value: @end_date || params[:end_date], class: "rounded-lg border border-primary px-3 py-2 text-sm bg-container-inset text-primary w-full" %>
      </div>
      <div>
        <%= f.label :family_id, t(".filters.family_id"), class: "block text-sm font-medium text-primary mb-1" %>
        <%= f.text_field :family_id, value: params[:family_id], class: "rounded-lg border border-primary px-3 py-2 text-sm bg-container-inset text-primary w-full font-mono" %>
      </div>
      <div>
        <%= f.label :account_id, t(".filters.account_id"), class: "block text-sm font-medium text-primary mb-1" %>
        <%= f.text_field :account_id, value: params[:account_id], class: "rounded-lg border border-primary px-3 py-2 text-sm bg-container-inset text-primary w-full font-mono" %>
      </div>
      <div>
        <%= f.label :user_id, t(".filters.user_id"), class: "block text-sm font-medium text-primary mb-1" %>
        <%= f.text_field :user_id, value: params[:user_id], class: "rounded-lg border border-primary px-3 py-2 text-sm bg-container-inset text-primary w-full font-mono" %>
      </div>
      <div>
        <%= f.label :account_provider_id, t(".filters.account_provider_id"), class: "block text-sm font-medium text-primary mb-1" %>
        <%= f.text_field :account_provider_id, value: params[:account_provider_id], class: "rounded-lg border border-primary px-3 py-2 text-sm bg-container-inset text-primary w-full font-mono" %>
      </div>
      <div class="flex gap-2 xl:col-span-2">
        <%= render DS::Button.new(variant: :primary, size: :md, type: "submit", text: t(".filters.submit"), class: "justify-center") %>
        <%= render DS::Link.new(text: t(".filters.reset"), href: settings_debug_path, variant: "ghost") %>
      </div>
    <% end %>
  <% end %>

  <%# Seven columns of long-form diagnostics stay cramped however wide the
      settings page gets, so the whole table can be reopened in a near
      full-width dialog — same pattern as the dashboard cashflow chart. %>
  <div class="bg-container rounded-xl shadow-border-xs overflow-hidden group" data-controller="expandable">
    <% if @debug_log_entries.any? %>
      <%# Never hover-only: pointer hover, keyboard focus, and always shown on
          coarse pointers, where there is no hover to reveal it. Viewport width
          is the wrong proxy for that — a large tablet is touch-only well past
          `lg`. Same shape as the dashboard insights feed's row controls. %>
      <div class="flex items-center justify-end px-4 py-2 border-b border-primary">
        <%= render DS::Button.new(
              variant: "icon",
              size: :sm,
              icon: "maximize-2",
              title: t("global.expand"),
              aria_label: t("global.expand"),
              class: "opacity-0 group-hover:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100 transition-opacity",
              data: { action: "click->expandable#open" }
            ) %>
      </div>

      <div class="overflow-x-auto">
        <%= render "settings/debugs/log_table", entries: @debug_log_entries %>
      </div>

      <%= render DS::Dialog.new(
            auto_open: false,
            disable_frame: true,
            width: "expanded",
            data: { expandable_target: "dialog" }
          ) do |dialog| %>
        <% dialog.with_header(title: t(".title"), subtitle: t(".subtitle")) %>
        <% dialog.with_body do %>
          <div class="max-h-[75dvh] overflow-auto overscroll-contain">
            <%= render "settings/debugs/log_table", entries: @debug_log_entries %>
          </div>
        <% end %>
      <% end %>
    <% else %>
      <div class="p-8 text-center text-secondary"><%= t(".empty") %></div>
    <% end %>
  </div>

  <% if @pagy.pages > 1 %>
    <div>
      <%= render "shared/pagination", pagy: @pagy %>
    </div>
  <% end %>
</div>