add all day settting
This commit is contained in:
parent
90c411f378
commit
3867b8fc69
|
@ -21,7 +21,7 @@ class EventNewsController < ApplicationController
|
||||||
target = a.is_external_link ? "_blank" : "_self"
|
target = a.is_external_link ? "_blank" : "_self"
|
||||||
doc = Nokogiri::HTML(a.title)
|
doc = Nokogiri::HTML(a.title)
|
||||||
title = doc.text.empty? ? 'no content' : doc.text
|
title = doc.text.empty? ? 'no content' : doc.text
|
||||||
event_time = (a.event_date.strftime('%Y-%m-%d %H:%M') rescue "")
|
event_time = (a.event_date.strftime(a.date_parse_format) rescue "")
|
||||||
if a.event_end_date
|
if a.event_end_date
|
||||||
event_time = "<span class=\"start_date\">#{event_time.split(" ")[0]}</span> ~ <span class=\"end_date\">#{a.event_end_date.strftime('%Y-%m-%d')}</span>"
|
event_time = "<span class=\"start_date\">#{event_time.split(" ")[0]}</span> ~ <span class=\"end_date\">#{a.event_end_date.strftime('%Y-%m-%d')}</span>"
|
||||||
end
|
end
|
||||||
|
@ -532,7 +532,7 @@ class EventNewsController < ApplicationController
|
||||||
event_news = top_event_news + rest_event_news
|
event_news = top_event_news + rest_event_news
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
event_news.each{|a| a["postdate"] = a["postdate"].in_time_zone(Time.zone.utc_offset / 3600).strftime('%Y-%m-%d %H:%M') rescue nil }
|
event_news.each{|a| a["postdate"] = a["postdate"].in_time_zone(Time.zone.utc_offset / 3600).strftime((a['all_day'] ? '%Y-%m-%d' : '%Y-%m-%d %H:%M')) rescue nil }
|
||||||
event_news
|
event_news
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -623,7 +623,7 @@ class EventNewsController < ApplicationController
|
||||||
pause_btn_title = (I18n.locale.to_s =="zh_tw") ? "暫停播放" : "pause"
|
pause_btn_title = (I18n.locale.to_s =="zh_tw") ? "暫停播放" : "pause"
|
||||||
prev_btn_title = (I18n.locale.to_s =="zh_tw") ? "上一張" : "prev"
|
prev_btn_title = (I18n.locale.to_s =="zh_tw") ? "上一張" : "prev"
|
||||||
next_btn_title = (I18n.locale.to_s =="zh_tw") ? "下一張" : "next"
|
next_btn_title = (I18n.locale.to_s =="zh_tw") ? "下一張" : "next"
|
||||||
event_time = (event_news.event_date.strftime('%Y-%m-%d %H:%M') rescue "")
|
event_time = (event_news.event_date.strftime(event_news.date_parse_format) rescue "")
|
||||||
if event_news.event_end_date
|
if event_news.event_end_date
|
||||||
event_time = "<span class=\"start_date\">#{event_time.split(" ")[0]}</span> ~ <span class=\"end_date\">#{event_news.event_end_date.strftime('%Y-%m-%d')}</span>"
|
event_time = "<span class=\"start_date\">#{event_time.split(" ")[0]}</span> ~ <span class=\"end_date\">#{event_news.event_end_date.strftime('%Y-%m-%d')}</span>"
|
||||||
end
|
end
|
||||||
|
@ -713,7 +713,7 @@ class EventNewsController < ApplicationController
|
||||||
|
|
||||||
event_date = DateTime.parse(event_news["event_date"].to_s) rescue nil
|
event_date = DateTime.parse(event_news["event_date"].to_s) rescue nil
|
||||||
event_end_date = DateTime.parse(event_news["event_end_date"].to_s) rescue nil
|
event_end_date = DateTime.parse(event_news["event_end_date"].to_s) rescue nil
|
||||||
event_time = (event_date.strftime('%Y-%m-%d %H:%M') rescue "")
|
event_time = (event_date.strftime(event_news.date_parse_format) rescue "")
|
||||||
if event_end_date
|
if event_end_date
|
||||||
event_time = "<span class=\"start_date\">#{event_time.split(" ")[0]}</span> ~ <span class=\"end_date\">#{event_end_date.strftime('%Y-%m-%d')}</span>"
|
event_time = "<span class=\"start_date\">#{event_time.split(" ")[0]}</span> ~ <span class=\"end_date\">#{event_end_date.strftime('%Y-%m-%d')}</span>"
|
||||||
end
|
end
|
||||||
|
@ -809,7 +809,7 @@ class EventNewsController < ApplicationController
|
||||||
target = a.is_external_link ? "_blank" : "_self"
|
target = a.is_external_link ? "_blank" : "_self"
|
||||||
doc = Nokogiri::HTML(a.title)
|
doc = Nokogiri::HTML(a.title)
|
||||||
title = doc.text.empty? ? 'no content' : doc.text
|
title = doc.text.empty? ? 'no content' : doc.text
|
||||||
event_time = (a.event_date.strftime('%Y-%m-%d %H:%M') rescue "")
|
event_time = (a.event_date.strftime(a.date_parse_format) rescue "")
|
||||||
if a.event_end_date
|
if a.event_end_date
|
||||||
event_time = "<span class=\"start_date\">#{event_time.split(" ")[0]}</span> ~ <span class=\"end_date\">#{a.event_end_date.strftime('%Y-%m-%d')}</span>"
|
event_time = "<span class=\"start_date\">#{event_time.split(" ")[0]}</span> ~ <span class=\"end_date\">#{a.event_end_date.strftime('%Y-%m-%d')}</span>"
|
||||||
end
|
end
|
||||||
|
|
|
@ -118,12 +118,13 @@ module EventNewsHelper
|
||||||
event_time_formated = a.event_time_formated
|
event_time_formated = a.event_time_formated
|
||||||
s = DateTime.parse(fa["event_date"]) rescue nil
|
s = DateTime.parse(fa["event_date"]) rescue nil
|
||||||
e = DateTime.parse(fa["event_end_date"]) rescue nil
|
e = DateTime.parse(fa["event_end_date"]) rescue nil
|
||||||
|
date_parse_format = fa["all_day"] ? '%Y-%m-%d' : '%Y-%m-%d %H:%M'
|
||||||
if s.blank? && e.blank?
|
if s.blank? && e.blank?
|
||||||
event_time_formated = ""
|
event_time_formated = ""
|
||||||
elsif s.blank?
|
elsif s.blank?
|
||||||
event_time_formated = s.strftime('%Y-%m-%d %H:%M')
|
event_time_formated = s.strftime(date_parse_format)
|
||||||
elsif e.blank?
|
elsif e.blank?
|
||||||
event_time_formated = "~ " + e.strftime('%Y-%m-%d %H:%M')
|
event_time_formated = "~ " + e.strftime(date_parse_format)
|
||||||
else
|
else
|
||||||
if s.to_date == e.to_date
|
if s.to_date == e.to_date
|
||||||
date_str = s.strftime('%Y-%m-%d')
|
date_str = s.strftime('%Y-%m-%d')
|
||||||
|
@ -131,7 +132,7 @@ module EventNewsHelper
|
||||||
e_time = e.strftime('%H:%M')
|
e_time = e.strftime('%H:%M')
|
||||||
event_time_formated = "#{date_str} #{s_time} ~ #{e_time}"
|
event_time_formated = "#{date_str} #{s_time} ~ #{e_time}"
|
||||||
else
|
else
|
||||||
event_time_formated = s.strftime('%Y-%m-%d %H:%M') + " ~ " + e.strftime('%Y-%m-%d %H:%M')
|
event_time_formated = s.strftime(date_parse_format) + " ~ " + e.strftime(date_parse_format)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
x = {
|
x = {
|
||||||
|
|
|
@ -34,6 +34,7 @@ class EventNews
|
||||||
field :calendar_start_date, :type => DateTime
|
field :calendar_start_date, :type => DateTime
|
||||||
field :calendar_end_date, :type => DateTime
|
field :calendar_end_date, :type => DateTime
|
||||||
field :calendar_all_day,type: Boolean,default: false
|
field :calendar_all_day,type: Boolean,default: false
|
||||||
|
field :all_day,type: Boolean,default: false
|
||||||
field :calendar_type_id
|
field :calendar_type_id
|
||||||
field :event_id
|
field :event_id
|
||||||
field :place, type: String, localize: true
|
field :place, type: String, localize: true
|
||||||
|
@ -104,15 +105,19 @@ class EventNews
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def date_parse_format
|
||||||
|
all_day ? '%Y-%m-%d' : '%Y-%m-%d %H:%M'
|
||||||
|
end
|
||||||
|
|
||||||
def event_time_formated
|
def event_time_formated
|
||||||
s = self.event_date
|
s = self.event_date
|
||||||
e = self.event_end_date
|
e = self.event_end_date
|
||||||
if s.blank? && e.blank?
|
if s.blank? && e.blank?
|
||||||
""
|
""
|
||||||
elsif e.blank?
|
elsif e.blank?
|
||||||
s.strftime('%Y-%m-%d %H:%M')
|
s.strftime(self.date_parse_format)
|
||||||
elsif s.blank?
|
elsif s.blank?
|
||||||
"~ " + e.strftime('%Y-%m-%d %H:%M')
|
"~ " + e.strftime(self.date_parse_format)
|
||||||
else
|
else
|
||||||
if s.to_date == e.to_date
|
if s.to_date == e.to_date
|
||||||
date_str = s.strftime('%Y-%m-%d')
|
date_str = s.strftime('%Y-%m-%d')
|
||||||
|
@ -120,7 +125,7 @@ class EventNews
|
||||||
e_time = e.strftime('%H:%M')
|
e_time = e.strftime('%H:%M')
|
||||||
"#{date_str} #{s_time} ~ #{e_time}"
|
"#{date_str} #{s_time} ~ #{e_time}"
|
||||||
else
|
else
|
||||||
s.strftime('%Y-%m-%d %H:%M') + " ~ " + e.strftime('%Y-%m-%d %H:%M')
|
s.strftime(self.date_parse_format) + " ~ " + e.strftime(self.date_parse_format)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -76,6 +76,12 @@
|
||||||
<%= f.datetime_picker :event_end_date, :no_label => true, :new_record => @event_news.new_record?, :data=>{"picker-type" => "range", "range" => "start"} %>
|
<%= f.datetime_picker :event_end_date, :no_label => true, :new_record => @event_news.new_record?, :data=>{"picker-type" => "range", "range" => "start"} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted"><%= t("event_news.all_day") %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.check_box :all_day %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted"><%= t("event_news.start_date") %></label>
|
<label class="control-label muted"><%= t("event_news.start_date") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
|
|
@ -2,6 +2,7 @@ en:
|
||||||
module_name:
|
module_name:
|
||||||
event_news: Event News
|
event_news: Event News
|
||||||
event_news:
|
event_news:
|
||||||
|
all_day: All Day
|
||||||
show_today_data_first: Show today data first
|
show_today_data_first: Show today data first
|
||||||
custom_fields_title: Custom Fields Title
|
custom_fields_title: Custom Fields Title
|
||||||
custom_carousel_image_width_hint: "If blank, width will be default value."
|
custom_carousel_image_width_hint: "If blank, width will be default value."
|
||||||
|
|
|
@ -2,6 +2,7 @@ zh_tw:
|
||||||
module_name:
|
module_name:
|
||||||
event_news: 活動公告
|
event_news: 活動公告
|
||||||
event_news:
|
event_news:
|
||||||
|
all_day: 全天
|
||||||
show_today_data_first: 優先顯示當日資料
|
show_today_data_first: 優先顯示當日資料
|
||||||
custom_fields_title: 欄位名稱設定
|
custom_fields_title: 欄位名稱設定
|
||||||
custom_carousel_image_width_hint: "未填寫,則使用預設寬度"
|
custom_carousel_image_width_hint: "未填寫,則使用預設寬度"
|
||||||
|
|
Loading…
Reference in New Issue