diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index f6a953c..246144c 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -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 diff --git a/app/helpers/announcements_helper.rb b/app/helpers/announcements_helper.rb index 9b9e3e9..51e7661 100644 --- a/app/helpers/announcements_helper.rb +++ b/app/helpers/announcements_helper.rb @@ -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| {