Skip to content

Commit

Permalink
Some minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nodecarter committed Nov 21, 2016
1 parent da4e35b commit 7bbc784
Show file tree
Hide file tree
Showing 25 changed files with 381 additions and 379 deletions.
44 changes: 11 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,18 @@ services:
- postgresql

rvm:
- 1.9.3
- 2.0.0
- 2.3.1

gemfile:
- $REDMINE_PATH/Gemfile

env:
- REDMINE_VER=2.1.6 DB=mysql
- REDMINE_VER=2.2.4 DB=mysql
- REDMINE_VER=2.3.3 DB=mysql
- REDMINE_VER=2.3.4 DB=mysql
- REDMINE_VER=2.4.4 DB=mysql
- REDMINE_VER=2.5.0 DB=mysql
- REDMINE_VER=2.1.6 DB=postgresql
- REDMINE_VER=2.2.4 DB=postgresql
- REDMINE_VER=2.3.3 DB=postgresql
- REDMINE_VER=2.3.4 DB=postgresql
- REDMINE_VER=2.4.4 DB=postgresql
- REDMINE_VER=2.5.0 DB=postgresql

matrix:
exclude:
- rvm: 2.0.0
env: REDMINE_VER=2.1.6 DB=mysql
gemfile: $REDMINE_PATH/Gemfile
- rvm: 2.0.0
env: REDMINE_VER=2.2.4 DB=mysql
gemfile: $REDMINE_PATH/Gemfile
- rvm: 2.0.0
env: REDMINE_VER=2.1.6 DB=postgresql
gemfile: $REDMINE_PATH/Gemfile
- rvm: 2.0.0
env: REDMINE_VER=2.2.4 DB=postgresql
gemfile: $REDMINE_PATH/Gemfile
- REDMINE_VER=3.1.7 DB=mysql
- REDMINE_VER=3.2.4 DB=mysql
- REDMINE_VER=3.3.1 DB=mysql
- REDMINE_VER=3.1.7 DB=postgresql
- REDMINE_VER=3.2.4 DB=postgresql
- REDMINE_VER=3.3.1 DB=postgresql

before_install:
- export PLUGIN_NAME=redmine_issue_checklist
Expand All @@ -49,10 +27,10 @@ before_install:
- cd $REDMINE_PATH

before_script:
- rake db:create
- rake db:migrate
- rake redmine:plugins:migrate
- bundle exec rake db:create
- bundle exec rake db:migrate
- bundle exec rake redmine:plugins:migrate

script:
- rake redmine:plugins:test NAME=$PLUGIN_NAME
- bundle exec rake redmine:plugins:test NAME=$PLUGIN_NAME RUBYOPT="-W0"

21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Redmine Issue Checklist Plugin

[![Build Status](https://travis-ci.org/Undev/redmine_issue_checklist.png?branch=master)](https://travis-ci.org/Undev/redmine_issue_checklist)
[![Code Climate](https://codeclimate.com/github/Undev/redmine_issue_checklist.png)](https://codeclimate.com/github/Undev/redmine_issue_checklist)
[![Build Status](https://travis-ci.org/Restream/redmine_issue_checklist.svg?branch=master)](https://travis-ci.org/Restream/redmine_issue_checklist)
[![Code Climate](https://codeclimate.com/github/Restream/redmine_issue_checklist/badges/gpa.svg)](https://codeclimate.com/github/Restream/redmine_issue_checklist)

This plugin enables you to add checklists to Redmine issues.

The initial author of the plugin is [Kirill Bezrukov](http://www.redminecrm.com/projects/checklist/pages/1)

## Compatibility

This plugin version is compatible only with Redmine 2.0 and later.
This plugin version is compatible only with Redmine 3.0 and later.

## Installation

Expand All @@ -24,12 +24,11 @@ This plugin version is compatible only with Redmine 2.0 and later.
Copy the plugin from GitHub using the following commands:

git clone https://github.com/Undev/redmine_issue_checklist.git plugins/redmine_issue_checklist
git clone https://github.com/Restream/redmine_issue_checklist.git plugins/redmine_issue_checklist

2. Update the Gemfile.lock file by running the following commands:

rm Gemfile.lock
bundle install
bundle install
3. This plugin requires a migration. Run the following command to upgrade your database (make a database backup before):

Expand All @@ -44,19 +43,19 @@ Now you should be able to see the plugin in **Administration > Plugins**.
The Redmine Issue Checklist plugin enables you to add checklists to Redmine issues.

You can configure the plugin to track the checklist changes in the issue log and change the issue done ratio based on the checklist progress. To do this, go to **Administration > Plugins**, clik**Configure** and select the corresponding check boxes.
![plugin settings](issue_checklist_1.PNG)
![plugin settings](doc/issue_checklist_1.png)

To add a checklist to an issue, enter the checklist item text into the the **Checklist** field in the issue description and click the **+** button.
![checklist item](issue_checklist_2.PNG)
![checklist item](doc/issue_checklist_2.png)

You can add as many checklist items as you need. To rearrange the checklist, drag and drop the items in the desired order. To delete an item, click the trash bin icon.
![checklist item](issue_checklist_3.PNG)
![checklist item](doc/issue_checklist_3.png)

To mark the completed checklist items, select the corresponding check boxes. The plugin will display the changes in the issue log and change the issue done ratio, if you have configured it accordingly.
![progress](issue_checklist_4.PNG)
![progress](doc/issue_checklist_4.png)

To manage checklist-related permissions, go to **Administration > Roles and permissions**, click the role name and select or clear the required check boxes.
![permissions](issue_checklist_5.PNG)
![permissions](doc/issue_checklist_5.png)

## Testing

Expand Down
62 changes: 31 additions & 31 deletions app/controllers/issue_checklists_controller.rb
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
class IssueChecklistsController < ApplicationController
before_filter :find_checklist_item

before_action :find_checklist_item

def done
(render_403; return false) unless User.current.allowed_to?(:done_checklists, @checklist_item.issue.project)

old_checklist_item = @checklist_item.dup
old_checklist_item = @checklist_item.dup
@checklist_item.is_done = !@checklist_item.is_done

if @checklist_item.save
if RedmineIssueChecklist.settings[:save_log] && old_checklist_item.info != @checklist_item.info
journal = Journal.new(:journalized => @checklist_item.issue, :user => User.current)
journal.details << JournalDetail.new(:property => 'attr',
:prop_key => 'checklist',
# :old_value => old_checklist_item.info,
:value => @checklist_item.info)
journal = Journal.new(journalized: @checklist_item.issue, user: User.current)
journal.details << JournalDetail.new(
property: 'attr',
prop_key: 'checklist',
# old_value: old_checklist_item.info,
value: @checklist_item.info)
journal.save
end
if (Setting.issue_done_ratio == "issue_field") && RedmineIssueChecklist.settings[:issue_done_ratio]
done_checklist = @checklist_item.issue.checklist.map{|c| c.is_done ? 1 : 0}

if (Setting.issue_done_ratio == 'issue_field') && RedmineIssueChecklist.settings[:issue_done_ratio]
done_checklist = @checklist_item.issue.checklist.map { |c| c.is_done ? 1 : 0 }
@checklist_item.issue.done_ratio = (done_checklist.count(1) * 10) / done_checklist.count * 10
@checklist_item.issue.save
end
end
respond_to do |format|
format.js
format.html {redirect_to :back }
format.html { redirect_to :back }
end
end

end

def delete
(render_403; return false) unless User.current.allowed_to?(:edit_checklists, @checklist_item.issue.project)

@checklist_item.delete
respond_to do |format|
format.js do
render :update do |page|
page["checklist_item_#{@checklist_item.id}"].visual_effect :fade
format.js do
render :update do |page|
page["checklist_item_#{@checklist_item.id}"].visual_effect :fade
end
end
format.html {redirect_to :back }
end
format.html { redirect_to :back }
end
end

end

private

def find_checklist_item
@checklist_item = IssueChecklist.find(params[:checklist_item_id])
@project = @checklist_item.issue.project
@checklist_item = IssueChecklist.find(params[:checklist_item_id])
@project = @checklist_item.issue.project
end



end
25 changes: 12 additions & 13 deletions app/models/issue_checklist.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
class IssueChecklist < ActiveRecord::Base
belongs_to :issue
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
has_one :comment, :as => :commented, :dependent => :delete
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
has_one :comment, as: :commented, dependent: :delete
acts_as_list

attr_accessible :is_done, :subject
attr_protected :id

validates_presence_of :subject

# after_save :recalc_issue_done_ratio

def editable_by?(usr=User.current)
usr && (usr.allowed_to?(:edit_checklists, project) || (self.author == usr && usr.allowed_to?(:edit_own_checklists, project)))
end

def project
self.issue.project if self.issue
end
self.issue.project if self.issue
end

def info
"[#{self.is_done ? 'x' : ' ' }] #{self.subject.strip}"
end

def recalc_issue_done_ratio
return false if (Setting.issue_done_ratio != "issue_field") || !RedmineIssueChecklist.settings[:issue_done_ratio]
done_checklist = issue.checklist.map{|c| c.is_done ? 1 : 0}
return false if (Setting.issue_done_ratio != 'issue_field') || !RedmineIssueChecklist.settings[:issue_done_ratio]
done_checklist = issue.checklist.map { |c| c.is_done ? 1 : 0 }
issue.done_ratio = (done_checklist.count(1) * 10) / done_checklist.count * 10
issue.save
end



end
7 changes: 4 additions & 3 deletions app/views/issue_checklists/_checklist_item.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<li id="checklist_item_<%= checklist_item.id %>" <%= "class=is-done-checklist-item" if checklist_item.is_done %> >
<%= check_box_tag 'checklist_item', "1", checklist_item.is_done, :disabled => !User.current.allowed_to?(:done_checklists, checklist_item.issue.project),
:onclick =>"checklist_item_done(this,'#{url_for({:controller => "issue_checklists", :action => "done", :checklist_item_id => checklist_item.id, :is_done => (checklist_item.is_done == false)})}','#{checklist_item.id}')"
<li id="checklist_item_<%= checklist_item.id %>" <%= 'class=is-done-checklist-item' if checklist_item.is_done %> >
<%= check_box_tag 'checklist_item', '1', checklist_item.is_done,
disabled: !User.current.allowed_to?(:done_checklists, checklist_item.issue.project),
onclick: "checklist_item_done(this,'#{url_for({ controller: 'issue_checklists', action: 'done', checklist_item_id: checklist_item.id, is_done: (checklist_item.is_done == false) })}','#{checklist_item.id}')"
%>
<%= textilizable(checklist_item, :subject).gsub(/<\/?(p|h\d+|li|ul)>/, '').strip.html_safe %>
</li>
34 changes: 17 additions & 17 deletions app/views/issues/_checklist.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<% if [email protected]? && @issue.checklist.any? && User.current.allowed_to?(:view_checklists, @project) %>
<% if [email protected]? && @issue.checklist.any? && User.current.allowed_to?(:view_checklists, @project) %>

<hr />
<div id="issue_checklist">
<p><strong><%=l(:label_issue_checklist_plural)%></strong></p>
<ul id="issue_checklist_items">
<% @issue.checklist.each do |checklist_item| %>
<%= render :partial => 'issue_checklists/checklist_item', :object => checklist_item %>
<% end %>
</ul>
</div>
<hr/>
<div id="issue_checklist">
<p><strong><%= l(:label_issue_checklist_plural) %></strong></p>

<ul id="issue_checklist_items">
<% @issue.checklist.each do |checklist_item| %>
<%= render partial: 'issue_checklists/checklist_item', object: checklist_item %>
<% end %>
</ul>
</div>

<% end %>

<% content_for :header_tags do %>
<% if Redmine::VERSION::MAJOR == 3 || (Redmine::VERSION::MAJOR == 2 && Redmine::VERSION::MINOR >= 1) %>
<%= javascript_include_tag 'jquery.klass.js', :plugin => 'redmine_issue_checklist' %>
<%= javascript_include_tag 'issue_checklist.jquery.js', :plugin => 'redmine_issue_checklist' %>
<% else %>
<%= javascript_include_tag 'issue_checklist.prototype.js', :plugin => 'redmine_issue_checklist' %>
<% end %>
<%= stylesheet_link_tag :issue_checklist, :plugin => 'redmine_issue_checklist' %>
<%= javascript_include_tag 'jquery.klass.js', plugin: 'redmine_issue_checklist' %>
<%= javascript_include_tag 'issue_checklist.jquery.js', plugin: 'redmine_issue_checklist' %>
<% else %>
<%= javascript_include_tag 'issue_checklist.prototype.js', plugin: 'redmine_issue_checklist' %>
<% end %>
<%= stylesheet_link_tag :issue_checklist, plugin: 'redmine_issue_checklist' %>
<% end %>
40 changes: 20 additions & 20 deletions app/views/issues/_checklist_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<%= fields_for :issue, issue do |f| -%>
<div class="tabular">
<p id="issue_checklist_form">
<label><%=l(:label_issue_checklist_plural)%></label>
<span id="checklist_form_items"> </span>
<%= text_field_tag 'new_checklist', '',
:id => 'add_checklist_item_input' %>
<%= link_to '', '#',
:id => 'add_checklist_item_button',
:class => "tag-add icon icon-add" %>
<%= file_field_tag 'import_checklist',
:id => 'import_checklist_items_input',
:accept => 'text/plain' %>
<div class="tabular">
<p id="issue_checklist_form">
<label><%= l(:label_issue_checklist_plural) %></label>
<span id="checklist_form_items"> </span>
<%= text_field_tag 'new_checklist', '',
id: 'add_checklist_item_input' %>
<%= link_to '', '#',
id: 'add_checklist_item_button',
class: 'tag-add icon icon-add' %>
<%= file_field_tag 'import_checklist',
id: 'import_checklist_items_input',
accept: 'text/plain' %>

<%= javascript_tag "observeIssueChecklistField('checklist_form_items', 'add_checklist_item_input', 'add_checklist_item_button', 'import_checklist_items_input');" %>
<%= javascript_tag "createIssueChecklist(#{@issue.checklist.collect{|cli| {:is_done => cli.is_done, :subject => cli.subject, :id => cli.id}}.to_json.html_safe});" %>
</p>
</div>
<%= javascript_tag "observeIssueChecklistField('checklist_form_items', 'add_checklist_item_input', 'add_checklist_item_button', 'import_checklist_items_input');" %>
<%= javascript_tag "createIssueChecklist(#{@issue.checklist.collect { |cli| { is_done: cli.is_done, subject: cli.subject, id: cli.id } }.to_json.html_safe});" %>
</p>
</div>
<% end if User.current.allowed_to?(:edit_checklists, @project) -%>


<% content_for :header_tags do %>
<% if Redmine::VERSION::MAJOR == 3 || (Redmine::VERSION::MAJOR == 2 && Redmine::VERSION::MINOR >= 1) %>
<%= javascript_include_tag 'jquery.klass.js', :plugin => 'redmine_issue_checklist' %>
<%= javascript_include_tag 'issue_checklist.jquery.js', :plugin => 'redmine_issue_checklist' %>
<%= javascript_include_tag 'jquery.klass.js', plugin: 'redmine_issue_checklist' %>
<%= javascript_include_tag 'issue_checklist.jquery.js', plugin: 'redmine_issue_checklist' %>
<% else %>
<%= javascript_include_tag 'issue_checklist.prototype.js', :plugin => 'redmine_issue_checklist' %>
<%= javascript_include_tag 'issue_checklist.prototype.js', plugin: 'redmine_issue_checklist' %>
<% end %>
<%= stylesheet_link_tag :issue_checklist, :plugin => 'redmine_issue_checklist' %>
<%= stylesheet_link_tag :issue_checklist, plugin: 'redmine_issue_checklist' %>
<% end %>
10 changes: 5 additions & 5 deletions app/views/settings/_issue_checklist.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<%= check_box_tag 'settings[save_log]', 1, @settings[:save_log] %>
</p>

<% if Setting.issue_done_ratio == "issue_field" %>
<p>
<label><%= l(:label_checklist_done_ratio) %></label>
<%= check_box_tag 'settings[issue_done_ratio]', 1, @settings[:issue_done_ratio] %>
</p>
<% if Setting.issue_done_ratio == 'issue_field' %>
<p>
<label><%= l(:label_checklist_done_ratio) %></label>
<%= check_box_tag 'settings[issue_done_ratio]', 1, @settings[:issue_done_ratio] %>
</p>
<% end %>
Loading

0 comments on commit 7bbc784

Please sign in to comment.