From 57a22c346467ca6666d3a6dc9f0a9134447bd58c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 25 Oct 2015 10:54:09 +0000 Subject: [PATCH] Helper method for custom field title. git-svn-id: http://svn.redmine.org/redmine/trunk@14751 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/custom_field_enumerations_controller.rb | 2 ++ app/helpers/custom_fields_helper.rb | 9 +++++++++ app/views/custom_field_enumerations/index.html.erb | 4 +--- app/views/custom_fields/edit.html.erb | 4 +--- app/views/custom_fields/new.html.erb | 4 +--- app/views/custom_fields/select_type.html.erb | 3 +-- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/controllers/custom_field_enumerations_controller.rb b/app/controllers/custom_field_enumerations_controller.rb index ba746d2b5..212e57534 100644 --- a/app/controllers/custom_field_enumerations_controller.rb +++ b/app/controllers/custom_field_enumerations_controller.rb @@ -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 diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 2de4c4037..3ed68c12c 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -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 diff --git a/app/views/custom_field_enumerations/index.html.erb b/app/views/custom_field_enumerations/index.html.erb index 9ca9314eb..9e9b67d3f 100644 --- a/app/views/custom_field_enumerations/index.html.erb +++ b/app/views/custom_field_enumerations/index.html.erb @@ -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 %> diff --git a/app/views/custom_fields/edit.html.erb b/app/views/custom_fields/edit.html.erb index cd52e0075..0cbef1f7d 100644 --- a/app/views/custom_fields/edit.html.erb +++ b/app/views/custom_fields/edit.html.erb @@ -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 } %> diff --git a/app/views/custom_fields/new.html.erb b/app/views/custom_fields/new.html.erb index 6c5809e73..db422296b 100644 --- a/app/views/custom_fields/new.html.erb +++ b/app/views/custom_fields/new.html.erb @@ -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 } %> diff --git a/app/views/custom_fields/select_type.html.erb b/app/views/custom_fields/select_type.html.erb index fd9c5a210..084c9f3a7 100644 --- a/app/views/custom_fields/select_type.html.erb +++ b/app/views/custom_fields/select_type.html.erb @@ -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 %> -- 2.39.5