forked from Restream/redmine_issue_checklist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da4e35b
commit 7bbc784
Showing
25 changed files
with
381 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.