redmine_dmsf/app/views/my/blocks/_open_approvals.html.erb
2017-03-17 11:00:40 +01:00

118 lines
5.7 KiB
Plaintext

<%
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011-17 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%>
<% assignments = Array.new %>
<% if @user %>
<% all_assignments = DmsfWorkflowStepAssignment.joins(
'LEFT JOIN dmsf_workflow_step_actions ON dmsf_workflow_step_assignments.id = dmsf_workflow_step_actions.dmsf_workflow_step_assignment_id').where(
'dmsf_workflow_step_assignments.user_id = ? AND dmsf_workflow_step_actions.id IS NULL', @user.id).all %>
<% all_assignments.each do |assignment| %>
<% if assignment.dmsf_file_revision.dmsf_file.last_revision &&
!assignment.dmsf_file_revision.dmsf_file.last_revision.deleted? &&
(assignment.dmsf_file_revision.workflow == DmsfWorkflow::STATE_WAITING_FOR_APPROVAL) &&
(assignment.dmsf_file_revision == assignment.dmsf_file_revision.dmsf_file.last_revision) %>
<% assignments << assignment %>
<% end %>
<% end %>
<% end %>
<h3><%= l(:open_approvals)%> (<%= assignments.count %>)</h3>
<% if assignments.any? %>
<%= form_tag({}) do %>
<table class="list">
<thead>
<tr>
<th><%= l(:field_project) %></th>
<th><%= l(:field_label_dmsf_workflow) %></th>
<th><%= l(:field_status) %></th>
<th><%= l(:label_document) %></th>
<th><%= l(:field_folder) %></th>
<th></th>
</tr>
</thead>
<tbody>
<% assignments.each do |assignment| %>
<tr id="assignment-<%= assignment.id %>" class="<%= cycle('odd', 'even') %>">
<td class="project">
<% if assignment.dmsf_file_revision.dmsf_file.project %>
<%= link_to_project(assignment.dmsf_file_revision.dmsf_file.project) %>
<% end %>
</td>
<td>
<% if assignment.dmsf_workflow_step && assignment.dmsf_workflow_step.dmsf_workflow %>
<%= link_to(h(assignment.dmsf_workflow_step.dmsf_workflow.name),
edit_dmsf_workflow_path(assignment.dmsf_workflow_step.dmsf_workflow)) %>
<% end %>
</td>
<td class="dmsf_workflow">
<% if assignment.dmsf_workflow_step.dmsf_workflow %>
<%= link_to(
assignment.dmsf_file_revision.workflow_str(false),
log_dmsf_workflow_path(
:project_id => assignment.dmsf_file_revision.dmsf_file.project.id,
:id => assignment.dmsf_workflow_step.dmsf_workflow.id,
:dmsf_file_revision_id => assignment.dmsf_file_revision.id),
:title => assignment.dmsf_file_revision.workflow_tooltip,
:remote => true) %>
<% else %>
<%= assignment.dmsf_file_revision.workflow_str(false) %>
<% end %>
</td>
<td class="title">
<% if assignment.dmsf_file_revision && assignment.dmsf_file_revision.dmsf_file %>
<%= link_to(h(assignment.dmsf_file_revision.title),
{:controller => 'dmsf_files', :action => :show, :id => assignment.dmsf_file_revision.dmsf_file }) %>
<% end %>
</td>
<td class="title">
<% if assignment.dmsf_file_revision %>
<% if assignment.dmsf_file_revision.dmsf_file.dmsf_folder %>
<%= link_to(h(assignment.dmsf_file_revision.dmsf_file.dmsf_folder.title),
{:controller => 'dmsf', :action => 'show', :id => assignment.dmsf_file_revision.dmsf_file.project, :folder_id => assignment.dmsf_file_revision.dmsf_file.dmsf_folder}) %>
<% elsif assignment.dmsf_file_revision.dmsf_file.project %>
<%= link_to(l(:link_documents), {:controller => 'dmsf', :action => 'show', :id => assignment.dmsf_file_revision.dmsf_file.project }) %>
<% end %>
<% end %>
</td>
<td class="dmsf_buttons">
<% if assignment.dmsf_workflow_step.dmsf_workflow %>
<% assigns = assignment.dmsf_workflow_step.dmsf_workflow.next_assignments(assignment.dmsf_file_revision.id) %>
<% index = assigns.find_index{|assign| assign.user_id == User.current.id} if assigns %>
<% if index %>
<%= link_to('',
action_dmsf_workflow_path(
:project_id => assignment.dmsf_file_revision.dmsf_file.project.id,
:id => assignment.dmsf_workflow_step.dmsf_workflow.id,
:dmsf_workflow_step_assignment_id => assigns[index].id,
:dmsf_file_revision_id => assignment.dmsf_file_revision.id),
:title => l(:title_waiting_for_approval),
:remote => true,
:class => 'icon icon-wf-waiting') %>
<% end %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% end %>