2014-05-01 08:41:00 +00:00
|
|
|
<% content_for :right_nav do %>
|
|
|
|
<ul class="nav nav-pills filter-nav pull-right">
|
|
|
|
<% @filter_fields.keys.each do |field| %>
|
|
|
|
<li class="accordion-group">
|
|
|
|
<div class="accordion-heading">
|
|
|
|
<a href="#collapse-<%= field %>" data-toggle="collapse" data-parent="#filter" class="accordion-toggle"><%= t(field) %></a>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<% end %>
|
|
|
|
</ul>
|
|
|
|
<div class="filter-group accordion-group">
|
|
|
|
<% @filter_fields.keys.each do |field| %>
|
|
|
|
<div class="accordion-body collapse" id="collapse-<%= field %>">
|
|
|
|
<div class="accordion-inner pagination-right" data-toggle="buttons-checkbox">
|
|
|
|
<% @filter_fields[field].each do |val| %>
|
2014-05-02 10:21:51 +00:00
|
|
|
<%= link_to t(val[:title]), "#", :onclick => "addFilter('filters[#{field}][]=#{val[:id]}')", :class => "btn btn-small #{is_filter_active?(field, val[:id])}" %>
|
2014-05-01 08:41:00 +00:00
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
<div class="filter-clear">
|
|
|
|
<a href="" class="btn btn-link btn-small"><i class="icons-cycle"></i> <%= t(:clear) %></a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
|
2014-05-02 10:21:51 +00:00
|
|
|
<span id="index_table">
|
|
|
|
</span>
|
2014-05-01 08:41:00 +00:00
|
|
|
|
2014-05-02 04:09:44 +00:00
|
|
|
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
|
2014-05-02 10:21:51 +00:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
filters=[];
|
|
|
|
table_url="";
|
|
|
|
|
|
|
|
$(function(){
|
|
|
|
init();
|
|
|
|
update_table();
|
|
|
|
});
|
|
|
|
|
|
|
|
var init = function(){
|
|
|
|
filters = window.location.search.replace('?','').split('&');
|
|
|
|
table_url = "";
|
|
|
|
if(window.location.search==""){
|
|
|
|
filters = [];
|
|
|
|
table_url = window.location.pathname+'/index_table';
|
|
|
|
}else{
|
|
|
|
table_url = window.location.pathname+'/index_table';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var update_table = function(url){
|
|
|
|
if(url==null){
|
|
|
|
if(filters.length==0){
|
|
|
|
url = table_url;
|
|
|
|
}else{
|
|
|
|
url = table_url+'?'+filters.join('&');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$.get(url,function(data){
|
|
|
|
history.pushState(null, null, decodeURIComponent(url.replace('/index_table','')) );
|
|
|
|
init();
|
|
|
|
$("#index_table").html(data);
|
|
|
|
|
|
|
|
$(".pagination a").click(function(){
|
|
|
|
update_table($(this).attr('href'));
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var addFilter = function(filter){
|
|
|
|
url = "";
|
|
|
|
$.each(filters,function(idx,data){
|
|
|
|
if(data.indexOf("page=")>-1) filters.splice(idx,1);
|
|
|
|
});
|
|
|
|
|
|
|
|
if( (index = filters.indexOf(filter) ) > -1){
|
|
|
|
table_url = table_url.replace(filter,'');
|
|
|
|
filters.splice(index,1);
|
|
|
|
}else{
|
|
|
|
filters.push(filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
update_table();
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
</script>
|