Mercurial > hg > soundsoftware-site
diff app/helpers/custom_fields_helper.rb @ 523:0b6c82dead28 luisf
Merge from branch "cannam"
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Mon, 25 Jul 2011 14:23:37 +0100 |
parents | cbce1fd3b1b7 |
children | cbb26bc654de |
line wrap: on
line diff
--- a/app/helpers/custom_fields_helper.rb Mon Mar 28 18:17:06 2011 +0100 +++ b/app/helpers/custom_fields_helper.rb Mon Jul 25 14:23:37 2011 +0100 @@ -1,5 +1,5 @@ -# redMine - project management software -# Copyright (C) 2006 Jean-Philippe Lang +# Redmine - project management software +# Copyright (C) 2006-2011 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 @@ -37,7 +37,7 @@ field_id = "#{name}_custom_field_values_#{custom_field.id}" field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format) - case field_format.edit_as + case field_format.try(:edit_as) when "date" text_field_tag(field_name, custom_value.value, :id => field_id, :size => 10) + calendar_for(field_id) @@ -49,7 +49,7 @@ blank_option = custom_field.is_required? ? (custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') : '<option></option>' - select_tag(field_name, blank_option + options_for_select(custom_field.possible_values, custom_value.value), :id => field_id) + select_tag(field_name, blank_option + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value), :id => field_id) else text_field_tag(field_name, custom_value.value, :id => field_id) end @@ -68,11 +68,11 @@ custom_field_label_tag(name, custom_value) + custom_field_tag(name, custom_value) end - def custom_field_tag_for_bulk_edit(name, custom_field) + def custom_field_tag_for_bulk_edit(name, custom_field, projects=nil) field_name = "#{name}[custom_field_values][#{custom_field.id}]" field_id = "#{name}_custom_field_values_#{custom_field.id}" field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format) - case field_format.edit_as + case field_format.try(:edit_as) when "date" text_field_tag(field_name, '', :id => field_id, :size => 10) + calendar_for(field_id) @@ -83,7 +83,7 @@ [l(:general_text_yes), '1'], [l(:general_text_no), '0']]), :id => field_id) when "list" - select_tag(field_name, options_for_select([[l(:label_no_change_option), '']] + custom_field.possible_values), :id => field_id) + select_tag(field_name, options_for_select([[l(:label_no_change_option), '']] + custom_field.possible_values_options(projects)), :id => field_id) else text_field_tag(field_name, '', :id => field_id) end @@ -101,7 +101,18 @@ end # Return an array of custom field formats which can be used in select_tag - def custom_field_formats_for_select - Redmine::CustomFieldFormat.as_select + def custom_field_formats_for_select(custom_field) + Redmine::CustomFieldFormat.as_select(custom_field.class.customized_class.name) + end + + # Renders the custom_values in api views + def render_api_custom_values(custom_values, api) + api.array :custom_fields do + custom_values.each do |custom_value| + api.custom_field :id => custom_value.custom_field_id, :name => custom_value.custom_field.name do + api.value custom_value.value + end + end + end unless custom_values.empty? end end