From ba7cf9c3ce6c970a2ecb49d1f4ab276a071ada40 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 15 Nov 2009 15:22:55 +0000 Subject: [PATCH] Adds custom fields for versions (#4219). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3064 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/versions_controller.rb | 2 ++ app/helpers/custom_fields_helper.rb | 1 + app/models/version.rb | 1 + app/models/version_custom_field.rb | 22 ++++++++++++++++++++++ app/views/versions/_form.rhtml | 4 ++++ app/views/versions/_overview.rhtml | 7 +++++++ 6 files changed, 37 insertions(+) create mode 100644 app/models/version_custom_field.rb diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index 6513d080c..7be042d9f 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -21,6 +21,8 @@ class VersionsController < ApplicationController before_filter :find_project, :only => :close_completed before_filter :authorize + helper :custom_fields + def show end diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 13348546b..e11f7ccfe 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -21,6 +21,7 @@ module CustomFieldsHelper tabs = [{:name => 'IssueCustomField', :partial => 'custom_fields/index', :label => :label_issue_plural}, {:name => 'TimeEntryCustomField', :partial => 'custom_fields/index', :label => :label_spent_time}, {:name => 'ProjectCustomField', :partial => 'custom_fields/index', :label => :label_project_plural}, + {:name => 'VersionCustomField', :partial => 'custom_fields/index', :label => :label_version_plural}, {:name => 'UserCustomField', :partial => 'custom_fields/index', :label => :label_user_plural}, {:name => 'GroupCustomField', :partial => 'custom_fields/index', :label => :label_group_plural}, {:name => 'TimeEntryActivityCustomField', :partial => 'custom_fields/index', :label => TimeEntryActivity::OptionName}, diff --git a/app/models/version.rb b/app/models/version.rb index dc72e8212..e63ed46cf 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -19,6 +19,7 @@ class Version < ActiveRecord::Base before_destroy :check_integrity belongs_to :project has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id' + acts_as_customizable acts_as_attachable :view_permission => :view_files, :delete_permission => :manage_files diff --git a/app/models/version_custom_field.rb b/app/models/version_custom_field.rb new file mode 100644 index 000000000..400caf0df --- /dev/null +++ b/app/models/version_custom_field.rb @@ -0,0 +1,22 @@ +# Redmine - project management software +# Copyright (C) 2006-2009 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class VersionCustomField < CustomField + def type_name + :label_version_plural + end +end diff --git a/app/views/versions/_form.rhtml b/app/views/versions/_form.rhtml index dfdbc18fe..13579b8b6 100644 --- a/app/views/versions/_form.rhtml +++ b/app/views/versions/_form.rhtml @@ -6,4 +6,8 @@

<%= f.select :status, Version::VERSION_STATUSES.collect {|s| [l("version_status_#{s}"), s]} %>

<%= f.text_field :wiki_page_title, :label => :label_wiki_page, :size => 60, :disabled => @project.wiki.nil? %>

<%= f.text_field :effective_date, :size => 10 %><%= calendar_for('version_effective_date') %>

+ +<% @version.custom_field_values.each do |value| %> +

<%= custom_field_tag_with_label :version, value %>

+<% end %> diff --git a/app/views/versions/_overview.rhtml b/app/views/versions/_overview.rhtml index 724f9f923..550cf3e78 100644 --- a/app/views/versions/_overview.rhtml +++ b/app/views/versions/_overview.rhtml @@ -5,6 +5,13 @@ <% end %>

<%=h version.description %>

+ <% if version.fixed_issues.count > 0 %> <%= progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '40em', :legend => ('%0.0f%' % version.completed_pourcent)) %> -- 2.39.5