added hidden and show
This commit is contained in:
1 parent
e6c7b932aa
commit
5af9cfe9e2
7 files changed
+61
-9
No files matched your search
@@ -1,6 +1,11 @@
|
||||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "universal_table/universal-table" %>
|
||||
<% end %>
|
||||
<style>
|
||||
.hidden_entry{
|
||||
background-color: grey;
|
||||
}
|
||||
</style>
|
||||
<form class="form-search" action="<%= admin_universal_table_path(@table) %>" method="get">
|
||||
<input type="text" name="q" class="input-large search-query" placeholder="Search from text or editor columns">
|
||||
<button type="submit" class="btn btn-primary">Search</button>
|
||||
@@ -13,6 +18,13 @@
|
||||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr class="sort-header">
|
||||
<th width="15">
|
||||
<%= t(:status) %>
|
||||
<div class="status hide" id="entry-status">
|
||||
<a href="" class="toggle_entries" data-status="hide"><%= t(:hide) %></a>
|
||||
<a href="" class="toggle_entries" data-status="show"><%= t(:show) %></a>
|
||||
</div>
|
||||
</th>
|
||||
<% @table_fields.each do |field| %>
|
||||
<%
|
||||
sort = field.to_s.include?('.') ? field.to_s.split('.')[1] : field.to_s
|
||||
@@ -29,7 +41,8 @@
|
||||
<tbody>
|
||||
<% can_edit = can_edit_or_delete?(@table) %>
|
||||
<% @entries.each do |entry| %>
|
||||
<tr>
|
||||
<tr id="tr_entry_<%= entry.id.to_s %>" class="<%= entry.is_hidden? ? 'hidden_entry' : '' %>">
|
||||
<td><input class="hide-toggle" type="checkbox" value="<%= entry.id.to_s %>" /></td>
|
||||
<% @columns.each_with_index do |column, index| %>
|
||||
<% ce = entry.column_entries.where(:table_column_id => column.id).first rescue nil %>
|
||||
<td>
|
||||
@@ -123,4 +136,31 @@ $(".voice-player").on("click", function(){
|
||||
}
|
||||
return false;
|
||||
})
|
||||
$(".hide-toggle").on("click", function(){
|
||||
var count = $(".hide-toggle:checked").length;
|
||||
if(count > 0){
|
||||
$("#entry-status").removeClass("hide")
|
||||
}else{
|
||||
$("#entry-status").addClass("hide")
|
||||
}
|
||||
})
|
||||
$(".toggle_entries").on("click", function(){
|
||||
let checkedValues = $('.hide-toggle:checked').map(function() {
|
||||
return $(this).val();
|
||||
}).get();
|
||||
let status = $(this).data("status");
|
||||
$.ajax({
|
||||
url: "/admin/universal_tables/toggle_entries",
|
||||
method: "post",
|
||||
data: {"ids": checkedValues, "status": status},
|
||||
type: "json"
|
||||
}).done(function(){
|
||||
if(status == "hide"){
|
||||
$('.hide-toggle:checked').parents("tr").addClass("hidden_entry");
|
||||
}else{
|
||||
$('.hide-toggle:checked').parents("tr").removeClass("hidden_entry");
|
||||
}
|
||||
})
|
||||
return false;
|
||||
})
|
||||
</script>
|
||||
Reference in new issue
Block a user