The personal finance app for everyone (by everyone)
Ruby
Fix statement Turbo frame navigation and split view/edit actions (#2614) (#2695)
Bishal Shrestha82df89ef4566
diff --git a/app/views/accounts/show/_statements.html.erb b/app/views/accounts/show/_statements.html.erbindex 3a5d4a11ae..6be92fd4e3 100644--- a/app/views/accounts/show/_statements.html.erb+++ b/app/views/accounts/show/_statements.html.erb@@ -19,6 +19,7 @@aria: { label: t("account_statements.account_tab.year_label") } %><% end %><%= link_to account_statements_path,+ data: { turbo_frame: "_top" },class: "inline-flex items-center gap-2 text-sm font-medium text-primary hover:text-primary-hover" do %><%= icon("inbox", size: "sm") %><%= t("account_statements.account_tab.open_inbox") %>@@ -75,7 +76,11 @@<% statements.each do |statement| %><tr id="<%= dom_id(statement) %>" class="border-b border-subdued hover:bg-surface-hover"><td class="px-3 py-3">- <%= link_to account_statement_path(statement), class: "flex items-center gap-2 min-w-0 text-sm font-medium text-primary hover:underline" do %>+ <% file_attached = statement.original_file.attached? %>+ <%= link_to file_attached ? rails_blob_path(statement.original_file, disposition: "inline") : account_statement_path(statement),+ target: (file_attached ? "_blank" : nil),+ data: { turbo_frame: "_top" },+ class: "flex items-center gap-2 min-w-0 text-sm font-medium text-primary hover:underline" do %><%= icon(account_statement_file_icon(statement), size: "sm") %><span class="truncate"><%= statement.filename %></span><% end %>@@ -94,10 +99,25 @@</td><td class="px-3 py-3"><div class="flex items-center justify-end gap-3">- <%= link_to account_statement_path(statement), aria: { label: t("account_statements.table.view") } do %>- <%= icon("eye", class: "w-5 h-5 text-primary") %>+ <%# View: open the actual file inline (PDF) or download (CSV/XLSX) %>+ <% if file_attached %>+ <%= link_to rails_blob_path(statement.original_file, disposition: "inline"),+ target: "_blank",+ data: { turbo_frame: "_top" },+ aria: { label: t("account_statements.table.view") } do %>+ <%= icon("eye", class: "w-5 h-5 text-primary") %>+ <% end %>+ <% end %>++ <%# Edit: go to statement details/edit page %>+ <%= link_to account_statement_path(statement),+ data: { turbo_frame: "_top" },+ aria: { label: t("account_statements.table.edit") } do %>+ <%= icon("pencil", class: "w-5 h-5 text-primary") %><% end %>- <% if statement.original_file.attached? %>++ <%# Download %>+ <% if file_attached %><%= link_to rails_blob_path(statement.original_file, disposition: "attachment"), aria: { label: t("account_statements.table.download") } do %><%= icon("download", class: "w-5 h-5 text-primary") %><% end %>@@ -106,6 +126,7 @@<%= button_to unlink_account_statement_path(statement),method: :patch,class: "flex items-center",+ form: { data: { turbo_frame: "_top" } },aria: { label: t("account_statements.table.unlink") } do %><%= icon("unlink", class: "w-5 h-5 text-secondary") %><% end %>diff --git a/config/locales/views/account_statements/ca.yml b/config/locales/views/account_statements/ca.ymlindex 84f7324242..d4e0df21fb 100644--- a/config/locales/views/account_statements/ca.yml+++ b/config/locales/views/account_statements/ca.yml@@ -105,6 +105,7 @@ ca:account: Compteactions: Accionsdownload: Descarrega+ edit: Editafile: Fitxerlink_suggestion: Suggeriment d'enllaçperiod: Períodediff --git a/config/locales/views/account_statements/de.yml b/config/locales/views/account_statements/de.ymlindex 52d629ca47..47d372156d 100644--- a/config/locales/views/account_statements/de.yml+++ b/config/locales/views/account_statements/de.yml@@ -102,6 +102,7 @@ de:account: Kontoactions: Aktionendownload: Herunterladen+ edit: Bearbeitenfile: Dateilink_suggestion: Verknüpfungsvorschlagperiod: Zeitraumdiff --git a/config/locales/views/account_statements/en.yml b/config/locales/views/account_statements/en.ymlindex 78e21ae574..6a4062d47d 100644--- a/config/locales/views/account_statements/en.yml+++ b/config/locales/views/account_statements/en.yml@@ -102,6 +102,7 @@ en:account: Accountactions: Actionsdownload: Download+ edit: Editfile: Filelink_suggestion: Link suggestionperiod: Perioddiff --git a/config/locales/views/account_statements/es.yml b/config/locales/views/account_statements/es.ymlindex 3486f844db..8572eb7180 100644--- a/config/locales/views/account_statements/es.yml+++ b/config/locales/views/account_statements/es.yml@@ -102,6 +102,7 @@ es:account: Cuentaactions: Accionesdownload: Descargar+ edit: Editarfile: Archivolink_suggestion: Sugerencia de vínculoperiod: Periododiff --git a/config/locales/views/account_statements/fr.yml b/config/locales/views/account_statements/fr.ymlindex 57d8714237..b2b0265374 100644--- a/config/locales/views/account_statements/fr.yml+++ b/config/locales/views/account_statements/fr.yml@@ -107,6 +107,7 @@ fr:account: Compteactions: Actionsdownload: Télécharger+ edit: Modifierfile: Fichierlink_suggestion: Suggestion de lienperiod: Périodediff --git a/config/locales/views/account_statements/hu.yml b/config/locales/views/account_statements/hu.ymlindex 0a3fc5966d..8a9201114f 100644--- a/config/locales/views/account_statements/hu.yml+++ b/config/locales/views/account_statements/hu.yml@@ -102,6 +102,7 @@ hu:account: Számlaactions: Műveletekdownload: Letöltés+ edit: Szerkesztésfile: Fájllink_suggestion: Kapcsolati javaslatperiod: Időszakdiff --git a/config/locales/views/account_statements/nl.yml b/config/locales/views/account_statements/nl.ymlindex bc33505b94..35e302f6ed 100644--- a/config/locales/views/account_statements/nl.yml+++ b/config/locales/views/account_statements/nl.yml@@ -102,6 +102,7 @@ nl:account: Accountactions: Actiesdownload: Downloaden+ edit: Bewerkenfile: Bestandlink_suggestion: Koppelsuggestieperiod: Periodediff --git a/config/locales/views/account_statements/pt-BR.yml b/config/locales/views/account_statements/pt-BR.ymlindex 7f8f840573..5a44e1cb76 100644--- a/config/locales/views/account_statements/pt-BR.yml+++ b/config/locales/views/account_statements/pt-BR.yml@@ -102,6 +102,7 @@ pt-BR:account: Contaactions: Açõesdownload: Baixar+ edit: Editarfile: Arquivolink_suggestion: Sugestão de vínculoperiod: Períododiff --git a/config/locales/views/account_statements/ru.yml b/config/locales/views/account_statements/ru.ymlindex 0c67d7872a..6a33009f2b 100644--- a/config/locales/views/account_statements/ru.yml+++ b/config/locales/views/account_statements/ru.yml@@ -110,6 +110,7 @@ ru:account: Счётactions: Действияdownload: Скачать+ edit: Редактироватьfile: Файлlink_suggestion: Предложение привязкиperiod: Периодdiff --git a/config/locales/views/account_statements/vi.yml b/config/locales/views/account_statements/vi.ymlindex 709ca0c452..b68ed162be 100644--- a/config/locales/views/account_statements/vi.yml+++ b/config/locales/views/account_statements/vi.yml@@ -102,6 +102,7 @@ vi:account: Tài khoảnactions: Hành độngdownload: Tải xuống+ edit: Chỉnh sửafile: Tệplink_suggestion: Gợi ý liên kếtperiod: Kỳdiff --git a/config/locales/views/account_statements/zh-CN.yml b/config/locales/views/account_statements/zh-CN.ymlindex 73e27a5139..96001b4939 100644--- a/config/locales/views/account_statements/zh-CN.yml+++ b/config/locales/views/account_statements/zh-CN.yml@@ -102,6 +102,7 @@ zh-CN:account: 账户actions: 操作download: 下载+ edit: 编辑file: 文件link_suggestion: 关联建议period: 周期diff --git a/test/controllers/accounts_controller_test.rb b/test/controllers/accounts_controller_test.rbindex 8ace6ec048..a62ead4ac3 100644--- a/test/controllers/accounts_controller_test.rb+++ b/test/controllers/accounts_controller_test.rb@@ -31,6 +31,39 @@ class AccountsControllerTest < ActionDispatch::IntegrationTestassert_select "turbo-frame[src='#{statements_path}']"end+ test "statements tab links escape turbo frame for full-page navigation" do+ # Upload a statement to ensure table rows render+ statement = AccountStatement.create_from_upload!(+ family: @account.family,+ file: uploaded_file(+ filename: "test.pdf",+ content_type: "application/pdf",+ content: "%PDF-1.4 test content"+ ),+ account: @account+ )+++ get account_url(@account, tab: "statements")++ assert_response :success++ # Inbox link escapes frame+ assert_select "a[href='#{account_statements_path}'][data-turbo-frame='_top']"++ # Statement filename link escapes frame+ assert_select "a[data-turbo-frame='_top']", text: statement.filename++ # Eye/view icon escapes frame and opens in new tab+ assert_select "a[target='_blank'][data-turbo-frame='_top'][aria-label='#{I18n.t("account_statements.table.view")}']"++ # Edit icon escapes frame+ assert_select "a[href='#{account_statement_path(statement)}'][data-turbo-frame='_top'][aria-label='#{I18n.t("account_statements.table.edit")}']"++ # Unlink button escapes frame+ assert_select "form[action='#{unlink_account_statement_path(statement)}'][data-turbo-frame='_top'] button"+ end+test "statements tab shows coverage and upload for statement managers with account write access" doget account_url(@account, tab: "statements")