From 080a02eb25b1ea614b8c83aa2103c961419cc8cf Mon Sep 17 00:00:00 2001 From: ulferts Date: Tue, 3 Mar 2026 18:34:38 +0100 Subject: [PATCH] clarify cost admin settings form --- .../app/views/admin/costs_settings/show.html.erb | 15 +++++++++++++-- modules/costs/config/locales/en.yml | 5 ++++- ...0303172517_suffix_or_prefix_currency_format.rb | 12 ++++++++++++ modules/costs/lib/costs/engine.rb | 2 +- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 modules/costs/db/migrate/20260303172517_suffix_or_prefix_currency_format.rb diff --git a/modules/costs/app/views/admin/costs_settings/show.html.erb b/modules/costs/app/views/admin/costs_settings/show.html.erb index dab2f65b85f..bce17b94489 100644 --- a/modules/costs/app/views/admin/costs_settings/show.html.erb +++ b/modules/costs/app/views/admin/costs_settings/show.html.erb @@ -42,8 +42,19 @@ See COPYRIGHT and LICENSE files for more details. subhead.with_description { I18n.t(:description_costs_settings) } end end - form.text_field(name: :costs_currency, input_width: :small) - form.text_field(name: :costs_currency_format, input_width: :small) + form.text_field( + name: :costs_currency, + input_width: :xsmall, + caption: I18n.t(:setting_costs_currency_caption) + ) + form.select_list( + name: :costs_currency_format, + values: [ + [I18n.t(:setting_costs_currency_format_prefix), "%u %n"], + [I18n.t(:setting_costs_currency_format_suffix), "%n %u"] + ], + input_width: :small + ) form.submit end diff --git a/modules/costs/config/locales/en.yml b/modules/costs/config/locales/en.yml index eee2eed4809..b1d3e79f54e 100644 --- a/modules/costs/config/locales/en.yml +++ b/modules/costs/config/locales/en.yml @@ -224,7 +224,10 @@ en: setting_allow_tracking_start_and_end_times: "Allow start and finish times" setting_costs_currency: "Currency" - setting_costs_currency_format: "Format of currency" + setting_costs_currency_caption: "This is the unit of currency. It can be a three-letter ISO code like EUR, USD or JPY or a symbol like €, $ or ¥." + setting_costs_currency_format: "Currency format" + setting_costs_currency_format_prefix: "Before the number (e.g. EUR 100)" + setting_costs_currency_format_suffix: "After the number (e.g. 100 EUR)" setting_enforce_tracking_start_and_end_times: "Require start and finish times" setting_enforce_without_allow: "Requiring start and finish times is not possible without allowing them" setting_allow_tracking_start_and_end_times_caption: "Enables entering start and finish times when logging time." diff --git a/modules/costs/db/migrate/20260303172517_suffix_or_prefix_currency_format.rb b/modules/costs/db/migrate/20260303172517_suffix_or_prefix_currency_format.rb new file mode 100644 index 00000000000..ee9ac1560b6 --- /dev/null +++ b/modules/costs/db/migrate/20260303172517_suffix_or_prefix_currency_format.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class SuffixOrPrefixCurrencyFormat < ActiveRecord::Migration[8.1] + def up + execute <<~SQL.squish + UPDATE settings + SET value = '%n %u' + WHERE name = 'costs_currency_format' + AND value NOT IN ('%u %n', '%n %u'); + SQL + end +end diff --git a/modules/costs/lib/costs/engine.rb b/modules/costs/lib/costs/engine.rb index 698b425fba4..1fe57a590fd 100644 --- a/modules/costs/lib/costs/engine.rb +++ b/modules/costs/lib/costs/engine.rb @@ -167,7 +167,7 @@ module Costs initializer "costs.settings" do ::Settings::Definition.add "costs_currency", default: "€", format: :string - ::Settings::Definition.add "costs_currency_format", default: "%n %u", format: :string + ::Settings::Definition.add "costs_currency_format", default: "%n %u", format: :string, allowed: ["%u %n", "%n %u"] ::Settings::Definition.add "allow_tracking_start_and_end_times", default: false, format: :boolean ::Settings::Definition.add "enforce_tracking_start_and_end_times", default: false, format: :boolean end