aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorZog2018-05-03 09:50:23 +0200
committercedricnjanga2018-05-03 16:06:35 -0700
commitd768698125f45ac35278c015e5cca99e0861b0d7 (patch)
tree1529b3758f026c3cfeb17e2a78e0e8a91ba65cd6 /app
parentdb65c0ffc7ccc76a144689ec3db43fbc2e61ee82 (diff)
downloadchouette-core-d768698125f45ac35278c015e5cca99e0861b0d7.tar.bz2
Refs #6867; Remove duplicated entries in TZ select
Diffstat (limited to 'app')
-rw-r--r--app/inputs/full_time_zone_input.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/inputs/full_time_zone_input.rb b/app/inputs/full_time_zone_input.rb
index f5d8a9ba2..b3f43fa19 100644
--- a/app/inputs/full_time_zone_input.rb
+++ b/app/inputs/full_time_zone_input.rb
@@ -1,7 +1,13 @@
class FullTimeZoneInput < SimpleForm::Inputs::CollectionSelectInput
def collection
@collection ||= begin
- collection = options.delete(:collection) || ActiveSupport::TimeZone::MAPPING
+ collection = options.delete(:collection) || begin
+ coll = ActiveSupport::TimeZone::MAPPING.invert
+ coll.sort_by do |k, v|
+ tz = ActiveSupport::TimeZone[k]
+ "(#{tz.formatted_offset}) #{tz.name}"
+ end
+ end
collection.respond_to?(:call) ? collection.call : collection.to_a
end
end
@@ -10,10 +16,10 @@ class FullTimeZoneInput < SimpleForm::Inputs::CollectionSelectInput
label, value = options.delete(:label_method), options.delete(:value_method)
label ||= ->(tz) do
- tz = ActiveSupport::TimeZone[tz.last]
+ tz = ActiveSupport::TimeZone[tz.first]
"(#{tz.formatted_offset}) #{tz.name}"
end
- value ||= :last
+ value ||= :first
[label, value]
end