-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Utiliser 2 selects (heures et minutes) sur le formulaire de plage d'ouverture #4971
Changes from all commits
e7ddcd3
0df34f2
b8473e3
83c14a2
40c7283
153351c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,4 @@ | ||
module PlageOuverturesHelper | ||
# Generates ["00:00", "00:05", "00:10", ... "23:50", "23:55"] | ||
EVERY_5_MINUTES_OF_THE_DAY = (0..23).flat_map do |h| | ||
padded_h = format("%02i", h) | ||
(0..55).step(5).map do |m| | ||
padded_min = format("%02i", m) | ||
"#{padded_h}:#{padded_min}" | ||
end | ||
end.freeze | ||
|
||
def every_5_minutes_of_the_day | ||
EVERY_5_MINUTES_OF_THE_DAY | ||
end | ||
|
||
Comment on lines
-2
to
-14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cette logique est fournie par Rails à travers le paramètre |
||
def display_recurrence(plage_ouverture) | ||
every_part = display_every(plage_ouverture) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ module RecurrenceConcern | |
|
||
included do | ||
serialize :recurrence, coder: Montrose::Recurrence | ||
serialize :start_time, coder: Tod::TimeOfDay | ||
serialize :end_time, coder: Tod::TimeOfDay | ||
attribute :start_time, :time_only # uses Tod::TimeOfDayType | ||
attribute :end_time, :time_only # uses Tod::TimeOfDayType | ||
|
||
before_save :clear_empty_recurrence, :set_recurrence_ends_at | ||
|
||
|
@@ -22,8 +22,8 @@ module RecurrenceConcern | |
class_methods do | ||
def serialize_for_active_job(record) | ||
manually_serialized_attrs = { | ||
start_time: Tod::TimeOfDay.dump(record.start_time), | ||
end_time: Tod::TimeOfDay.dump(record.end_time), | ||
start_time: record.start_time.to_s, | ||
end_time: record.end_time.to_s, | ||
Comment on lines
-25
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cette sérialisation manuelle a été ajoutée dans #4625, à contre cœur, lorsque nous avons constaté que les serializers custom ActiveJob ne fonctionnaient pas en prod (alors qu'ils fonctionnent en dev et test 😬 ) |
||
recurrence: Montrose::Recurrence.dump(record.recurrence), | ||
} | ||
record.attributes.merge(manually_serialized_attrs.stringify_keys) | ||
|
@@ -32,8 +32,8 @@ def serialize_for_active_job(record) | |
def deserialize_for_active_job(hash) | ||
hash = hash.symbolize_keys | ||
manually_deserialized_attrs = { | ||
start_time: Tod::TimeOfDay.load(hash[:start_time]), | ||
end_time: Tod::TimeOfDay.load(hash[:end_time]), | ||
start_time: Tod::TimeOfDay.parse(hash[:start_time]), | ||
end_time: Tod::TimeOfDay.parse(hash[:end_time]), | ||
recurrence: Montrose::Recurrence.load(hash[:recurrence]), | ||
} | ||
new(hash.merge(manually_deserialized_attrs)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍