Initial changes in announcement for sorting and filtering

This commit is contained in:
Christophe Vilayphiou 2012-02-22 13:44:01 +08:00
parent 22d9741ac8
commit 53ed4b0404
9 changed files with 530 additions and 142 deletions

View File

@ -56,4 +56,32 @@ module ApplicationHelper
end
end
def active_for_controllers(*controller_names)
controller_names.include?(controller.controller_name) ? 'active' : nil
end
def visible_for_controllers(*controller_names)
controller_names.include?(controller.controller_name) ? '' : 'hide'
end
def active_for_action(controller_name, action_name)
(controller.controller_name.eql?(controller_name) && controller.action_name.eql?(action_name)) ? 'active' : nil
end
def sortable(column)
direction = (column == params[:sort] && params[:direction] == "asc") ? "desc" : "asc"
{:sort => column, :direction => direction}
end
def add_filter(param_name, value)
filter = params[:filter] rescue nil
if filter && filter.has_key(param_name)
filter[param_name] << value
elsif filter
filter.merge({param_name => [value]})
else
{param_name => [value]}
end
end
end

View File

@ -15,7 +15,6 @@
</div>
<ul class="nav">
<li><%= link_to t(:homepage), root_path, :class => 'orbit-bar-home' %></li>
<li><a class="orbit-bar-desktop" href="#">Desktop</a></li>
</ul>
<ul class="nav pull-right">
<% if user_signed_in? %>
@ -26,6 +25,7 @@
<span class="member-name"><%= current_user.name %></span>
</a>
<ul class="dropdown-menu account-menu">
<li><a class="orbit-bar-desktop" href="#">Desktop</a></li>
<li>
<a href="#">
<i class="icons-wrench"></i>

View File

@ -1,15 +1,37 @@
<li><%= link_to content_tag(:i, nil, :class => 'icons-purchase') + t('admin.purchase'), admin_purchases_path %></li>
<li class="active">
<%= content_tag :li, :class => active_for_controllers('purchases') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-purchase') + t('admin.purchase'), admin_purchases_path %>
<% end -%>
<%= content_tag :li, :class => active_for_controllers('bulletins', 'tags', 'bulletin_categorys') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-announcement') + t('admin.announcement'), panel_announcement_back_end_bulletins_path %>
<ul class="nav nav-list">
<li class="active"><%= link_to t('admin.all_articles'), panel_announcement_back_end_bulletins_path %></li>
<li><%= link_to t('admin.add_new'), new_panel_announcement_back_end_bulletin_path %></li>
<li><%= link_to t('admin.categories'), panel_announcement_back_end_bulletin_categorys_path %></li>
<li><%= link_to t('admin.tags'), panel_announcement_back_end_tags_path %></li>
</ul>
</li>
<li><%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), admin_users_path %></li>
<li><%= link_to content_tag(:i, nil, :class => 'icons-page') + t('admin.page'), admin_items_path %></li>
<li><%= link_to content_tag(:i, nil, :class => 'icons-window-block') + t('admin.design'), admin_designs_path %></li>
<li><%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.link'), nil %></li>
<li><%= link_to content_tag(:i, nil, :class => 'icons-cog') + t('admin.site_settings'), nil %></li>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('bulletins', 'tags', 'bulletin_categorys')) do -%>
<%= content_tag :li, link_to(t('admin.all_articles'), panel_announcement_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %>
<%= content_tag :li, link_to(t('admin.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %>
<%= content_tag :li, link_to(t('admin.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %>
<%= content_tag :li, link_to(t('admin.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('tags', 'index') %>
<% end -%>
<% end -%>
<%= content_tag :li, :class => active_for_controllers('users') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), admin_users_path %>
<% end -%>
<%= content_tag :li, :class => active_for_controllers(nil) do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-page') + t('admin.page'), admin_pages_path %>
<%#= content_tag :ul, :class => "nav nav-list" do -%>
<%#= content_tag :li, link_to(t('admin.all_pages'), panel_page_content_back_end_bulletins_path), :class => active_for_action('bulletins', 'index') %>
<%#= content_tag :li, link_to(t('admin.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %>
<%# end -%>
<% end -%>
<%= content_tag :li, :class => active_for_controllers('designs') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-window-block') + t('admin.design'), admin_designs_path %>
<% end -%>
<%= content_tag :li, :class => active_for_controllers(nil) do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.link'), nil %>
<% end -%>
<%= content_tag :li, :class => active_for_controllers(nil) do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-cog') + t('admin.site_settings'), nil %>
<% end -%>

View File

@ -126,6 +126,7 @@ en:
non_multilingual: Non multilingual
options: Options
orig_upload_file: Original filename
page: Page
position: Position
published?: Published?
purchase: Purchase

View File

@ -12,7 +12,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController
# @bulletins = Bulletin.where("bulletin_category_id" => params[:bulletin_category_id]).desc("postdate") if params[:bulletin_category_id]
@bulletins = Bulletin.search(params[:search],params[:category_id])
@bulletins = Bulletin.search(params[:search], params[:category_id]).order_by([params[:sort], params[:direction]])
@bulletin_categories = BulletinCategory.all
module_app = ModuleApp.first(:conditions => {:key => 'announcement'})

View File

@ -28,8 +28,9 @@
</div>
<div class="accordion-body collapse" id="collapse-category">
<div class="accordion-inner" data-toggle="buttons-checkbox">
<a href="#" class="btn">Category1</a>
<a href="#" class="btn">Category2</a>
<% @bulletin_categories.each do |category| -%>
<%= link_to category.i18n_variable[I18n.locale], panel_announcement_back_end_bulletins_path(:filter => add_filter(:categories, category.id)), :class => 'btn' %>
<% end -%>
</div>
<div class="filter-clear">
<a href="#" class="btn"><i class="icons-brush-large"></i>Clear/重置</a>

View File

@ -1,11 +1,6 @@
<% # encoding: utf-8 %>
<%= f.error_messages %>
<div class="field">
<%= f.label :category %><br />
<%= f.select :bulletin_category_id, @bulletin_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]} %>
</div>
<!-- <%= f.error_messages %>
<div class="field">
<%= f.label :image, t('announcement.image') %><br />
@ -144,5 +139,392 @@
});
});
</script>
<% end %>
<% end %> -->
<!--Widget start-->
<div id="sub-wiget">
<div id="widget-date" class="widget-box">
<div class="widget-action clear">
<a href="#" class="action"><i title="Set the announcement to start and end dates" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-calendar icons-white"></i> Date</h3>
<div class="widget-content clear">
<div class="control-group">
<label class="control-label">Start</label>
<div class="controls">
<select id="start-day" class="input-small">
<option>Day</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
<select id="start-month" class="input-small">
<option>Month</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
<select id="start-year" class="input-small">
<option>Year</option>
<option>2012</option>
<option>2011</option>
<option>2010</option>
<option>2009</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label">End</label>
<div class="controls">
<select id="start-day" class="input-small">
<option>Day</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
<select id="start-month" class="input-small">
<option>Month</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
<select id="start-year" class="input-small">
<option>Year</option>
<option>2012</option>
<option>2011</option>
<option>2010</option>
<option>2009</option>
</select>
</div>
</div>
</div>
</div>
<div id="widget-status" class="widget-box">
<div class="widget-action clear">
<a class="action"><i title="Setting the announcement state" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-star-thin icons-white"></i>Status</h3>
<div class="widget-content clear">
<div class="controls">
<label class="checkbox inline"><input type="checkbox" value="hot">Hot</label>
<label class="checkbox inline"><input type="checkbox" value="top">Top</label>
<label class="checkbox inline"><input type="checkbox" value="hide">Hide</label>
</div>
</div>
</div>
<div id="widget-role" class="widget-box">
<div class="widget-action clear">
<a class="action"><i title="Set the read role" class="icon-exclamation-sign icon-white tip"></i></a>
<a class="action"><i title="Setting" class="icon-cog icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-lock icons-white"></i>Permissions</h3>
<div class="widget-content clear">
<div class="controls">
<label class="radio inline"><input class="privacy" type="radio" value="public" name="privacy">Public</label>
<label class="radio inline"><input class="privacy" type="radio" value="private" name="privacy">Private</label>
<div class="well select-role">
<label class="checkbox inline"><input type="checkbox" value="hot">Student</label>
<label class="checkbox inline"><input type="checkbox" value="top">Teacher</label>
<label class="checkbox inline"><input type="checkbox" value="hide">Staff</label>
</div>
</div>
</div>
</div>
<div id="widget-picture" class="widget-box">
<div class="widget-action clear">
<a class="action"><i title="Upload pictures" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-picture icons-white"></i>Picture</h3>
<div class="widget-content clear">
<div class="control-group">
<img class="pull-left upload-picture" src="images/default-img.png" />
<div class="controls file-upload">
<label class="control-label btn" for="input-upload">
Browse/選擇檔案
<input id="input-upload" class="upload" type="file" name="upload" onchange="document.getElementById('fu').innerHTML = this.form.fu.value = this.value;">
</label>
<span id='fu' class="file-name"></span>
<br>
<input name='fu' class="input-medium" type="text">
</div>
</div>
</div>
</div>
<div id="widget-tags" class="widget-box">
<div class="widget-action clear">
<a class="action"><i title="Enter post tags, Chinese and English required" class="icon-exclamation-sign icon-white tip"></i></a>
<a class="action"><i title="Setting" class="icon-cog icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-tag icons-white"></i>Tags</h3>
<div class="widget-content clear form-horizontal">
<div class="control-group error">
<label class="control-label" for="tags-zh-tw">
Chinese
</label>
<div class="controls">
<input id='tags-zh-tw' class="input-prepend" type="text">
<span class="help-inline">Please correct the error</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="tags-en">
English
</label>
<div class="controls">
<input id='tags-en' class="input-prepend" type="text">
<span class="help-inline">Please correct the error</span>
</div>
</div>
<div class="clear">
<a class="pull-right btn btn-primary" href="#">Add/新增</a>
</div>
<hr>
<span class="label label-tags">Default<a href><i class="icon-remove icon-white"></i></a></span>
<span class="label label-tags">Default<a href><i class="icon-remove icon-white"></i></a></span>
<span class="label label-tags">Default<a href><i class="icon-remove icon-white"></i></a></span>
<span class="label label-tags">Default<a href><i class="icon-remove icon-white"></i></a></span>
</div>
</div>
</div>
<!--Wiget End-->
<!--Post Start-->
<div id="post-body">
<div id="post-body-content" class="clear">
<%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %> <div class="btn-group pull-right">
<a class="btn dropdown-toggle" href="#" data-toggle="dropdown">
English
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">English</a></li>
<li><a href="#">Chinese</a></li>
<li><a href="#">Japanese</a></li>
<li><a href="#">French</a></li>
<li><a href="#">German</a></li>
<!--<li class="divider"></li>
<li><a href="#">Separated link</a></li>-->
</ul>
</div>
<div class="title">
<input class="post-title" type="text" placeholder="Enter title here">
</div>
<div class="editor">
<%= text_area_tag 'locale', nil, :style=>"width:100%" %>
</div>
<div class="main-wiget">
<div id="widget-link" class="widget-box">
<div class="widget-action clear">
<a class="action"><i title="Add a reference link" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-link icons-white"></i>Link</h3>
<div class="widget-content">
<table class="table table-condensed">
<thead>
<tr>
<th>Chinese</th>
<th>English</th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="3">
<a class="btn btn-primary btn-small" href="#modal-link" data-toggle="modal"><i class="icon-plus icon-white"></i> ADD/新增</a>
</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>…</td>
<td>…</td>
<td><a href="#modal-link" data-toggle="modal" class="action"><i class="icon-pencil"></i></a><a href class="action"><i class="icon-remove"></i></a></td>
</tr>
</tbody>
</table>
</div>
<div id="modal-link" class="modal hide fade">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Add Link / Edit Link</h3>
</div>
<div class="modal-body form-horizontal">
<div class="control-group">
<label for="http" class="control-label">http://</label>
<div class="controls">
<input type="text" value="" id="http" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
<div class="control-group error">
<label for="link-zh-tw" class="control-label">Chinese</label>
<div class="controls">
<input type="text" value="" id="link-zh-tw" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
<div class="control-group">
<label for="link-en" class="control-label">English</label>
<div class="controls">
<input type="text" value="" id="link-en" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-primary" href="#">Submit/確定</a>
<a class="btn" data-dismiss="modal" href="#">Cancel/取消</a>
</div>
</div>
</div>
<div id="widget-file" class="widget-box">
<div class="widget-action clear">
<a class="action"><i title="Added to the file" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-paperclip icons-white"></i>File</h3>
<div class="widget-content">
<table class="table table-condensed">
<thead>
<tr>
<th>Chinese</th>
<th>English</th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="3">
<a class="btn btn-primary btn-small" href="#modal-file" data-toggle="modal"><i class="icon-plus icon-white"></i> ADD/新增</a>
</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>…</td>
<td>…</td>
<td><a href="#modal-file" data-toggle="modal" class="action"><i class="icon-pencil"></i></a><a href class="action"><i class="icon-remove"></i></a></td>
</tr>
</tbody>
</table>
</div>
<div id="modal-file" class="modal hide fade">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Add File / Edit File</h3>
</div>
<div class="modal-body form-horizontal">
<div class="controls file-upload">
<label class="control-label btn" for="input-upload">
Browse
<input id="input-upload" class="upload" type="file" name="upload" onchange="document.getElementById('fn').innerHTML = this.value;">
</label>
<span id='fn' class="file-name"></span>
</div>
<div class="control-group">
<label for="file-zh-tw" class="control-label">Chinese</label>
<div class="controls">
<input type="text" value="" id="file-zh-tw" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
<div class="control-group">
<label for="file-en" class="control-label">English</label>
<div class="controls">
<input type="text" value="" id="file-en" class="input-xlarge">
<span class="help-inline">Please correct the error</span>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-primary" href="#">Submit/確定</a>
<a class="btn" data-dismiss="modal" href="#">Cancel/取消</a>
</div>
</div>
</div>
</div>
</div>
</div>
<!--Post End-->
<div class="form-actions">
<button class="btn btn-success" type="submit">Preview/預覽</button>
<button class="btn btn-primary" type="submit">Submit/送出</button>
<button class="btn" type="reset">Cancel/取消</button>
</div>

View File

@ -1,16 +1,7 @@
<br />
<br />
<br />
<br />
<h1><%= t('announcement.editing_announcement') %></h1>
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletin_path(@bulletin) do |f| %>
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletin_path(@bulletin), :html => {:class => 'clear'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%= link_back %>
<br />
<br />
<br />
<br />

View File

@ -1,48 +1,3 @@
<!-- <% content_for :secondary do %>
<br />
<br />
<br />
<br />
<br />
<ul class="list">
<li><%= link_to t('bulletin.new_announcement'), new_panel_announcement_back_end_bulletin_path %></li>
<li><%= link_to t('bulletin.announcement_list'), panel_announcement_back_end_bulletins_path %></li>
<li><%= link_to t('bulletin.new_announcement_class'), panel_announcement_back_end_bulletin_categorys_path %></li>
</ul>
<% end -%>
<%= flash_messages %>
<br />
<br />
<br />
<br />
<br />
<fieldset><legend><%= t('bulletin.search') %></legend>
<%= form_for :bulletin, :action => 'search', :method => 'get', :url => panel_announcement_back_end_bulletins_path do |f| %>
<%#= f.select :bulletin_category_id, @bulletin_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ] },{ :include_blank => t('bulletin.select') }%>
Category <%= select_tag "category_id", options_for_select(@bulletin_categorys.collect{|t| [t.i18n_variable[I18n.locale], t.id]}), :prompt => t('bulletin.select') %>
KeyWord <%= text_field_tag :search, params[:search], :id => 'search_field' %>
<%= submit_tag "Search", :name => nil %>
<% end %>
</fieldset>
<br />
<br />
<br />
-->
<%= render 'filter' %>
<table class="table main-list">
<thead>
@ -51,13 +6,21 @@
<input type="checkbox">
<a href class="list-remove"><i class="icon-trash"></i></a>
</th>
<th class="span1"><%= t('bulletin.status') %></th>
<th class="span1-2"><%= t('bulletin.category') %></th>
<th class="span7 select"><%= t('bulletin.title') %></th>
<th class="span1-2"><%= t('bulletin.start_date') %></th>
<th class="span1-2"><%= t('bulletin.end_date') %></th>
<th class="span1-2"><%= t('bulletin.tags') %></th>
<th class="span1-2"><%= t('bulletin.last_modified') %></th>
<th id="sort-status" class="sort span1">
<%= link_to (t('bulletin.status') + content_tag(:b, nil, :class => "web-symbol")), panel_announcement_back_end_bulletins_path(sortable('status')) %>
</th>
<th id="sort-status" class="sort span1-2">
<%= link_to (t('bulletin.category') + content_tag(:b, nil, :class => "web-symbol")), panel_announcement_back_end_bulletins_path(sortable('category')) %>
</th>
<%= link_to content_tag(:th, (t('bulletin.title') + content_tag(:b, nil, :class => "web-symbol")), :id => "sort-title", :class => "sort span7 select active"), panel_announcement_back_end_bulletins_path %>
<th id="sort-status" class="sort span1-2">
<%= link_to (t('bulletin.start_date') + content_tag(:b, nil, :class => "web-symbol")), panel_announcement_back_end_bulletins_path(sortable('start_date')) %>
</th>
<th id="sort-status" class="sort span1-2">
<%= link_to (t('bulletin.end_date') + content_tag(:b, nil, :class => "web-symbol")), panel_announcement_back_end_bulletins_path(sortable('end_date')) %>
</th>
<%= link_to content_tag(:th, (t('bulletin.tags') + content_tag(:b, nil, :class => "web-symbol")), :id => "sort-tags", :class => "sort span1-2"), panel_announcement_back_end_bulletins_path %>
<%= link_to content_tag(:th, (t('bulletin.last_modified') + content_tag(:b, nil, :class => "web-symbol")), :id => "sort-lastModified", :class => "sort span1-2"), panel_announcement_back_end_bulletins_path %>
</tr>
</thead>
<tbody>