mirror of
https://github.com/we-promise/sure.git
synced 2026-04-08 23:04:49 +00:00
* Implement API v1 Imports controller - Add Api::V1::ImportsController with index, show, and create actions - Add Jbuilder views for index and show - Add integration tests - Implement row generation logic in create action - Update routes * Validate import account belongs to family - Add validation to Import model to ensure account belongs to the same family - Add regression test case in Api::V1::ImportsControllerTest * updating docs to be more detailed * Rescue StandardError instead of bare rescue in ImportsController * Optimize Imports API and fix documentation - Implement rows_count counter cache for Imports - Preload rows in Api::V1::ImportsController#show - Update documentation to show correct OAuth scopes * Fix formatting in ImportsControllerTest * Permit all import parameters and fix unknown attribute error * Restore API routes for auth, chats, and messages * removing pr summary * Fix trailing whitespace and configured? test failure - Update Import#configured? to use rows_count for performance and consistency - Mock rows_count in TransactionImportTest - Fix trailing whitespace in migration * Harden security and fix mass assignment in ImportsController - Handle type and account_id explicitly in create action - Rename import_params to import_config_params for clarity - Validate type against Import::TYPES * Fix MintImport rows_count update and migration whitespace - Update MintImport#generate_rows_from_csv to update rows_count counter cache - Fix trailing whitespace and final newline in AddRowsCountToImports migration * Implement full-screen Drag and Drop CSV import on Transactions page - Add DragAndDropImport Stimulus controller listening on document - Add full-screen overlay with icon and text to Transactions index - Update ImportsController to handle direct file uploads via create action - Add system test for drag and drop functionality * Implement Drag and Drop CSV upload on Import Upload page - Add drag-and-drop-import controller to import/uploads/show - Add full-screen overlay to import/uploads/show - Annotate upload form and input with drag-and-drop targets - Add PR_SUMMARY.md * removing pr summary * Add file validation to ImportsController - Validate file size (max 10MB) and MIME type in create action - Prevent memory exhaustion and invalid file processing - Defined MAX_CSV_SIZE and ALLOWED_MIME_TYPES in Import model * Refactor dragLeave logic with counter pattern to prevent flickering * Extract shared drag-and-drop overlay partial - Create app/views/imports/_drag_drop_overlay.html.erb - Update transactions/index and import/uploads/show to use the partial - Reduce code duplication in views * Update Brakeman and harden ImportsController security - Update brakeman to 7.1.2 - Explicitly handle type assignment in ImportsController#create to avoid mass assignment - Remove :type from permitted import parameters * Fix trailing whitespace in DragAndDropImportTest * Don't commit LLM comments as file * FIX add api validation --------- Co-authored-by: Carlos Adames <cj@Carloss-MacBook-Air.local> Co-authored-by: Juan José Mata <jjmata@jjmata.com> Co-authored-by: sokie <sokysrm@gmail.com>
132 lines
6.3 KiB
Plaintext
132 lines
6.3 KiB
Plaintext
<div class="space-y-4 pb-20 flex flex-col">
|
|
<header class="flex justify-between items-center text-primary font-medium">
|
|
<h1 class="text-xl">Transactions</h1>
|
|
<div class="flex items-center gap-5">
|
|
<div class="flex items-center gap-2">
|
|
<%= render DS::Menu.new do |menu| %>
|
|
<% menu.with_item(variant: "link", text: "New rule", href: new_rule_path(resource_type: "transaction"), icon: "plus", data: { turbo_frame: :modal }) %>
|
|
<% menu.with_item(variant: "link", text: "Edit rules", href: rules_path, icon: "git-branch", data: { turbo_frame: :_top }) %>
|
|
<% menu.with_item(variant: "link", text: "Edit categories", href: categories_path, icon: "shapes", data: { turbo_frame: :_top }) %>
|
|
<% menu.with_item(variant: "link", text: "Edit tags", href: tags_path, icon: "tags", data: { turbo_frame: :_top }) %>
|
|
<% menu.with_item(variant: "link", text: "Edit merchants", href: family_merchants_path, icon: "store", data: { turbo_frame: :_top }) %>
|
|
<% menu.with_item(variant: "link", text: "Edit imports", href: imports_path, icon: "hard-drive-upload", data: { turbo_frame: :_top }) %>
|
|
<% menu.with_item(variant: "link", text: "Import", href: new_import_path, icon: "download", data: { turbo_frame: "modal", class_name: "md:!hidden" }) %>
|
|
<% end %>
|
|
|
|
<div class="hidden md:flex">
|
|
<%= render DS::Link.new(
|
|
text: t(".import"),
|
|
icon: "download",
|
|
variant: "outline",
|
|
href: new_import_path,
|
|
frame: :modal,
|
|
) %>
|
|
</div>
|
|
|
|
<%= render DS::Link.new(
|
|
text: "New transaction",
|
|
icon: "plus",
|
|
variant: "primary",
|
|
href: new_transaction_path,
|
|
frame: :modal,
|
|
class: "hidden md:inline-flex"
|
|
) %>
|
|
|
|
<%= render DS::Link.new(
|
|
icon: "plus",
|
|
variant: "icon-inverse",
|
|
href: new_transaction_path,
|
|
frame: :modal,
|
|
class: "rounded-full md:hidden"
|
|
) %>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<%= render "summary", totals: @search.totals %>
|
|
|
|
<div id="transactions"
|
|
data-controller="bulk-select checkbox-toggle drag-and-drop-import"
|
|
data-bulk-select-singular-label-value="<%= t(".transaction") %>"
|
|
data-bulk-select-plural-label-value="<%= t(".transactions") %>"
|
|
class="flex flex-col bg-container rounded-xl shadow-border-xs px-3 py-4 lg:p-4 relative group">
|
|
|
|
<%= form_with url: imports_path, method: :post, class: "hidden", data: { drag_and_drop_import_target: "form" } do |f| %>
|
|
<%= f.hidden_field "import[type]", value: "TransactionImport" %>
|
|
<%= f.file_field "import[csv_file]", class: "hidden", data: { drag_and_drop_import_target: "input" }, accept: ".csv" %>
|
|
<% end %>
|
|
|
|
<%= render "imports/drag_drop_overlay", title: "Drop CSV to import", subtitle: "Upload transactions directly" %>
|
|
|
|
<%= render "transactions/searches/search" %>
|
|
|
|
<div id="entry-selection-bar" data-bulk-select-target="selectionBar" class="flex justify-center hidden">
|
|
<%= render "transactions/selection_bar" %>
|
|
</div>
|
|
|
|
<% if @pagy.count > 0 || (@projected_recurring.any? && @q.blank?) %>
|
|
<div class="grow overflow-y-auto">
|
|
<% if @transactions.any? %>
|
|
<div class="grid-cols-12 bg-container-inset rounded-xl px-5 py-3 text-xs uppercase font-medium text-secondary items-center mb-4 grid">
|
|
<div class="pl-0.5 col-span-8 flex items-center gap-4">
|
|
<%= check_box_tag "selection_entry",
|
|
class: "checkbox checkbox--light hidden lg:block",
|
|
data: {
|
|
action: "bulk-select#togglePageSelection",
|
|
checkbox_toggle_target: "selectionEntry"
|
|
} %>
|
|
<p>transaction</p>
|
|
</div>
|
|
|
|
<p class="col-span-2 md:block hidden">category</p>
|
|
<p class="col-span-2 col-start-11 md:col-start-auto justify-self-end md:block">amount</p>
|
|
</div>
|
|
<% end %>
|
|
|
|
<div class="space-y-6">
|
|
<% if @projected_recurring.any? && @q.blank? %>
|
|
<div
|
|
class="space-y-2"
|
|
data-controller="transactions-section"
|
|
data-transactions-section-section-key-value="upcoming_recurring"
|
|
data-transactions-section-collapsed-value="<%= Current.user.transactions_section_collapsed?("upcoming_recurring") %>">
|
|
<div class="flex items-center gap-2 px-2">
|
|
<button
|
|
type="button"
|
|
class="text-secondary hover:text-primary transition-colors p-0.5"
|
|
data-action="click->transactions-section#toggle keydown->transactions-section#handleToggleKeydown"
|
|
data-transactions-section-target="button"
|
|
aria-label="<%= t("transactions.toggle_recurring_section") %>"
|
|
aria-expanded="<%= !Current.user.transactions_section_collapsed?("upcoming_recurring") %>">
|
|
<%= icon("chevron-down", size: "sm", class: "transition-transform", data: { transactions_section_target: "chevron" }) %>
|
|
</button>
|
|
<h3 class="text-xs uppercase font-medium text-secondary"><%= t("recurring_transactions.upcoming") %></h3>
|
|
</div>
|
|
<div data-transactions-section-target="content">
|
|
<% @projected_recurring.group_by(&:next_expected_date).sort.each do |date, transactions| %>
|
|
<div class="space-y-2">
|
|
<div class="text-xs text-secondary px-2 pt-2"><%= l(date, format: :long) %></div>
|
|
<% transactions.each do |recurring_transaction| %>
|
|
<%= render "recurring_transactions/projected_transaction", recurring_transaction: recurring_transaction %>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
|
|
<%= entries_by_date(@transactions.map(&:entry), totals: true) do |entries| %>
|
|
<%= render entries %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<% else %>
|
|
<%= render "entries/empty" %>
|
|
<% end %>
|
|
|
|
<div class="pt-4">
|
|
<%= render "shared/pagination", pagy: @pagy %>
|
|
</div>
|
|
</div>
|
|
</div>
|