before_filter :find_custom_field
before_filter :find_enumeration, :only => :destroy
+ helper :custom_fields
+
def index
@values = @custom_field.enumerations.order(:position)
end
CUSTOM_FIELDS_TABS.map {|h| [l(h[:label]), h[:name]]}
end
+ def custom_field_title(custom_field)
+ items = []
+ items << [l(:label_custom_field_plural), custom_fields_path]
+ items << [l(custom_field.type_name), custom_fields_path(:tab => custom_field.class.name)] if custom_field
+ items << (custom_field.nil? || custom_field.new_record? ? l(:label_custom_field_new) : custom_field.name)
+
+ title(*items)
+ end
+
def render_custom_field_format_partial(form, custom_field)
partial = custom_field.format.form_partial
if partial
-<%= title [l(:label_custom_field_plural), custom_fields_path],
- [l(@custom_field.type_name), custom_fields_path(:tab => @custom_field.class.name)],
- @custom_field.name %>
+<%= custom_field_title @custom_field %>
<% if @custom_field.enumerations.any? %>
<%= form_tag custom_field_enumerations_path(@custom_field), :method => 'put' do %>
-<%= title [l(:label_custom_field_plural), custom_fields_path],
- [l(@custom_field.type_name), custom_fields_path(:tab => @custom_field.class.name)],
- @custom_field.name %>
+<%= custom_field_title @custom_field %>
<%= labelled_form_for :custom_field, @custom_field, :url => custom_field_path(@custom_field), :html => {:method => :put, :id => 'custom_field_form'} do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
-<%= title [l(:label_custom_field_plural), custom_fields_path],
- [l(@custom_field.type_name), custom_fields_path(:tab => @custom_field.class.name)],
- l(:label_custom_field_new) %>
+<%= custom_field_title @custom_field %>
<%= labelled_form_for :custom_field, @custom_field, :url => custom_fields_path, :html => {:id => 'custom_field_form'} do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
-<%= title [l(:label_custom_field_plural), custom_fields_path],
- l(:label_custom_field_new) %>
+<%= custom_field_title @custom_field %>
<% selected = 0 %>
<%= form_tag new_custom_field_path, :method => 'get' do %>