Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
2.4 KB
Raw Blame
<%# locals: (settings:, categories:) %>
<div class="space-y-4">
  <%# Which categories it learns, which labels it trusts, then how many. %>
  <div class="flex items-center justify-between gap-x-4">
    <div class="flex-1 min-w-0">
      <p class="text-sm text-primary"><%= t(".categories") %></p>
      <p class="text-xs text-secondary"><%= t(".categories_hint") %></p>
    </div>
    <% excluded = settings.excluded_category_ids %>
    <%= render layout: "pages/dashboard/filter_popover", locals: {
          button_text: excluded.empty? ? t(".categories_all") : t(".categories_some", count: categories.size - excluded.size, total: categories.size),
          search_label: t(".search_categories"),
          apply_text: t(".apply"),
          hidden_fields: { category_filter: "1" },
          url: settings_classifier_path,
          method: :patch,
          form_data: {},
          list_controllers: "list-filter category-filter"
        } do %>
      <%# The transactions filter's cascade: picking a parent covers its
          subcategories, and a parent is submitted only while all of them
          are checked. %>
      <% categories.each do |category| %>
        <%= render layout: "pages/dashboard/filter_popover_option", locals: {
              name: "included_category_ids[]",
              value: category.id,
              checked: excluded.exclude?(category.id.to_s),
              filter_name: category.display_name,
              checkbox_data: {
                category_filter_target: "checkbox",
                action: "change->category-filter#toggle",
                category_id: category.id,
                parent_id: category.parent_id
              }
            } do %>
          <% if category.parent_id.present? %>
            <%= icon("corner-down-right", size: "sm") %>
          <% end %>
          <%= render partial: "categories/badge", locals: { category: category } %>
        <% end %>
      <% end %>
    <% end %>
  </div>

  <%= classifier_section_form do %>
    <%= render "settings/classifiers/option", key: :exclude_transfers, settings: settings,
          label: t(".exclude_transfers"), hint: t(".exclude_transfers_hint") %>
    <%= render "settings/classifiers/option", key: :skip_self_labels, settings: settings,
          number_key: :self_label_grace_days,
          label: t(".skip_self_labels"), hint: t(".skip_self_labels_hint") %>
  <% end %>
</div>