#173, #38 open approvals and locked documents in the my page

This commit is contained in:
Karel Picman 2013-11-06 10:23:49 +01:00
parent 4139e86331
commit 97292504f0
13 changed files with 216 additions and 14 deletions

View File

@ -17,10 +17,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class DmsfWorkflowStep < ActiveRecord::Base
belongs_to :workflow
belongs_to :dmsf_workflow
has_many :dmsf_workflow_step_assignments, :dependent => :destroy
validates :dmsf_workflow_id, :presence => true
validates :step, :presence => true
validates :user_id, :presence => true

View File

@ -19,9 +19,9 @@
class DmsfWorkflowStepAssignment < ActiveRecord::Base
belongs_to :dmsf_workflow_step
belongs_to :user
belongs_to :dmsf_file_revision
has_many :dmsf_workflow_step_actions, :dependent => :destroy
validates :dmsf_workflow_step_id, :presence => true
validates :dmsf_file_revision_id, :presence => true
validates :dmsf_workflow_step_id, :dmsf_file_revision_id, :presence => true
validates_uniqueness_of :dmsf_workflow_step_id, :scope => [:dmsf_file_revision_id]
def add?(dmsf_file_revision_id)

View File

@ -0,0 +1,82 @@
<%#
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2013 Karel Picman <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.
%>
<% folders = DmsfFolder.joins(
'JOIN dmsf_locks ON dmsf_folders.id = dmsf_locks.entity_id').where(
'dmsf_locks.entity_type' => 1, 'dmsf_locks.user_id' => @user.id).all %>
<% files = DmsfFile.joins(
'JOIN dmsf_locks ON dmsf_files.id = dmsf_locks.entity_id').where(
'dmsf_locks.entity_type' => 0, 'dmsf_locks.user_id' => @user.id).all %>
<h3><%= l(:label_my_locked_documents)%> (<%= folders.count %>/<%= files.count %>)</h3>
<% if folders.any? || files.any?%>
<%= form_tag({}) do %>
<div><table class="list">
<thead>
<tr>
<th><%=l(:field_project)%></th>
<th><%=l(:label_document)%>/<%=l(:field_folder)%></th>
<th><%=l(:field_folder)%></th>
</tr>
</thead>
<tbody>
<% folders.each do |folder| %>
<tr id="folder-<%= folder.id %>" class="<%= cycle('odd', 'even') %>">
<td class="project">
<%= link_to_project(folder.project) %>
</td>
<td class="title">
<%= link_to(h(folder.title),
{:controller => 'dmsf', :action => 'show', :id => folder.project, :folder_id => folder},
:class => 'icon icon-folder') %>
</td>
<td class="title">
<% if folder.folder %>
<%= link_to(h(folder.folder.title),
{:controller => 'dmsf', :action => 'show', :id => folder.project, :folder_id => folder.folder}) %>
<% else %>
<%= link_to(l(:link_documents), {:controller => 'dmsf', :action => 'show', :id=> folder.project }) %>
<% end %>
</td>
</tr>
<% end %>
<% files.each do |file| %>
<tr id="file-<%= file.id %>" class="<%= cycle('odd', 'even') %>">
<td class="project">
<%= link_to_project(file.project) %>
</td>
<td class="title">
<%= link_to(h(file.last_revision.display_title),
{:controller => 'dmsf_files', :action => :show, :id => file },
:class => "icon icon-file #{DmsfHelper.filetype_css(file.name)}") %>
</td>
<td class="title">
<% if file.folder %>
<%= link_to(h(file.folder.title),
{:controller => 'dmsf', :action => 'show', :id => file.project, :folder_id => file.folder}) %>
<% else %>
<%= link_to(l(:link_documents), {:controller => 'dmsf', :action => 'show', :id=> file.project }) %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% end %>

View File

@ -0,0 +1,75 @@
<%#
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2013 Karel Picman <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.
%>
<% 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 %>
<% assignments = Array.new %>
<% all_assignments.each do |assignment| %>
<% if assignment.dmsf_file_revision == assignment.dmsf_file_revision.file.last_revision %>
<% assignments << assignment %>
<% end %>
<% end %>
<h3><%= l(:label_my_open_approvals)%> (<%= assignments.count %>)</h3>
<% if assignments.any? %>
<%= form_tag({}) do %>
<div><table class="list">
<thead>
<tr>
<th><%=l(:field_project)%></th>
<th><%=l(:field_label_dmsf_workflow)%></th>
<th><%=l(:label_document)%></th>
<th><%=l(:field_folder)%></th>
</tr>
</thead>
<tbody>
<% assignments.each do |assignment| %>
<tr id="assignment-<%= assignment.id %>" class="<%= cycle('odd', 'even') %>">
<td class="project">
<%= link_to_project(assignment.dmsf_file_revision.project) %>
</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="title">
<% if assignment.dmsf_file_revision && assignment.dmsf_file_revision.file %>
<%= link_to(h(assignment.dmsf_file_revision.display_title),
{:controller => 'dmsf_files', :action => :show, :id => assignment.dmsf_file_revision.file }) %>
<% end %>
</td>
<td class="title">
<% if assignment.dmsf_file_revision %>
<% if assignment.dmsf_file_revision.folder %>
<%= link_to(h(assignment.dmsf_file_revision.folder.title),
{:controller => 'dmsf', :action => 'show', :id=> assignment.dmsf_file_revision.project, :folder_id => assignment.dmsf_file_revision.folder}) %>
<% else %>
<%= link_to(l(:link_documents), {:controller => 'dmsf', :action => 'show', :id => assignment.dmsf_file_revision.project }) %>
<% end %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% end %>

View File

@ -257,3 +257,8 @@ cs:
text_email_to_proceed: Pro schválení klikněte na zaškrtávací ikonku vedle dokumentu v
text_email_to_see_history: Pro zobrazení historie schvalovacího procesu klikněte na status dokumentu v
text_email_to_see_status: Pro zobrazení aktuálního stavu schvalovacího procesu klikněte na status dokumentu v
my:
blocks:
locked_documents: Zamčené dokumenty
open_approvals: Procesy ke schválení

View File

@ -259,3 +259,8 @@ de:
text_email_to_proceed: To proceed click on the check box icon next to the document in
text_email_to_see_history: To see the approval history click on the workflow status of the document in
text_email_to_see_status: To see the current status of the approval workflow click on the workflow status the document in
my:
blocks:
locked_documents: Locked documents
open_approvals: Open approvals

View File

@ -257,3 +257,10 @@ en:
text_email_to_proceed: To proceed click on the check box icon next to the document in
text_email_to_see_history: To see the approval history click on the workflow status of the document in
text_email_to_see_status: To see the current status of the approval workflow click on the workflow status the document in
label_my_open_approvals: My open approvals
label_my_locked_documents: My locked documents
my:
blocks:
locked_documents: Locked documents
openap_provals: Open approvals

View File

@ -259,3 +259,8 @@ es:
text_email_to_proceed: To proceed click on the check box icon next to the document in
text_email_to_see_history: To see the approval history click on the workflow status of the document in
text_email_to_see_status: To see the current status of the approval workflow click on the workflow status the document in
my:
blocks:
locked_documents: Locked documents
open_approvals: Open approvals

View File

@ -259,3 +259,8 @@ fr:
text_email_to_proceed: To proceed click on the check box icon next to the document in
text_email_to_see_history: To see the approval history click on the workflow status of the document in
text_email_to_see_status: To see the current status of the approval workflow click on the workflow status the document in
my:
blocks:
locked_documents: Locked documents
open_approvals: Open approvals

View File

@ -259,3 +259,8 @@ ja:
text_email_to_proceed: To proceed click on the check box icon next to the document in
text_email_to_see_history: To see the approval history click on the workflow status of the document in
text_email_to_see_status: To see the current status of the approval workflow click on the workflow status the document in
my:
blocks:
locked_documents: Locked documents
open_approvals: Open approvals

View File

@ -259,3 +259,8 @@ ru:
text_email_to_proceed: To proceed click on the check box icon next to the document in
text_email_to_see_history: To see the approval history click on the workflow status of the document in
text_email_to_see_status: To see the current status of the approval workflow click on the workflow status the document in
my:
blocks:
locked_documents: Locked documents
open_approvals: Open approvals

View File

@ -259,3 +259,8 @@ sl:
text_email_to_proceed: To proceed click on the check box icon next to the document in
text_email_to_see_history: To see the approval history click on the workflow status of the document in
text_email_to_see_status: To see the current status of the approval workflow click on the workflow status the document in
my:
blocks:
locked_documents: Locked documents
open_approvals: Open approvals

View File

@ -260,3 +260,8 @@ zh:
text_email_to_proceed: To proceed click on the check box icon next to the document in
text_email_to_see_history: To see the approval history click on the workflow status of the document in
text_email_to_see_status: To see the current status of the approval workflow click on the workflow status the document in
my:
blocks:
locked_documents: Locked documents
open_approvals: Open approvals