announcement-test/app/views/announcements/index.html.erb

62 lines
2.1 KiB
Plaintext

<% params = OrbitHelper.params
page = Page.where(url:params['url']).first
enable_search_flag = false
if page.methods.include? 'select_option_items'.to_sym
ModuleApp.all.select{|tmp| tmp.key.to_s=='announcement'}.each do |modile_app|
@show_option_items = modile_app.show_option_items rescue nil
end
page.select_option_items.each do |select_option_item|
if !(@show_option_items.nil?) && select_option_item.field_name == @show_option_items.keys[1].to_s
value = YAML.load(select_option_item.value)
if value[I18n.locale] == t('announcement.yes')
enable_search_flag = true
end
end
end
end
%>
<% if enable_search_flag %>
<style type="text/css">
#category_select_box{
margin: 0;
background: linear-gradient(0deg, #515fff, #ff3e3e);
color: white;
outline: 0;
border-radius: 0.9em;
}
#category_select_box>option{
background: #5640dd;
}
input.search_box{
margin: 0;
background: #a2c3df;
color: #9100ff;
border-radius: 0.7em;
outline: 0;
}
input.search_box[type='submit']:hover{
background: #9100ff;
color: white;
}
input.search_box[type='submit']:active{
background: #7201ff;
color: white;
}
</style>
<form>
<% cats = Array(page.categories)
if cats.include? 'all'
cats = ModuleApp.where(key: 'announcement').first.categories
else
cats = cats.map{|v| Category.where(id: v).first}.compact
end
all_cat = [[t('announcement.all'),'all']]
%>
<div class="search_widget" style="font-size: 1.2em;">
<%= select_tag('category',options_for_select(all_cat.concat(cats.map{|v| [v.title,v.id.to_s]}),:selected => params['category'].to_s),:id=>"category_select_box",:prompt => t('announcement.select_prompt')) %>
<input class="search_box" type="text" name="keywords" value="<%= params['keywords'] %>" placeholder="<%= t('announcement.keywords') %>">
<input class="search_box" type="submit" value="<%= t('announcement.search') %>">
</div>
</form>
<% end %>
<%= render_view %>