Compatibility with Redmine 3.x

This commit is contained in:
Anton Argirov 2015-05-08 14:53:04 +06:00
parent e05a8a467d
commit 37bedaa84a
12 changed files with 41 additions and 51 deletions

View File

@ -95,10 +95,11 @@ Do not forget to check whether issue is just created. Here we create the new iss
== 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
[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.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

View File

@ -1,12 +1,11 @@
class CustomWorkflowsController < ApplicationController
unloadable
layout 'admin'
before_filter :require_admin
before_filter :find_workflow, :only => [:show, :edit, :update, :destroy]
def index
@workflows = CustomWorkflow.find(:all, :include => [:projects])
@workflows = CustomWorkflow.includes(:projects).all
respond_to do |format|
format.html
end

View File

@ -7,21 +7,17 @@ class WorkflowError < StandardError
end
class CustomWorkflow < ActiveRecord::Base
unloadable
attr_protected :id
has_and_belongs_to_many :projects
acts_as_list
default_scope :order => 'position ASC'
validates_presence_of :name
validates_uniqueness_of :name, :case_sensitive => false
validate :validate_syntax
if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("3.1.0")
named_scope :for_all, :conditions => {:is_for_all => true}
else
scope :for_all, where(:is_for_all => true)
end
default_scope { order(:position => :asc) }
scope :for_all, lambda { where(:is_for_all => true) }
def validate_syntax
issue = Issue.new

View File

@ -1,9 +1,12 @@
<div class="splitcontent">
<div class="splitcontentleft box">
<p><%= f.text_field :name, :required => true, :size => 50 %></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 class="splitcontentright">
@ -40,25 +43,19 @@
</fieldset>
<script type="text/javascript">
jQuery('#custom_workflow_before_save').taboverride(2, true);
jQuery('#custom_workflow_after_save').taboverride(2, true);
function checkAndDisable(id, checked) {
if (checked) {
jQuery('#'+id).find('input[type=checkbox]').attr('checked', true).attr('disabled', true);
} else {
jQuery('#'+id).find('input[type=checkbox]').removeAttr('checked').removeAttr('disabled');
jQuery('#custom_workflow_before_save').taboverride(2, true);
jQuery('#custom_workflow_after_save').taboverride(2, true);
function checkAndDisable(id, checked) {
if (checked) {
jQuery('#' + id).find('input[type=checkbox]').attr('checked', true).attr('disabled', true);
} else {
jQuery('#' + id).find('input[type=checkbox]').removeAttr('checked').removeAttr('disabled');
}
}
}
</script>
<%= wikitoolbar_for :custom_workflow_description %>
<% content_for :header_tags do %>
<% if (Redmine::VERSION::ARRAY <=> [2,1,0]) < 0 %>
<%= 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' %>
<%= javascript_include_tag "tab_override", :plugin => 'redmine_custom_workflows' %>
<% end %>

File diff suppressed because one or more lines are too long

View File

@ -1,11 +1,21 @@
#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;
}

View File

@ -1,7 +1,7 @@
class CreateExampleWorkflow < ActiveRecord::Migration
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.
* If done ratio is changed to 100% and status is "In Process", status changes to "Resolved"

11
init.rb
View File

@ -1,7 +1,7 @@
require 'redmine'
require 'redmine_custom_workflows/hooks'
to_prepare = Proc.new do
Rails.application.config.to_prepare do
unless Project.include?(RedmineCustomWorkflows::ProjectPatch)
Project.send(:include, RedmineCustomWorkflows::ProjectPatch)
end
@ -16,18 +16,11 @@ to_prepare = Proc.new do
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
name 'Redmine Custom Workflow plugin'
author 'Anton Argirov'
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'
menu :admin_menu, :custom_workflows, {:controller => 'custom_workflows', :action => 'index'}, :caption => :label_custom_workflow_plural

View File

@ -1,6 +1,5 @@
module RedmineCustomWorkflows
module Helper
unloadable
# Renders a tree of projects as a nested set of unordered lists
# 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|
# set the project environment to please macros.
@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"
else
ancestors.pop
s << "</li>"
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
s << '</li>'
while ancestors.any? && !project.is_descendant_of?(ancestors.last)
ancestors.pop
s << "</ul></li>\n"
end

View File

@ -1,6 +1,5 @@
module RedmineCustomWorkflows
module IssuePatch
unloadable
def self.included(base)
base.send(:include, InstanceMethods)

View File

@ -1,6 +1,5 @@
module RedmineCustomWorkflows
module ProjectPatch
unloadable
def self.included(base)
base.send :include, InstanceMethods

View File

@ -1,6 +1,5 @@
module RedmineCustomWorkflows
module ProjectsHelperPatch
unloadable
def self.included(base)
base.send(:include, InstanceMethods)