1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-21 22:29:38 +02:00

Fix: make date format year consistent overall #1712 (#1726)
Some checks are pending
Publish Docker image / ci (push) Waiting to run
Publish Docker image / Build docker image (push) Blocked by required conditions

* Fix: make date format year consistent overall

* chore: Consolidating all date formatting options

* adding disabled condition back to mint import

* chore: Moving formats from helper to models/family.rd

* Adding date_format_label to the en translation for import/configurations

* nit: making changes to use individual translations
This commit is contained in:
scodes73 2025-02-03 11:19:56 -05:00 committed by GitHub
parent b02380ac97
commit f57fa526af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 23 additions and 21 deletions

View file

@ -1,20 +1,6 @@
module ApplicationHelper module ApplicationHelper
include Pagy::Frontend include Pagy::Frontend
def date_format_options
[
[ "DD-MM-YYYY", "%d-%m-%Y" ],
[ "DD.MM.YYYY", "%d.%m.%Y" ],
[ "MM-DD-YYYY", "%m-%d-%Y" ],
[ "YYYY-MM-DD", "%Y-%m-%d" ],
[ "DD/MM/YYYY", "%d/%m/%Y" ],
[ "YYYY/MM/DD", "%Y/%m/%d" ],
[ "MM/DD/YYYY", "%m/%d/%Y" ],
[ "D/MM/YYYY", "%e/%m/%Y" ],
[ "YYYY.MM.DD", "%Y.%m.%d" ]
]
end
def icon(key, size: "md", color: "current") def icon(key, size: "md", color: "current")
render partial: "shared/icon", locals: { key:, size:, color: } render partial: "shared/icon", locals: { key:, size:, color: }
end end

View file

@ -1,7 +1,17 @@
class Family < ApplicationRecord class Family < ApplicationRecord
include Plaidable, Syncable include Plaidable, Syncable
DATE_FORMATS = [ "%m-%d-%Y", "%d.%m.%Y", "%d-%m-%Y", "%Y-%m-%d", "%d/%m/%Y", "%Y/%m/%d", "%m/%d/%Y", "%e/%m/%Y", "%Y.%m.%d" ] DATE_FORMATS = [
[ "MM-DD-YYYY", "%m-%d-%Y" ],
[ "DD.MM.YYYY", "%d.%m.%Y" ],
[ "DD-MM-YYYY", "%d-%m-%Y" ],
[ "YYYY-MM-DD", "%Y-%m-%d" ],
[ "DD/MM/YYYY", "%d/%m/%Y" ],
[ "YYYY/MM/DD", "%Y/%m/%d" ],
[ "MM/DD/YYYY", "%m/%d/%Y" ],
[ "D/MM/YYYY", "%e/%m/%Y" ],
[ "YYYY.MM.DD", "%Y.%m.%d" ]
].freeze
include Providable include Providable
@ -21,7 +31,7 @@ class Family < ApplicationRecord
has_many :budget_categories, through: :budgets has_many :budget_categories, through: :budgets
validates :locale, inclusion: { in: I18n.available_locales.map(&:to_s) } validates :locale, inclusion: { in: I18n.available_locales.map(&:to_s) }
validates :date_format, inclusion: { in: DATE_FORMATS } validates :date_format, inclusion: { in: DATE_FORMATS.map(&:last) }
def sync_data(start_date: nil) def sync_data(start_date: nil)
update!(last_synced_at: Time.current) update!(last_synced_at: Time.current)

View file

@ -8,7 +8,7 @@
<%= styled_form_with model: @import, url: import_configuration_path(@import), scope: :import, method: :patch, class: "space-y-2" do |form| %> <%= styled_form_with model: @import, url: import_configuration_path(@import), scope: :import, method: :patch, class: "space-y-2" do |form| %>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<%= form.select :date_col_label, import.csv_headers, { include_blank: "Leave empty", label: "Date" }, required: true, disabled: import.complete? %> <%= form.select :date_col_label, import.csv_headers, { include_blank: "Leave empty", label: "Date" }, required: true, disabled: import.complete? %>
<%= form.select :date_format, [["DD-MM-YYYY", "%d-%m-%Y"], ["MM-DD-YYYY", "%m-%d-%Y"], ["YYYY-MM-DD", "%Y-%m-%d"], ["DD/MM/YYYY", "%d/%m/%Y"], ["YYYY/MM/DD", "%Y/%m/%d"], ["MM/DD/YYYY", "%m/%d/%Y"]], { label: true }, required: true, disabled: import.complete? %> <%= form.select :date_format, Family::DATE_FORMATS, { label: t(".date_format_label")}, label: true, required: true, disabled: import.complete? %>
</div> </div>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">

View file

@ -3,7 +3,7 @@
<%= styled_form_with model: @import, url: import_configuration_path(@import), scope: :import, method: :patch, class: "space-y-2" do |form| %> <%= styled_form_with model: @import, url: import_configuration_path(@import), scope: :import, method: :patch, class: "space-y-2" do |form| %>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<%= form.select :date_col_label, import.csv_headers, { include_blank: "Leave empty", label: "Date" }, required: true %> <%= form.select :date_col_label, import.csv_headers, { include_blank: "Leave empty", label: "Date" }, required: true %>
<%= form.select :date_format, [["DD-MM-YYYY", "%d-%m-%Y"], ["DD.MM.YY", "%d.%m.%y"], ["MM-DD-YYYY", "%m-%d-%Y"], ["YYYY-MM-DD", "%Y-%m-%d"], ["DD/MM/YYYY", "%d/%m/%Y"], ["YYYY/MM/DD", "%Y/%m/%d"], ["MM/DD/YYYY", "%m/%d/%Y"]], label: true, required: true %> <%= form.select :date_format, Family::DATE_FORMATS, { label: t(".date_format_label")}, label: true, required: true %>
</div> </div>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">

View file

@ -3,7 +3,7 @@
<%= styled_form_with model: @import, url: import_configuration_path(@import), scope: :import, method: :patch, class: "space-y-2" do |form| %> <%= styled_form_with model: @import, url: import_configuration_path(@import), scope: :import, method: :patch, class: "space-y-2" do |form| %>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<%= form.select :date_col_label, import.csv_headers, { include_blank: "Leave empty", label: "Date" }, required: true %> <%= form.select :date_col_label, import.csv_headers, { include_blank: "Leave empty", label: "Date" }, required: true %>
<%= form.select :date_format, [["DD-MM-YYYY", "%d-%m-%Y"], ["DD.MM.YY", "%d.%m.%y"], ["MM-DD-YYYY", "%m-%d-%Y"], ["YYYY-MM-DD", "%Y-%m-%d"], ["DD/MM/YYYY", "%d/%m/%Y"], ["YYYY/MM/DD", "%Y/%m/%d"], ["MM/DD/YYYY", "%m/%d/%Y"]], label: true, required: true %> <%= form.select :date_format, Family::DATE_FORMATS, { label: t(".date_format_label")}, label: true, required: true %>
</div> </div>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">

View file

@ -72,7 +72,7 @@
{ data: { action: "onboarding#setCurrency" } } %> { data: { action: "onboarding#setCurrency" } } %>
<%= family_form.select :date_format, <%= family_form.select :date_format,
date_format_options, Family::DATE_FORMATS,
{ label: t(".date_format"), required: true, selected: params[:date_format] || @user.family.date_format }, { label: t(".date_format"), required: true, selected: params[:date_format] || @user.family.date_format },
{ data: { action: "onboarding#setDateFormat" } } %> { data: { action: "onboarding#setDateFormat" } } %>

View file

@ -25,7 +25,7 @@
{ data: { auto_submit_form_target: "auto" } } %> { data: { auto_submit_form_target: "auto" } } %>
<%= family_form.select :date_format, <%= family_form.select :date_format,
date_format_options, Family::DATE_FORMATS,
{ label: t(".date_format") }, { label: t(".date_format") },
{ data: { auto_submit_form_target: "auto" } } %> { data: { auto_submit_form_target: "auto" } } %>

View file

@ -8,6 +8,12 @@ en:
details. details.
title: Clean your data title: Clean your data
configurations: configurations:
trade_import:
date_format_label: Date format
mint_import:
date_format_label: Date format
transaction_import:
date_format_label: Date format
show: show:
description: Select the columns that correspond to each field in your CSV. description: Select the columns that correspond to each field in your CSV.
title: Configure your import title: Configure your import