Permalink
Browse files

created status change handler

  • Loading branch information...
1 parent 8c8fd17 commit a8e63550d0941d6c6ab20c87b0438d6c756a39c0 @edtsech committed Oct 17, 2009
Showing with 78 additions and 45 deletions.
  1. +3 −7 .gitignore
  2. +21 −28 app/views/issue_statuses/issue_closed_list.html.erb
  3. +8 −1 init.rb
  4. +46 −9 lib/issue_closed.rb
View
@@ -1,9 +1,5 @@
-$ cat .gitignore
-
-# Can ignore specific files
.DS_Store
-# Use wildcards as well
-
-# Can also ignore all directories and files in a directory.
-tmp/**/*
+tmp/**/*
+log/*.log
+config/database.yml
@@ -38,31 +38,24 @@
<fieldset class="box">
<legend >Issue Closed Plugin Settings</legend>
- <form>
- <table>
- <tr>
- <td>
- <label for="issue-status-closed">Select closed issue status</label>
- </td>
- <td>
- <select id="issue-status-closed">
- <% for status in @issue_statuses %>
- <option value="option1"><%= status.name %></option>
- <% end %>
- </select>
- </td>
- </tr>
- <td>
- <label for="issue-status-closed">Select resolved issue status</label>
- </td>
- <td>
- <select id="issue-status-closed">
- <% for status in @issue_statuses %>
- <option value="option1"><%= status.name %></option>
- <% end %>
- </select>
- </td>
- </table>
- <input type="submit"></submit>
- </form>
-</fieldset>
+ <% form_for :issue_statuses, :url => { :action => :update_issue_closed } do |form| %>
+ <label for="issue-status-resolved">Select resolved issue status</label>
+ <select id="issue-status-resolved" name="resolved">
+ <% for status in @issue_statuses %>
+ <option value="<%= status.id %>" <%= status.state == false ? 'selected="selected"' : '' %>><%= status.name %></option>
+ <% end %>
+ </select>
+ <label for="issue-status-closed">Select closed issue status</label>
+ <select id="issue-status-closed" name="closed">
+ <% for status in @issue_statuses %>
+ <option value="<%= status.id %>" <%= status.state ? 'selected="selected"' : '' %>><%= status.name %></option>
+ <% end %>
+ </select>
+ <input type="submit"></submit>
+ <% end %>
+</fieldset>
+<style type="text/css" media="screen">
+ select#issue-status-resolved, select#issue-status-closed{
+ margin-right: 20px;
+ }
+</style>
View
@@ -6,4 +6,11 @@
author 'Equelli'
description 'This is a plugin for Redmine'
version '0.0.1'
-end
+ #permission :issue_closed, { :example => :say_hello }
+
+ menu :project_menu, :issue_closed, { :controller => 'example', :action => 'say_hello' }, :caption => 'Sample'
+
+ project_module "issue_closed" do
+ permission :run_autoclose, { :issue => :update }
+ end
+end
View
@@ -10,28 +10,64 @@ module IssueClosed
# self.status.is_resolved?
# end
#end
-
+
module IssueStatusesController
- module InstanceMethods
- end
-
def self.included base
- base.send :include, InstanceMethods
base.class_eval do
- alias _list list
+ alias _list list
+
def index
list
- render :template => 'issue_statuses/issue_closed_list' #'list' unless request.xhr?
end
def list
- _list
- render :template => 'issue_statuses/issue_closed_list' #'list' unless request.xhr?
+ collect_issue_statuses
+ render :template => 'issue_statuses/issue_closed_list'
+ end
+
+ def update_issue_closed
+ (statuses = IssueStatus.all).each do |status|
+ case status.id
+ when params[:closed].to_i
+ status.state = true
+ when params[:resolved].to_i
+ status.state = false
+ else
+ status.state = nil
+ end
+ status.save!
+ end
+ redirect_to :action => :list
+ end
+ protected
+ def collect_issue_statuses
+ @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
end
end
end
end
+
+ module IssuesController
+ def self.included base
+ base.class_eval do
+ alias _edit edit
+
+ def edit
+ status_before_update = @issue.status
+ _edit
+ if request.post? and \
+ not (@issue.project.enabled_modules.detect { |enabled_module| enabled_module.name ==
+ 'issue_closed' }) == nil and \
+ status_before_update != @issue.status and \
+ @issue.status.state == false
+
+ ###
+ end
+ end
+ end
+ end
+ end
end
#class IssueStatus
@@ -60,4 +96,5 @@ def list
end
IssueStatusesController.send :include, IssueClosed::IssueStatusesController
+ IssuesController.send :include, IssueClosed::IssuesController
end

0 comments on commit a8e6355

Please sign in to comment.