Put sorting in web_link, page_context and design
This commit is contained in:
1 parent
b48099d752
commit
f190ce18ee
23 files changed
+130
-259
No files matched your search
@@ -1,4 +1,4 @@
|
||||
class Admin::DesignsController < ApplicationController
|
||||
class Admin::DesignsController < OrbitBackendController
|
||||
require "net/http"
|
||||
require "uri"
|
||||
require 'zip/zip'
|
||||
@@ -25,7 +25,7 @@ class Admin::DesignsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@designs = Design.all.entries
|
||||
@designs = params[:sort] ? get_sorted_and_filtered("designs") : Design.all
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -84,6 +84,13 @@ class Admin::DesignsController < ApplicationController
|
||||
render :action => 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def delete
|
||||
if params[:to_delete]
|
||||
designs = Design.any_in(:_id => params[:to_delete]).delete_all
|
||||
end
|
||||
redirect_to admin_designs_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
|
||||
@@ -27,9 +27,13 @@ class OrbitBackendController< ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def get_sorted_and_filtered(object_class)
|
||||
def get_sorted_and_filtered(object_class, query=nil)
|
||||
object_class = object_class.classify.constantize
|
||||
objects = object_class.all
|
||||
if query
|
||||
objects = object_class.all.where(query)
|
||||
else
|
||||
objects = object_class.all
|
||||
end
|
||||
|
||||
if !params[:sort].blank?
|
||||
options = params[:sort_options]
|
||||
|
||||
@@ -27,7 +27,7 @@ module OrbitBackendHelper
|
||||
concat (content_tag :th, :class => "span1 strong" do
|
||||
concat check_box_tag :check_all
|
||||
concat link_to content_tag(:i, nil, :class => "icon-trash"), '#', :class => "list-remove"
|
||||
end) if delete_all && is_manager?
|
||||
end) if (delete_all && (is_admin? || (is_manager? rescue nil)))
|
||||
titles.each do |title|
|
||||
concat render_title(title[0], title[1], title[2], title[3])
|
||||
end
|
||||
|
||||
@@ -3,10 +3,10 @@ class Design
|
||||
include Mongoid::Timestamps
|
||||
include ParserLayout
|
||||
|
||||
field :title
|
||||
field :author
|
||||
field :intro
|
||||
field :version
|
||||
field :title, :type => String
|
||||
field :author, :type => String
|
||||
field :intro, :type => String
|
||||
field :version, :type => String
|
||||
|
||||
has_many :pages
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<tr class="with_action">
|
||||
<td><%= check_box_tag 'to_delete[]', design.id, false, :class => "checkbox_in_list" %></td>
|
||||
<td>
|
||||
<%= design.title %>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills hide">
|
||||
<li><%= link_to t(:edit), edit_admin_design_path(design), :class => 'edit' %></li>
|
||||
<li class="dropdown"><%= link_to t(:delete), admin_design_path(design), :confirm => t('sure?'), :method => :delete, :class => 'delete' %></li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<td><%= design.author %></td>
|
||||
<td><%= design.intro %></td>
|
||||
</tr>
|
||||
@@ -0,0 +1,12 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span1 strong"></th>
|
||||
<th class="span7"></th>
|
||||
<th class="span2"></th>
|
||||
<th class="span2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody id="tbody_designs" class="sort-holder">
|
||||
<%= render :partial => 'design', :collection => @designs %>
|
||||
</tbody>
|
||||
@@ -0,0 +1,11 @@
|
||||
<div id='filter' class="subnav">
|
||||
<div class="filters">
|
||||
<div id="sort_headers" class="table-label">
|
||||
<%= render 'sort_headers' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "sort_header" %>
|
||||
<% end %>
|
||||
@@ -0,0 +1,3 @@
|
||||
<%= render_sort_bar(true, ['title', 'title','span7', 'admin.title'],
|
||||
['author', 'author', 'span2', 'admin.author'],
|
||||
['intro', 'intro', 'span2', 'admin.intro']).html_safe %>
|
||||
@@ -1,52 +1,10 @@
|
||||
<%= flash_messages %>
|
||||
<div id="filter" class="subnav">
|
||||
<div class="filters">
|
||||
<div id="sort_headers" class="table-label">
|
||||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span1 strong">
|
||||
<input type="checkbox">
|
||||
<a href class="list-remove"><i class="icon-trash"></i></a>
|
||||
</th>
|
||||
<th class="span7"><%= t('admin.title') %></th>
|
||||
<th class="span2"><%= t('admin.author') %></th>
|
||||
<th class="span2"><%= t('admin.intro') %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%= form_for :news_bulletins, :url => delete_admin_designs_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]), :html => {:id => 'delete_all'}, :remote => true do %>
|
||||
<%= render 'filter' %>
|
||||
<table class="table main-list">
|
||||
<%= render 'designs' %>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span1 strong"></th>
|
||||
<th class="span7"></th>
|
||||
<th class="span2"></th>
|
||||
<th class="span2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @designs.each do |design| %>
|
||||
<tr class="with_action">
|
||||
<td><input type="checkbox"></td>
|
||||
<td>
|
||||
<%= design.title %>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills hide">
|
||||
<li><%= link_to t(:edit), edit_admin_design_path(design), :class => 'edit' %></li>
|
||||
<li class="dropdown"><%= link_to t(:delete), admin_design_path(design), :confirm => t('sure?'), :method => :delete, :class => 'delete' %></li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<td><%= design.author %></td>
|
||||
<td><%= design.intro %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="form-actions form-fixed pagination-right">
|
||||
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_admin_design_path, :class => 'btn btn-primary' %>
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
$("#delete_all").attr("action", "<%= delete_admin_designs_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) %>");
|
||||
$("#sort_headers").html("<%= j render 'sort_headers' %>");
|
||||
$("#tbody_designs").html("<%= j render :partial => 'design', :collection => @designs %>");
|
||||
Reference in new issue
Block a user