merger select options for widget

This commit is contained in:
chiu 2021-09-17 17:23:32 +08:00
parent 25be05e5d1
commit 7b4f271fcc
2 changed files with 28 additions and 52 deletions

View File

@ -412,38 +412,39 @@ class AnnouncementsController < ApplicationController
@show_options = modile_app.show_options rescue nil
end
subpart.select_options.each do |select_option|
if !(@show_options.nil?) && select_option.field_name == @show_options.keys[1].to_s
if !(@show_options.nil?)
value = YAML.load(select_option.value)
tmp = value[:en]
I18n.with_locale(:en) do
tab_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}")
@tab_option = i
break
case select_option.field_name
when @show_options.keys[0].to_s
if tmp == t('announcement.small_size')
@image_version = 'thumb'
elsif tmp == t('announcement.medium_size')
@image_version = 'mobile'
elsif tmp == t('announcement.orignal_size')
@image_version = 'orignal'
end
end
end
end
if !(@show_options.nil?) && select_option.field_name == @show_options.keys[2].to_s
value = YAML.load(select_option.value)
tmp = value[:en]
I18n.with_locale(:en) do
read_more_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}")
@read_more_option = i
break
when @show_options.keys[1].to_s
tab_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}")
@tab_option = i
break
end
end
end
end
end
if !(@show_options.nil?) && select_option.field_name == @show_options.keys[3].to_s
value = YAML.load(select_option.value)
tmp = value[:en]
I18n.with_locale(:en) do
all_setting_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}")
@all_setting_option = i
break
when @show_options.keys[2].to_s
read_more_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}")
@read_more_option = i
break
end
end
when @show_options.keys[3].to_s
all_setting_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}")
@all_setting_option = i
break
end
end
end
end
@ -458,7 +459,6 @@ class AnnouncementsController < ApplicationController
subpart = OrbitHelper.get_current_widget
widget_data_count = OrbitHelper.widget_data_count
anns_cache = AnnsCache.where(parent_id: subpart.id.to_s + cats.to_s + tags.to_s + widget_data_count.to_s,locale: I18n.locale.to_s)
set_image_version_for_widget()
devide_flag = (!(defined? SiteFeed).nil?)
anns_cache.where(:invalid_date.lte => Time.now).destroy
count = anns_cache.count

View File

@ -20,30 +20,6 @@ module AnnouncementsHelper
end
'#'+comp.join
end
def set_image_version_for_widget
subpart = OrbitHelper.get_current_widget
@image_version = 'thumb'
if subpart.methods.include? 'select_options'.to_sym
ModuleApp.all.select{|tmp| tmp.key.to_s=='announcement'}.each do |modile_app|
@show_options = modile_app.show_options rescue nil
end
subpart.select_options.each do |select_option|
if !(@show_options.nil?) && select_option.field_name == @show_options.keys.first.to_s
value = YAML.load(select_option.value)
tmp = value[:en]
I18n.with_locale(:en) do
if tmp == t('announcement.small_size')
@image_version = 'thumb'
elsif tmp == t('announcement.medium_size')
@image_version = 'mobile'
elsif tmp == t('announcement.orignal_size')
@image_version = 'orignal'
end
end
end
end
end
end
def data_to_human_type(a,set_tag_ids=nil)
statuses = a.statuses_with_classname.collect do |status|
{