fix error for sort announcements because of get nil by call enable_manually_sort

This commit is contained in:
chiu 2024-10-17 02:52:13 +00:00
parent 4043dfed5c
commit b3dbabef5b
1 changed files with 28 additions and 26 deletions

View File

@ -1,4 +1,6 @@
module AnnouncementsHelper
extend self
def data_to_human_type(a,set_tag_ids=nil,tmp_enable_annc_dept=false,annc_depts=[])
tmp_enable_annc_dept = @tmp_enable_annc_dept if @tmp_enable_annc_dept
annc_depts = @annc_depts if @annc_depts
@ -464,34 +466,34 @@ module AnnouncementsHelper
</div>").html_safe
end
class << self
def complementaryColor(my_hex)
if my_hex[0] == '#'
my_hex = my_hex[1..-1]
end
rgb = my_hex.split(//).each_slice(my_hex.length/3).map{|v| v.join}
comp = rgb.map{|a| (255 - a.to_i(16)).to_s(16).rjust(2,'0')}
'#'+comp.join
def complementaryColor(my_hex)
if my_hex[0] == '#'
my_hex = my_hex[1..-1]
end
def lighten_color(my_hex,percent)
if my_hex[0] == '#'
my_hex = my_hex[1..-1]
end
rgb = my_hex.split(//).each_slice(my_hex.length/3).map{|v| v.join}
comp = rgb.collect do |a|
tmp = a.to_i(16)*(1+percent/100.0)
tmp = 255 if tmp>255
tmp = 0 if tmp < 0
tmp.to_i.to_s(16).rjust(2,'0')
end
'#'+comp.join
rgb = my_hex.split(//).each_slice(my_hex.length/3).map{|v| v.join}
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]
end
def enable_manually_sort
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
OrbitHelper::SharedHash['announcement'][:enable_manually_sort]
else
AnnouncementSetting.first.enable_manually_sort rescue false
end
rgb = my_hex.split(//).each_slice(my_hex.length/3).map{|v| v.join}
comp = rgb.collect do |a|
tmp = a.to_i(16)*(1+percent/100.0)
tmp = 255 if tmp>255
tmp = 0 if tmp < 0
tmp.to_i.to_s(16).rjust(2,'0')
end
'#'+comp.join
end
def enable_manually_sort
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
OrbitHelper::SharedHash['announcement'][:enable_manually_sort]
else
AnnouncementSetting.first.enable_manually_sort rescue false
end
end
end