fix get enable_manually_sort nil error

This commit is contained in:
chiu 2024-10-17 03:02:40 +00:00
parent e328e1eb12
commit 6e2a4ac3e9
1 changed files with 38 additions and 35 deletions

View File

@ -1,4 +1,6 @@
module EventNewsHelper
extend self
def data_to_human_type(a,set_tag_ids=nil)
statuses = a.statuses_with_classname.collect do |status|
{
@ -88,7 +90,7 @@ module EventNewsHelper
sort_maps = {event_date: :asc, is_top: :desc, postdate: :asc, id: :asc}
else
sort_maps = {is_top: :desc}
if EventNewsHelper.is_postdate_sort_first
if is_postdate_sort_first
sort_maps = sort_maps.merge({postdate: :desc, event_date: :desc, id: :desc})
else
sort_maps = sort_maps.merge({event_date: :desc, postdate: :desc, id: :desc})
@ -234,8 +236,7 @@ module EventNewsHelper
end
def sort_event_news(event_news_list)
enable_manually_sort = enable_manually_sort
if @show_today_data_first || !EventNewsHelper.is_postdate_sort_first
if @show_today_data_first || !is_postdate_sort_first
if enable_manually_sort
event_news_list = event_news_list.sort_by { |event_news|
tmp1 = event_news["event_date"].blank?
@ -551,7 +552,7 @@ module EventNewsHelper
</div>
</div>").html_safe
end
class << self
def complementaryColor(my_hex)
if my_hex[0] == '#'
my_hex = my_hex[1..-1]
@ -560,6 +561,7 @@ module EventNewsHelper
comp = rgb.map{|a| (255 - a.to_i(16)).to_s(16).rjust(2,'0')}
'#'+comp.join
end
def lighten_color(my_hex,percent)
if my_hex[0] == '#'
my_hex = my_hex[1..-1]
@ -573,6 +575,7 @@ module EventNewsHelper
end
'#'+comp.join
end
def enable_manually_sort
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
OrbitHelper::SharedHash['event_news_mod'][:enable_manually_sort]
@ -580,6 +583,7 @@ module EventNewsHelper
EventNewsSetting.first.enable_manually_sort rescue false
end
end
def is_postdate_sort_first
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
OrbitHelper::SharedHash['event_news_mod'][:is_postdate_sort_first]
@ -588,4 +592,3 @@ module EventNewsHelper
end
end
end
end