diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2006-07-29 09:32:58 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2006-07-29 09:32:58 +0000 |
commit | 310a0f924aa0092228a173cc71864af4ce574f1f (patch) | |
tree | 9885aa2d18d4cf99f6d00100e260bbe56cf255f5 /redmine/app/helpers/custom_fields_helper.rb | |
parent | 7e57db1edbad635fcbe1e3ae3294d24e1a43046f (diff) | |
download | redmine-310a0f924aa0092228a173cc71864af4ce574f1f.tar.gz redmine-310a0f924aa0092228a173cc71864af4ce574f1f.zip |
0.3 unstable
git-svn-id: http://redmine.rubyforge.org/svn/trunk@12 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'redmine/app/helpers/custom_fields_helper.rb')
-rw-r--r-- | redmine/app/helpers/custom_fields_helper.rb | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/redmine/app/helpers/custom_fields_helper.rb b/redmine/app/helpers/custom_fields_helper.rb index 4e3aea50f..10cb1bb94 100644 --- a/redmine/app/helpers/custom_fields_helper.rb +++ b/redmine/app/helpers/custom_fields_helper.rb @@ -16,21 +16,49 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module CustomFieldsHelper
- def custom_field_tag(custom_value)
-
- custom_field = custom_value.custom_field
-
- field_name = "custom_fields[#{custom_field.id}]"
-
- case custom_field.typ
- when 0 .. 2
- text_field_tag field_name, custom_value.value
- when 3
- check_box field_name
- when 4
- select_tag field_name,
- options_for_select(custom_field.possible_values.split('|'),
- custom_value.value)
- end
- end +
+ def custom_field_tag(custom_value)
+ custom_field = custom_value.custom_field
+ field_name = "custom_fields[#{custom_field.id}]"
+ case custom_field.field_format
+ when "string", "int", "date"
+ text_field_tag field_name, custom_value.value
+ when "text"
+ text_area_tag field_name, custom_value.value, :cols => 60, :rows => 3
+ when "bool"
+ check_box_tag(field_name, "1", custom_value.value == "1") +
+ hidden_field_tag(field_name, "0")
+ when "list"
+ select_tag field_name,
+ "<option></option>" + options_for_select(custom_field.possible_values.split('|'),
+ custom_value.value)
+ end
+ end
+
+ def custom_field_label_tag(custom_value)
+ content_tag "label", custom_value.custom_field.name +
+ (custom_value.custom_field.is_required? ? " <span class=\"required\">*</span>" : "")
+ end
+
+ def custom_field_tag_with_label(custom_value)
+ case custom_value.custom_field.field_format
+ when "bool"
+ custom_field_tag(custom_value) + " " + custom_field_label_tag(custom_value)
+ else
+ custom_field_label_tag(custom_value) + "<br />" + custom_field_tag(custom_value)
+ end
+ end
+
+ def show_value(custom_value)
+ case custom_value.custom_field.field_format
+ when "bool"
+ l_YesNo(custom_value.value == "1")
+ else
+ custom_value.value
+ end
+ end
+
+ def custom_field_formats_for_select
+ CustomField::FIELD_FORMATS.keys.collect { |k| [ l(CustomField::FIELD_FORMATS[k]), k ] }
+ end end |