The personal finance app for everyone (by everyone)
Ruby
Add a notes field to the property form (#5058)
arnaurodondev427526777ad1
diff --git a/app/views/properties/_form_tabs.html.erb b/app/views/properties/_form_tabs.html.erbindex b862faa4c6..a58887b02e 100644--- a/app/views/properties/_form_tabs.html.erb+++ b/app/views/properties/_form_tabs.html.erb@@ -1,7 +1,36 @@<%# locals: (account:, active_tab:) %>-<div class="flex flex-col gap-0.5 w-[156px] shrink-0">- <%= render "properties/form_tab", label: t(".overview"), href: account.new_record? ? nil : edit_property_path(@account), active: active_tab == "overview" %>- <%= render "properties/form_tab", label: t(".value"), href: account.new_record? ? nil : balances_property_path(@account), active: active_tab == "value" %>- <%= render "properties/form_tab", label: t(".address"), href: account.new_record? ? nil : address_property_path(@account), active: active_tab == "address" %>+<%# A segmented control above the form on small screens, a sidebar from md up.+ Only one of the two is displayed at a time, so assistive tech and the tab+ order see a single set of tabs. A new property has no saved record to+ link to yet, so its steps are shown but can't be selected. %>+<% tabs = [+ { key: "overview", label: t(".overview"), href: account.new_record? ? nil : edit_property_path(account) },+ { key: "value", label: t(".value"), href: account.new_record? ? nil : balances_property_path(account) },+ { key: "address", label: t(".address"), href: account.new_record? ? nil : address_property_path(account) }+ ] %>++<%= render DS::SegmentedControl.new(full_width: true, aria_label: t(".aria_label"), class: "md:hidden") do |sc| %>+ <% tabs.each do |tab| %>+ <% if tab[:href] %>+ <% sc.with_segment(+ tag.span(tab[:label], class: "truncate"),+ active: active_tab == tab[:key],+ href: tab[:href],+ class: "min-w-0",+ data: { turbo_frame: :modal }) %>+ <% else %>+ <% sc.with_segment(+ tag.span(tab[:label], class: "truncate"),+ active: active_tab == tab[:key],+ disabled: true,+ class: class_names("min-w-0 cursor-default", "hover:bg-transparent" => active_tab != tab[:key])) %>+ <% end %>+ <% end %>+<% end %>++<div class="hidden md:flex md:flex-col gap-0.5 md:w-[156px] shrink-0">+ <% tabs.each do |tab| %>+ <%= render "properties/form_tab", label: tab[:label], href: tab[:href], active: active_tab == tab[:key] %>+ <% end %></div>diff --git a/app/views/properties/_overview_fields.html.erb b/app/views/properties/_overview_fields.html.erbindex 41d079f2db..325f272ec0 100644--- a/app/views/properties/_overview_fields.html.erb+++ b/app/views/properties/_overview_fields.html.erb@@ -32,4 +32,8 @@</div><% end %>+ <%= form.text_area :notes,+ label: t(".notes_label"),+ placeholder: t(".notes_placeholder"),+ rows: 4 %></div>diff --git a/app/views/properties/address.html.erb b/app/views/properties/address.html.erbindex a8b873c7cc..d6066d20a1 100644--- a/app/views/properties/address.html.erb+++ b/app/views/properties/address.html.erb@@ -1,8 +1,8 @@<%= render DS::Dialog.new do |dialog| %><% dialog.with_header(title: t(".title")) %><% dialog.with_body do %>- <div class="flex gap-4">- <!-- Left sidebar with tabs -->+ <div class="flex flex-col md:flex-row gap-4">+ <!-- Tabs: a row above the form on small screens, a sidebar from md up --><%= render "properties/form_tabs", account: @account, active_tab: "address" %><!-- Right content area with form -->diff --git a/app/views/properties/balances.html.erb b/app/views/properties/balances.html.erbindex 4604a19898..049a103c71 100644--- a/app/views/properties/balances.html.erb+++ b/app/views/properties/balances.html.erb@@ -1,7 +1,7 @@<%= render DS::Dialog.new do |dialog| %><% dialog.with_header(title: t(".title")) %><% dialog.with_body do %>- <div class="flex gap-4">+ <div class="flex flex-col md:flex-row gap-4"><%= render "properties/form_tabs", account: @account, active_tab: "value" %><!-- Right content area with form -->diff --git a/app/views/properties/edit.html.erb b/app/views/properties/edit.html.erbindex 8e4c4e82a5..bbaadf55f1 100644--- a/app/views/properties/edit.html.erb+++ b/app/views/properties/edit.html.erb@@ -1,8 +1,8 @@<%= render DS::Dialog.new do |dialog| %><% dialog.with_header(title: t(".title")) %><% dialog.with_body do %>- <div class="flex gap-4">- <!-- Left sidebar with tabs -->+ <div class="flex flex-col md:flex-row gap-4">+ <!-- Tabs: a row above the form on small screens, a sidebar from md up --><%= render "properties/form_tabs", account: @account, active_tab: "overview" %><!-- Right content area with form -->diff --git a/app/views/properties/new.html.erb b/app/views/properties/new.html.erbindex a62e2eda80..89fbc19068 100644--- a/app/views/properties/new.html.erb+++ b/app/views/properties/new.html.erb@@ -10,8 +10,8 @@<%= render DS::Dialog.new do |dialog| %><% dialog.with_header(title: t(".title")) %><% dialog.with_body do %>- <div class="flex gap-4">- <!-- Left sidebar with tabs -->+ <div class="flex flex-col md:flex-row gap-4">+ <!-- Tabs: a row above the form on small screens, a sidebar from md up --><%= render "properties/form_tabs", account: @account, active_tab: "overview" %><!-- Right content area with form -->diff --git a/config/locales/views/properties/en.yml b/config/locales/views/properties/en.ymlindex 85594f082b..8969daa8df 100644--- a/config/locales/views/properties/en.yml+++ b/config/locales/views/properties/en.yml@@ -80,6 +80,8 @@ en:save: "Save"next: "Next"overview_fields:+ notes_label: "Notes"+ notes_placeholder: "Registry or cadastral number, deed reference, notary, etc."name_label: "Name"name_placeholder: "Vacation home"subtype_prompt: "Select type"@@ -142,5 +144,6 @@ en:long: Agricultural Landform_tabs:address: Address+ aria_label: Property detailsoverview: Overviewvalue: Valuediff --git a/test/controllers/properties_controller_test.rb b/test/controllers/properties_controller_test.rbindex 2653bed07b..1445a201fa 100644--- a/test/controllers/properties_controller_test.rb+++ b/test/controllers/properties_controller_test.rb@@ -767,6 +767,16 @@ class PropertiesControllerTest < ActionDispatch::IntegrationTestassert_redirected_to new_property_pathend+ test "new and edit forms let the user keep notes on the property" do+ @account.update!(notes: "Cadastral number 12345")++ get edit_property_url(@account)+ assert_select "textarea[name='account[notes]']", text: "Cadastral number 12345"++ get new_property_url+ assert_select "textarea[name='account[notes]']"+ end+test "edit form leaves out the icon picker, which property updates do not save" doget edit_property_url(@account)