1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-07 14:35:23 +02:00

Allow CSV imports to be configured with single or multi-account mode (#1943)

* Allow CSV imports to be configured to a single account or multiple accounts

* Initialize import directly from accounts page

* Fix brakeman warnings

* Fix schema

* Fix Synth check
This commit is contained in:
Zach Gollwitzer 2025-03-03 12:47:30 -05:00 committed by GitHub
parent e907b073ed
commit c5da8ea550
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 118 additions and 57 deletions

View file

@ -19,33 +19,33 @@
</div>
</div>
<div data-tabs-target="tab" id="csv-paste-tab">
<%= styled_form_with model: @import, scope: :import, url: import_upload_path(@import), multipart: true, class: "space-y-2" do |form| %>
<%= form.select :col_sep, [["Comma (,)", ","], ["Semicolon (;)", ";"]], label: true %>
<%= form.text_area :raw_file_str,
<% ["csv-paste-tab", "csv-upload-tab"].each do |tab| %>
<%= tag.div id: tab, data: { tabs_target: "tab" }, class: tab == "csv-upload-tab" ? "hidden" : "" do %>
<%= styled_form_with model: @import, scope: :import, url: import_upload_path(@import), multipart: true, class: "space-y-2" do |form| %>
<%= form.select :col_sep, Import::SEPARATORS, label: true %>
<% unless @import.type == "MintImport" %>
<%= form.select :account_id, @import.family.accounts.pluck(:name, :id), { label: "Account (optional)", include_blank: "Multi-account import", selected: @import.account_id } %>
<% end %>
<% if tab == "csv-paste-tab" %>
<%= form.text_area :raw_file_str,
rows: 10,
required: true,
placeholder: "Paste your CSV file contents here",
"data-auto-submit-form-target": "auto" %>
<% else %>
<label for="import_csv_file" class="flex flex-col items-center justify-center w-full h-56 border-2 border-gray-300 border-dashed rounded-lg cursor-pointer bg-gray-50">
<div class="flex flex-col items-center justify-center pt-5 pb-6">
<%= form.file_field :csv_file, class: "ml-32", "data-auto-submit-form-target": "auto" %>
</div>
</label>
<% end %>
<%= form.submit "Upload CSV", disabled: @import.complete? %>
<%= form.submit "Upload CSV", disabled: @import.complete? %>
<% end %>
<% end %>
</div>
<div data-tabs-target="tab" id="csv-upload-tab" class="hidden">
<%= styled_form_with model: @import, scope: :import, url: import_upload_path(@import), multipart: true, class: "space-y-2" do |form| %>
<%= form.select :col_sep, [["Comma (,)", ","], ["Semicolon (;)", ";"]], label: true %>
<label for="import_csv_file" class="flex flex-col items-center justify-center w-full h-56 border-2 border-gray-300 border-dashed rounded-lg cursor-pointer bg-gray-50">
<div class="flex flex-col items-center justify-center pt-5 pb-6">
<%= form.file_field :csv_file, class: "ml-32", "data-auto-submit-form-target": "auto" %>
</div>
</label>
<%= form.submit "Upload CSV", disabled: @import.complete? %>
<% end %>
</div>
<% end %>
</div>
</div>