mirror of
https://github.com/anteo/redmine_custom_workflows.git
synced 2026-01-26 00:04:20 +00:00
Compatibility with Redmine 3.x
This commit is contained in:
parent
e05a8a467d
commit
37bedaa84a
@ -95,10 +95,11 @@ Do not forget to check whether issue is just created. Here we create the new iss
|
|||||||
|
|
||||||
== Compatibility
|
== Compatibility
|
||||||
|
|
||||||
This plug-in is compatible with Redmine 1.2.x, 1.3.x, 1.4.x, 2.x.x
|
This plug-in is compatible with Redmine 1.2.x, 1.3.x, 1.4.x, 2.x.x, 3.x.x (starting from version 0.1.0)
|
||||||
|
|
||||||
== Changelog
|
== Changelog
|
||||||
|
|
||||||
|
[0.1.0] Compatibility with Redmine 3.x, support of Redmine 2.x.x has dropped (for Redmine 2.x.x please use version 0.0.5)
|
||||||
[0.0.5] Compatibility with latest versions of Redmine 2.x.x
|
[0.0.5] Compatibility with latest versions of Redmine 2.x.x
|
||||||
[0.0.4] * Added ability to enable workflows globally for all projects. No need to enable 'Custom workflows' project module anymore. Just go to the 'Administration' -> 'Custom workflows' section and enable or disable your workflows in one place.
|
[0.0.4] * Added ability to enable workflows globally for all projects. No need to enable 'Custom workflows' project module anymore. Just go to the 'Administration' -> 'Custom workflows' section and enable or disable your workflows in one place.
|
||||||
* Fixed bug with 'Status transition prohibited' when updating the issue status by the repository commit
|
* Fixed bug with 'Status transition prohibited' when updating the issue status by the repository commit
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
class CustomWorkflowsController < ApplicationController
|
class CustomWorkflowsController < ApplicationController
|
||||||
unloadable
|
|
||||||
|
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
before_filter :require_admin
|
before_filter :require_admin
|
||||||
before_filter :find_workflow, :only => [:show, :edit, :update, :destroy]
|
before_filter :find_workflow, :only => [:show, :edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@workflows = CustomWorkflow.find(:all, :include => [:projects])
|
@workflows = CustomWorkflow.includes(:projects).all
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
|
|||||||
@ -7,21 +7,17 @@ class WorkflowError < StandardError
|
|||||||
end
|
end
|
||||||
|
|
||||||
class CustomWorkflow < ActiveRecord::Base
|
class CustomWorkflow < ActiveRecord::Base
|
||||||
unloadable
|
|
||||||
|
|
||||||
|
attr_protected :id
|
||||||
has_and_belongs_to_many :projects
|
has_and_belongs_to_many :projects
|
||||||
acts_as_list
|
acts_as_list
|
||||||
|
|
||||||
default_scope :order => 'position ASC'
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name, :case_sensitive => false
|
validates_uniqueness_of :name, :case_sensitive => false
|
||||||
validate :validate_syntax
|
validate :validate_syntax
|
||||||
|
|
||||||
if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("3.1.0")
|
default_scope { order(:position => :asc) }
|
||||||
named_scope :for_all, :conditions => {:is_for_all => true}
|
scope :for_all, lambda { where(:is_for_all => true) }
|
||||||
else
|
|
||||||
scope :for_all, where(:is_for_all => true)
|
|
||||||
end
|
|
||||||
|
|
||||||
def validate_syntax
|
def validate_syntax
|
||||||
issue = Issue.new
|
issue = Issue.new
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
|
|
||||||
<div class="splitcontent">
|
<div class="splitcontent">
|
||||||
<div class="splitcontentleft box">
|
<div class="splitcontentleft box">
|
||||||
<p><%= f.text_field :name, :required => true, :size => 50 %></p>
|
<p><%= f.text_field :name, :required => true, :size => 50 %></p>
|
||||||
|
|
||||||
<p><%= f.text_area :description, :cols => 40, :rows => 5 %></p>
|
<p><%= f.text_area :description, :cols => 40, :rows => 5 %></p>
|
||||||
<p><label><%= f.check_box :is_for_all, :onclick => "checkAndDisable('custom_workflow_enabled_projects', this.checked);", :no_label => true %> <%= l(:field_enabled_for_all_projects) %></label></p>
|
|
||||||
|
<p>
|
||||||
|
<label><%= f.check_box :is_for_all, :onclick => "checkAndDisable('custom_workflow_enabled_projects', this.checked);", :no_label => true %> <%= l(:field_enabled_for_all_projects) %></label>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="splitcontentright">
|
<div class="splitcontentright">
|
||||||
@ -40,25 +43,19 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery('#custom_workflow_before_save').taboverride(2, true);
|
jQuery('#custom_workflow_before_save').taboverride(2, true);
|
||||||
jQuery('#custom_workflow_after_save').taboverride(2, true);
|
jQuery('#custom_workflow_after_save').taboverride(2, true);
|
||||||
function checkAndDisable(id, checked) {
|
function checkAndDisable(id, checked) {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
jQuery('#'+id).find('input[type=checkbox]').attr('checked', true).attr('disabled', true);
|
jQuery('#' + id).find('input[type=checkbox]').attr('checked', true).attr('disabled', true);
|
||||||
} else {
|
} else {
|
||||||
jQuery('#'+id).find('input[type=checkbox]').removeAttr('checked').removeAttr('disabled');
|
jQuery('#' + id).find('input[type=checkbox]').removeAttr('checked').removeAttr('disabled');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<%= wikitoolbar_for :custom_workflow_description %>
|
<%= wikitoolbar_for :custom_workflow_description %>
|
||||||
|
|
||||||
<% content_for :header_tags do %>
|
<% content_for :header_tags do %>
|
||||||
<% if (Redmine::VERSION::ARRAY <=> [2,1,0]) < 0 %>
|
<%= javascript_include_tag "tab_override", :plugin => 'redmine_custom_workflows' %>
|
||||||
<%= javascript_include_tag "jquery-1.8.1.min.js", :plugin => 'redmine_custom_workflows' %>
|
|
||||||
<script type="text/javascript">
|
|
||||||
jQuery.noConflict();
|
|
||||||
</script>
|
|
||||||
<% end %>
|
|
||||||
<%= javascript_include_tag "tab_override", :plugin => 'redmine_custom_workflows' %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
2
assets/javascripts/jquery-1.8.1.min.js
vendored
2
assets/javascripts/jquery-1.8.1.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,11 +1,21 @@
|
|||||||
#admin-menu a.custom-workflows {
|
#admin-menu a.custom-workflows {
|
||||||
background-image: url(../../../images/ticket_go.png);
|
background-image: url(../../../images/ticket_go.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
table.list.custom-workflows td { vertical-align: middle; }
|
table.list.custom-workflows td {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
#custom_workflow_description, #custom_workflow_name { width: 98%; }
|
#custom_workflow_description, #custom_workflow_name {
|
||||||
|
width: 98%;
|
||||||
|
}
|
||||||
|
|
||||||
#custom_workflow_before_save, #custom_workflow_after_save { width: 98%; font-size: 11px; }
|
#custom_workflow_before_save, #custom_workflow_after_save {
|
||||||
|
width: 98%;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
#custom_workflow_enabled_projects ul { max-height: 200px; overflow-y: auto; }
|
#custom_workflow_enabled_projects ul {
|
||||||
|
max-height: 200px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
class CreateExampleWorkflow < ActiveRecord::Migration
|
class CreateExampleWorkflow < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
CustomWorkflow.create(:name => "Duration/Done Ratio/Status correlation", :description => <<EOD, :script => <<EOS)
|
CustomWorkflow.create!(:name => 'Duration/Done Ratio/Status correlation', :description => <<EOD, :script => <<EOS)
|
||||||
Set up a correlation between the start date, due date, done ratio and status of issues.
|
Set up a correlation between the start date, due date, done ratio and status of issues.
|
||||||
|
|
||||||
* If done ratio is changed to 100% and status is "In Process", status changes to "Resolved"
|
* If done ratio is changed to 100% and status is "In Process", status changes to "Resolved"
|
||||||
|
|||||||
11
init.rb
11
init.rb
@ -1,7 +1,7 @@
|
|||||||
require 'redmine'
|
require 'redmine'
|
||||||
require 'redmine_custom_workflows/hooks'
|
require 'redmine_custom_workflows/hooks'
|
||||||
|
|
||||||
to_prepare = Proc.new do
|
Rails.application.config.to_prepare do
|
||||||
unless Project.include?(RedmineCustomWorkflows::ProjectPatch)
|
unless Project.include?(RedmineCustomWorkflows::ProjectPatch)
|
||||||
Project.send(:include, RedmineCustomWorkflows::ProjectPatch)
|
Project.send(:include, RedmineCustomWorkflows::ProjectPatch)
|
||||||
end
|
end
|
||||||
@ -16,18 +16,11 @@ to_prepare = Proc.new do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Redmine::VERSION::MAJOR >= 2
|
|
||||||
Rails.configuration.to_prepare(&to_prepare)
|
|
||||||
else
|
|
||||||
require 'dispatcher'
|
|
||||||
Dispatcher.to_prepare(:redmine_custom_workflows, &to_prepare)
|
|
||||||
end
|
|
||||||
|
|
||||||
Redmine::Plugin.register :redmine_custom_workflows do
|
Redmine::Plugin.register :redmine_custom_workflows do
|
||||||
name 'Redmine Custom Workflow plugin'
|
name 'Redmine Custom Workflow plugin'
|
||||||
author 'Anton Argirov'
|
author 'Anton Argirov'
|
||||||
description 'Allows to create custom workflows for issues, defined in the plain Ruby language'
|
description 'Allows to create custom workflows for issues, defined in the plain Ruby language'
|
||||||
version '0.0.5'
|
version '0.1.0'
|
||||||
url 'http://redmine.academ.org'
|
url 'http://redmine.academ.org'
|
||||||
|
|
||||||
menu :admin_menu, :custom_workflows, {:controller => 'custom_workflows', :action => 'index'}, :caption => :label_custom_workflow_plural
|
menu :admin_menu, :custom_workflows, {:controller => 'custom_workflows', :action => 'index'}, :caption => :label_custom_workflow_plural
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module Helper
|
module Helper
|
||||||
unloadable
|
|
||||||
|
|
||||||
# Renders a tree of projects as a nested set of unordered lists
|
# Renders a tree of projects as a nested set of unordered lists
|
||||||
# The given collection may be a subset of the whole project tree
|
# The given collection may be a subset of the whole project tree
|
||||||
@ -13,12 +12,12 @@ module RedmineCustomWorkflows
|
|||||||
projects.sort_by(&:lft).each do |project|
|
projects.sort_by(&:lft).each do |project|
|
||||||
# set the project environment to please macros.
|
# set the project environment to please macros.
|
||||||
@project = project
|
@project = project
|
||||||
if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
|
if ancestors.empty? || project.is_descendant_of?(ancestors.last)
|
||||||
s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n"
|
s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n"
|
||||||
else
|
else
|
||||||
ancestors.pop
|
ancestors.pop
|
||||||
s << "</li>"
|
s << '</li>'
|
||||||
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
while ancestors.any? && !project.is_descendant_of?(ancestors.last)
|
||||||
ancestors.pop
|
ancestors.pop
|
||||||
s << "</ul></li>\n"
|
s << "</ul></li>\n"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module IssuePatch
|
module IssuePatch
|
||||||
unloadable
|
|
||||||
|
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.send(:include, InstanceMethods)
|
base.send(:include, InstanceMethods)
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module ProjectPatch
|
module ProjectPatch
|
||||||
unloadable
|
|
||||||
|
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.send :include, InstanceMethods
|
base.send :include, InstanceMethods
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
module RedmineCustomWorkflows
|
module RedmineCustomWorkflows
|
||||||
module ProjectsHelperPatch
|
module ProjectsHelperPatch
|
||||||
unloadable
|
|
||||||
|
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.send(:include, InstanceMethods)
|
base.send(:include, InstanceMethods)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user