<%= DmsfWorkflowStepAction.workflow_str(DmsfWorkflowStepAction::ACTION_START) if revision.dmsf_workflow_started_by %>
<%= format_time(revision.dmsf_workflow_started_at) if revision.dmsf_workflow_started_at %>
- <% sql = "SELECT c.action, c.note, c.created_at, c.author_id, a.user_id, s.step FROM dmsf_workflow_step_actions c RIGHT JOIN dmsf_workflow_step_assignments a ON a.id = c.dmsf_workflow_step_assignment_id RIGHT JOIN dmsf_workflow_steps s ON s.id = a.dmsf_workflow_step_id WHERE a.dmsf_file_revision_id = #{revision.id} ORDER BY s.step, c.action DESC, c.created_at" %>
- <% result = DmsfWorkflowStep.connection.exec_query sql %>
+ <% sql = "SELECT c.action, c.note, c.created_at, c.author_id, a.user_id, s.step, s.name FROM dmsf_workflow_step_actions c RIGHT JOIN dmsf_workflow_step_assignments a ON a.id = c.dmsf_workflow_step_assignment_id RIGHT JOIN dmsf_workflow_steps s ON s.id = a.dmsf_workflow_step_id WHERE a.dmsf_file_revision_id = #{revision.id} ORDER BY s.step, s.id, c.action DESC, c.created_at" %>
+ <% result = DmsfWorkflowStep.connection.exec_query sql %>
+ <% last_step = 0 %>
<% result.each_with_index do |row, i| %>
diff --git a/app/views/dmsf_workflows/_new_step_form.html.erb b/app/views/dmsf_workflows/_new_step_form.html.erb
index 3e60cf75..55a737f6 100644
--- a/app/views/dmsf_workflows/_new_step_form.html.erb
+++ b/app/views/dmsf_workflows/_new_step_form.html.erb
@@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
-# Copyright (C) 2011-16 Karel Pičman
+# Copyright (C) 2011-17 Karel Pičman
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -33,5 +33,10 @@
\ No newline at end of file
+ :id => 'selected_step', :onchange => "$('#dmsf_step_name').toggle(this.value == 0);" %>
+
+
+ <%= label_tag 'name', l(:field_name) %>
+ <%= text_field_tag 'name', nil, :maxlength => 30 %>
+
+
diff --git a/app/views/dmsf_workflows/_steps.html.erb b/app/views/dmsf_workflows/_steps.html.erb
index e26daf77..c4b38c46 100644
--- a/app/views/dmsf_workflows/_steps.html.erb
+++ b/app/views/dmsf_workflows/_steps.html.erb
@@ -44,6 +44,7 @@
<% if steps.any? %>
+
<%= l(:label_dmsf_workflow_step) %>
<%= l(:label_dmsf_workflow_approval_plural) %>
@@ -52,6 +53,8 @@
<% steps.each do |i|%>
<%= i %>
+ <% index = @dmsf_workflow.dmsf_workflow_steps.order(:id).index{ |s| s.step == i } %>
+
<%= @dmsf_workflow.dmsf_workflow_steps[index].name if index %>
<% stps = @dmsf_workflow.dmsf_workflow_steps.collect{|s| (s.step == i) ? s : nil}.compact %>
<% stps.each_with_index do |step, j| %>
diff --git a/db/migrate/20170103164701_add_name_to_appoval_workflow_step.rb b/db/migrate/20170103164701_add_name_to_appoval_workflow_step.rb
new file mode 100644
index 00000000..009cf80c
--- /dev/null
+++ b/db/migrate/20170103164701_add_name_to_appoval_workflow_step.rb
@@ -0,0 +1,29 @@
+# encoding: utf-8
+#
+# Redmine plugin for Document Management System "Features"
+#
+# Copyright (C) 2011-17 Karel Pičman
+#
+# 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.
+
+class AddNameToAppovalWorkflowStep < ActiveRecord::Migration
+ def up
+ add_column :dmsf_workflow_steps, :name, :string, :limit => 30, :null => true
+ end
+
+ def down
+ remove_column :dmsf_links, :external_url
+ end
+end
diff --git a/test/fixtures/dmsf_workflow_steps.yml b/test/fixtures/dmsf_workflow_steps.yml
index 5f781121..45576e54 100644
--- a/test/fixtures/dmsf_workflow_steps.yml
+++ b/test/fixtures/dmsf_workflow_steps.yml
@@ -3,6 +3,7 @@ wfs2:
id: 2
dmsf_workflow_id: 1
step: 2
+ name: '2nd step'
user_id: 2
operator: 1
@@ -10,6 +11,7 @@ wfs1:
id: 1
dmsf_workflow_id: 1
step: 1
+ name: '1st step'
user_id: 1
operator: 0
@@ -31,5 +33,6 @@ wfs5:
id: 5
dmsf_workflow_id: 1
step: 3
+ name: '3rd step'
user_id: 2
operator: 1
diff --git a/test/functional/dmsf_workflow_controller_test.rb b/test/functional/dmsf_workflow_controller_test.rb
index 5a7d391d..10148872 100644
--- a/test/functional/dmsf_workflow_controller_test.rb
+++ b/test/functional/dmsf_workflow_controller_test.rb
@@ -196,12 +196,14 @@ class DmsfWorkflowsControllerTest < RedmineDmsf::Test::TestCase
def test_add_step
assert_difference 'DmsfWorkflowStep.count', +1 do
- post :add_step, :commit => l(:dmsf_or), :step => 1, :id => @wf1.id, :user_ids => [@user_non_member.id]
+ post :add_step, :commit => l(:dmsf_or), :step => 1, :name => '1st step', :id => @wf1.id,
+ :user_ids => [@user_non_member.id]
end
assert_response :success
ws = DmsfWorkflowStep.order('id DESC').first
assert_equal @wf1.id, ws.dmsf_workflow_id
assert_equal 1, ws.step
+ assert_equal '1st step', ws.name
assert_equal @user_non_member.id, ws.user_id
assert_equal DmsfWorkflowStep::OPERATOR_OR, ws.operator
end
diff --git a/test/unit/dmsf_workflow_step_test.rb b/test/unit/dmsf_workflow_step_test.rb
index 2cb9e105..973c3694 100644
--- a/test/unit/dmsf_workflow_step_test.rb
+++ b/test/unit/dmsf_workflow_step_test.rb
@@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
-# Copyright (C) 2011-16 Karel Pičman
+# Copyright (C) 2011-17 Karel Pičman
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -44,6 +44,7 @@ class DmsfWorkflowStepTest < RedmineDmsf::Test::UnitTest
wfs = DmsfWorkflowStep.new
wfs.dmsf_workflow_id = 1
wfs.step = 2
+ wfs.name = '2nd step'
wfs.user_id = 3
wfs.operator = 1
assert wfs.save, wfs.errors.full_messages.to_sentence
@@ -51,13 +52,15 @@ class DmsfWorkflowStepTest < RedmineDmsf::Test::UnitTest
def test_update
@wfs1.dmsf_workflow_id = 2
- @wfs1.step = 2
+ @wfs1.step = 2
+ @wfs1.name = '2nd step'
@wfs1.user_id = 2
@wfs1.operator = 2
assert @wfs1.save, @wfs1.errors.full_messages.to_sentence
@wfs1.reload
assert_equal 2, @wfs1.dmsf_workflow_id
assert_equal 2, @wfs1.step
+ assert_equal '2nd step', @wfs1.name
assert_equal 2, @wfs1.user_id
assert_equal 2, @wfs1.operator
end
@@ -93,6 +96,12 @@ class DmsfWorkflowStepTest < RedmineDmsf::Test::UnitTest
assert !@wfs2.save
assert_equal 1, @wfs2.errors.count
end
+
+ def test_validate_name_length
+ @wfs1.name = 'a' * 31
+ assert !@wfs1.save
+ assert_equal 1, @wfs1.errors.count
+ end
def test_destroy
assert DmsfWorkflowStepAssignment.where(:dmsf_workflow_step_id => @wfs2.id).all.count > 0