ruling_timer/app/views/admin/ruling_timers/task_management.html.erb

130 lines
4.8 KiB
Plaintext

<style type="text/css">
.span20-percent{
width: 20%;
float: left;
text-align: center;
font-size: 1.5em;
margin: 0;
border: 2px solid #333333;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.span20-percent img{
width: 100%;
}
.status-tags > *{
font-weight: bold;
}
.task_name{
font-size: 1.5em;
}
.working_label{
color: #5a5a5a;
font-weight: bold;
}
.finish_label{
color: #3ec700;
font-weight: bold;
}
.stop_label{
color: #cd1643;
font-weight: bold;
}
</style>
<h3><%= t("ruling_timer.task") %></h3>
<table class="table main-list">
<thead>
<tr>
<th><%= t("ruling_timer.task_name") %></th>
<th><%= t("ruling_timer.task_performer") %></th>
<th><%=t("action")%></th>
</tr>
</thead>
<tbody>
<% @tasks.each_with_index do |task,i| %>
<tr>
<td class="task_name"><%=task.task_name%></td>
<td class="task_performer">
<% if task.user_ids %>
<% user_ids = task.user_ids
user_bson_ids = user_ids.map{|id| BSON::ObjectId(id)}
%>
<% users = User.find(user_ids).index_by(&:id).slice(*user_bson_ids).values %>
<% users.each do |user| %>
<% sub_task = task.ruling_timer_sub_tasks.where(:user=>user).first %>
<% klass = (sub_task.status == 'working' ? 'fa-play' : (sub_task.status == 'finish' ? 'fa-flag-checkered' : 'fa-pause') rescue 'fa-pause') %>
<span><%=user.name%>( <i class="fa <%=klass%> <%=sub_task.status%>_label"></i> <%=sub_task.get_infos["work"] rescue "00:00:00" %> )</span>
<br>
<% end %>
<% end %>
</td>
<td>
<a href="<%=view_task_admin_ruling_timer_path(:id=>task.id)%>" class="btn btn-primary"><%=t("view")%></a>
<a href="<%=edit_task_admin_ruling_timer_path(:id=>task.id)%>" class="btn btn-primary"><%=t("edit")%></a>
<a href="#" class="btn btn-danger delete_task" data-task="<%=task.task_name%>" data-task-id="<%=task.id.to_s%>"><%=t("ruling_timer.delete_task")%></a>
</td>
</tr>
<% end %>
</tbody>
</table>
<%=
content_tag :div, class: "bottomnav clearfix" do
content_tag(:div, paginate(@tasks), class: "pagination pagination-centered") +
content_tag(:div, link_to(t("ruling_timer.add_task"), add_task_admin_ruling_timers_path, :class=>"btn btn-primary"), class: "pull-right")
end %>
<script>
<% ["working","stop","finish"].each do |status| %>
$(".<%=status%>_label").attr("title",'<%=t("ruling_timer.#{status}")%>');
<% end %>
$('.delete_task').click(function(){
var item = $(this);
var item_row = $(this).parents("tr").eq(0);
var task_id = $(item).data("task-id")
if(window.confirm("<%=t("ruling_timer.delete_task_hint")%>")){
if(window.confirm("<%=t("ruling_timer.delete_task_hint")%>")){
if($("#dialog-confirm").length == 0){
$("#main-wrap").before("<div id='dialog-confirm' title='<%=t("ruling_timer.delete_task")%>'>"+
"<div style='clear:both;'></div><div id='info_texts'>"+'<%=t("ruling_timer.delete_task_hint1")%>'.replace('{{task}}',item.data('task'))+"</div>"+"<input id=\"confirm_input\"/ placeholder=\"<%= t('ruling_timer.please_input_confirm_delete') %>\" style=\"width: 17em;\">"+"<div id='msg_end' style='height:0px; overflow:hidden'></div>"+
"</div>");
}else{
$("#info_texts").html('<%=t("ruling_timer.delete_task_hint1")%>'.replace('{{task}}',item.data('task')));
$('#confirm_input').css('display','block');
$('#confirm_input').val('');
}
$( "#dialog-confirm" ).dialog({
resizable: true,
minHeight: 200,
maxHeight: 400,
modal: true,
width: '80%',
open: function(){
$('#confirm_input').blur();
},
close: function(){
$('#confirm_input').css('display','none');
$( this ).dialog( "close" );
},
buttons: {
"<%= t('ruling_timer.confirm') %>": function(){
var _this = $(this);
if($('#confirm_input').val().match(/<%= t('ruling_timer.confirm_delete') %>/gi)){
$('#confirm_input').css('display','none');
$.post(decodeURIComponent("<%=delete_task_admin_ruling_timer_path(:id=>"{{task_id}}")%>").replace("{{task_id}}",task_id),{'confirm_delete': true}).done(function(data){
item_row.remove();
_this.dialog( "close" );
});
}else{
alert("<%= t('client_management.please_input_confirm_delete').html_safe %>");
$('#confirm_input').focus();
}
},
"<%= t('ruling_timer.cancel') %>": function(){
$('#confirm_input').css('display','none');
$( this ).dialog( "close" );
}
}
});
}
}
});
</script>