@@ -1,72 +1,72 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | class CustomFieldsController < ApplicationController |
|
18 | class CustomFieldsController < ApplicationController | |
19 | layout 'base' |
|
19 | layout 'base' | |
20 | before_filter :require_admin |
|
20 | before_filter :require_admin | |
21 |
|
21 | |||
22 | def index |
|
22 | def index | |
23 | list |
|
23 | list | |
24 | render :action => 'list' unless request.xhr? |
|
24 | render :action => 'list' unless request.xhr? | |
25 | end |
|
25 | end | |
26 |
|
26 | |||
27 | def list |
|
27 | def list | |
28 |
@custom_fields_by_type = CustomField.find(:all).group_by {|f| f. |
|
28 | @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name } | |
29 | @tab = params[:tab] || 'IssueCustomField' |
|
29 | @tab = params[:tab] || 'IssueCustomField' | |
30 | render :action => "list", :layout => false if request.xhr? |
|
30 | render :action => "list", :layout => false if request.xhr? | |
31 | end |
|
31 | end | |
32 |
|
32 | |||
33 | def new |
|
33 | def new | |
34 | case params[:type] |
|
34 | case params[:type] | |
35 | when "IssueCustomField" |
|
35 | when "IssueCustomField" | |
36 | @custom_field = IssueCustomField.new(params[:custom_field]) |
|
36 | @custom_field = IssueCustomField.new(params[:custom_field]) | |
37 | @custom_field.trackers = Tracker.find(params[:tracker_ids]) if params[:tracker_ids] |
|
37 | @custom_field.trackers = Tracker.find(params[:tracker_ids]) if params[:tracker_ids] | |
38 | when "UserCustomField" |
|
38 | when "UserCustomField" | |
39 | @custom_field = UserCustomField.new(params[:custom_field]) |
|
39 | @custom_field = UserCustomField.new(params[:custom_field]) | |
40 | when "ProjectCustomField" |
|
40 | when "ProjectCustomField" | |
41 | @custom_field = ProjectCustomField.new(params[:custom_field]) |
|
41 | @custom_field = ProjectCustomField.new(params[:custom_field]) | |
42 | else |
|
42 | else | |
43 | redirect_to :action => 'list' |
|
43 | redirect_to :action => 'list' | |
44 | return |
|
44 | return | |
45 | end |
|
45 | end | |
46 | if request.post? and @custom_field.save |
|
46 | if request.post? and @custom_field.save | |
47 | flash[:notice] = l(:notice_successful_create) |
|
47 | flash[:notice] = l(:notice_successful_create) | |
48 | redirect_to :action => 'list', :tab => @custom_field.type |
|
48 | redirect_to :action => 'list', :tab => @custom_field.type | |
49 | end |
|
49 | end | |
50 | @trackers = Tracker.find(:all, :order => 'position') |
|
50 | @trackers = Tracker.find(:all, :order => 'position') | |
51 | end |
|
51 | end | |
52 |
|
52 | |||
53 | def edit |
|
53 | def edit | |
54 | @custom_field = CustomField.find(params[:id]) |
|
54 | @custom_field = CustomField.find(params[:id]) | |
55 | if request.post? and @custom_field.update_attributes(params[:custom_field]) |
|
55 | if request.post? and @custom_field.update_attributes(params[:custom_field]) | |
56 | if @custom_field.is_a? IssueCustomField |
|
56 | if @custom_field.is_a? IssueCustomField | |
57 | @custom_field.trackers = params[:tracker_ids] ? Tracker.find(params[:tracker_ids]) : [] |
|
57 | @custom_field.trackers = params[:tracker_ids] ? Tracker.find(params[:tracker_ids]) : [] | |
58 | end |
|
58 | end | |
59 | flash[:notice] = l(:notice_successful_update) |
|
59 | flash[:notice] = l(:notice_successful_update) | |
60 | redirect_to :action => 'list', :tab => @custom_field.type |
|
60 | redirect_to :action => 'list', :tab => @custom_field.type | |
61 | end |
|
61 | end | |
62 | @trackers = Tracker.find(:all, :order => 'position') |
|
62 | @trackers = Tracker.find(:all, :order => 'position') | |
63 | end |
|
63 | end | |
64 |
|
64 | |||
65 | def destroy |
|
65 | def destroy | |
66 | @custom_field = CustomField.find(params[:id]).destroy |
|
66 | @custom_field = CustomField.find(params[:id]).destroy | |
67 | redirect_to :action => 'list', :tab => @custom_field.type |
|
67 | redirect_to :action => 'list', :tab => @custom_field.type | |
68 | rescue |
|
68 | rescue | |
69 | flash[:error] = "Unable to delete custom field" |
|
69 | flash[:error] = "Unable to delete custom field" | |
70 | redirect_to :action => 'list' |
|
70 | redirect_to :action => 'list' | |
71 | end |
|
71 | end | |
72 | end |
|
72 | end |
General Comments 0
You need to be logged in to leave comments.
Login now