]> source.dussan.org Git - redmine.git/commitdiff
Helper method for custom field title.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 25 Oct 2015 10:54:09 +0000 (10:54 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 25 Oct 2015 10:54:09 +0000 (10:54 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@14751 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/custom_field_enumerations_controller.rb
app/helpers/custom_fields_helper.rb
app/views/custom_field_enumerations/index.html.erb
app/views/custom_fields/edit.html.erb
app/views/custom_fields/new.html.erb
app/views/custom_fields/select_type.html.erb

index ba746d2b5616380ee26b2e8dbee6cfe32262ac17..212e57534b5feb61efed1bb9b1e49dcc741ac7ec 100644 (file)
@@ -22,6 +22,8 @@ class CustomFieldEnumerationsController < ApplicationController
   before_filter :find_custom_field
   before_filter :find_enumeration, :only => :destroy
 
+  helper :custom_fields
+
   def index
     @values = @custom_field.enumerations.order(:position)
   end
index 2de4c4037feec61ec5b7dba07c6e4998a87ae026..3ed68c12c7ae0c94fc4161d957fe74cb1b36f4f4 100644 (file)
@@ -51,6 +51,15 @@ module CustomFieldsHelper
     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
index 9ca9314eb2cb169cfe00d1e4e548f01996fd1849..9e9b67d3fa6aa6eb1a329f44922f15b57dab8d27 100644 (file)
@@ -1,6 +1,4 @@
-<%= 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 %>
index cd52e0075848fb68001be729f0c6f7ace0f59dec..0cbef1f7deaae70705eab3ab0e34f9a061489216 100644 (file)
@@ -1,6 +1,4 @@
-<%= 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 } %>
index 6c5809e7396f8c62f01e902be30c4d598e76d834..db422296b3c170cdceb5b5160fcff03f418599ec 100644 (file)
@@ -1,6 +1,4 @@
-<%= 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 } %>
index fd9c5a210f1dca4e776eb4d53061fd1512e95b33..084c9f3a76fa1d61a9f66f919e4242af7b36e11b 100644 (file)
@@ -1,5 +1,4 @@
-<%= 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 %>