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,34 +412,34 @@ class AnnouncementsController < ApplicationController
@show_options = modile_app.show_options rescue nil @show_options = modile_app.show_options rescue nil
end end
subpart.select_options.each do |select_option| 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) value = YAML.load(select_option.value)
tmp = value[:en] tmp = value[:en]
I18n.with_locale(:en) do I18n.with_locale(:en) do
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
when @show_options.keys[1].to_s
tab_options.each_with_index do |option,i| tab_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}") if tmp == t("announcement.#{option}")
@tab_option = i @tab_option = i
break break
end end
end end
end when @show_options.keys[2].to_s
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| read_more_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}") if tmp == t("announcement.#{option}")
@read_more_option = i @read_more_option = i
break break
end end
end end
end when @show_options.keys[3].to_s
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| all_setting_options.each_with_index do |option,i|
if tmp == t("announcement.#{option}") if tmp == t("announcement.#{option}")
@all_setting_option = i @all_setting_option = i
@ -451,6 +451,7 @@ class AnnouncementsController < ApplicationController
end end
end end
end end
end
def get_anncs_for_pack_data(cats,tags,set_tags=nil,is_random = false) def get_anncs_for_pack_data(cats,tags,set_tags=nil,is_random = false)
if tags.blank? if tags.blank?
tags = ["all"] tags = ["all"]
@ -458,7 +459,6 @@ class AnnouncementsController < ApplicationController
subpart = OrbitHelper.get_current_widget subpart = OrbitHelper.get_current_widget
widget_data_count = OrbitHelper.widget_data_count 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) 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?) devide_flag = (!(defined? SiteFeed).nil?)
anns_cache.where(:invalid_date.lte => Time.now).destroy anns_cache.where(:invalid_date.lte => Time.now).destroy
count = anns_cache.count count = anns_cache.count

View File

@ -20,30 +20,6 @@ module AnnouncementsHelper
end end
'#'+comp.join '#'+comp.join
end 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) def data_to_human_type(a,set_tag_ids=nil)
statuses = a.statuses_with_classname.collect do |status| statuses = a.statuses_with_classname.collect do |status|
{ {