e_paper/app/views/admin/e_papers/_index.html.erb

74 lines
2.6 KiB
Plaintext

<table class="table main-list">
<thead>
<tr class="sort-header">
<% @table_fields.each do |f| %>
<%= thead(f) %>
<% end %>
</tr>
</thead>
<tbody>
<% user_has_rights = (current_user.is_admin? ? true : (current_user.is_manager?(@module_app) ? true : current_user.is_manager_with_role?(@module_app) ? true : false)) rescue false %>
<% @papers.each do |paper| %>
<tr>
<td>
<%= paper.category.title rescue "" %>
<% if (paper.category.disable rescue false) %>
<span class="label"><%= t(:disable) %></span>
<% end %>
</td>
<td>
<%= paper.title %>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(paper) %>
<li><a href="<%= admin_e_paper_path(paper.id) %>"><%= t('e_paper.add') %></a></li>
<% end %>
<% if user_has_rights %>
<li><a href="<%= edit_admin_e_paper_path(paper.id) %>"><%= t(:edit) %></a></li>
<li><a href="<%= admin_e_paper_path(paper.id) %>" data-method="delete" data-confirm="Are you sure?"><%= t(:delete_) %></a></li>
<% if paper.ready_to_send %>
<li><span class="label"><%= t('e_paper.sending') %></span></li>
<% elsif !paper.ready_to_send && paper.mailed %>
<li><span class="label"><%= t('e_paper.published') %></span></li>
<% else %>
<li><a href="<%= send_email_to_subscribers_admin_e_paper_path(paper.id) %>"><%= t('e_paper.send') %></a></li>
<li><a href="<%= send_test_email_admin_e_paper_path(paper.id) %>" class="test-email"><%= t('e_paper.test_mail') %></a></li>
<% end %>
<% end %>
</ul>
</div>
</td>
<td>
<%= paper.period.strftime("%Y-%m-%d") rescue "" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<div class="bottomnav clearfix" style="left: 81px;">
<%= content_tag :div, paginate(@papers), class: "pagination pagination-centered" %>
<% if user_has_rights %>
<div class="action pull-right">
<a class="btn btn-primary" href="<%= new_admin_e_paper_path %>">
<%= t("e_paper.new_paper") %>
</a>
</div>
<% end %>
</div>
<script type="text/javascript">
$(".test-email").on("click",function(){
var el = $(this),
email = prompt("Please enter an email address to send test email.", "<%= current_user.member_profile.email rescue "" %>");
if(email != null){
$.ajax({
url : el.attr("href"),
data : {"email" : email},
dataType : "json",
type : "get"
}).done(function(){
alert("Email sent.")
})
}
return false;
})
</script>