cleanup: simplify the definition and calls to labelled_tabular_form_for. some of the :as and :url params that i left out might not be needed either.

pull/75/head
Martin Linkhorst 12 years ago
parent da88773fdf
commit c9597204aa
  1. 7
      app/helpers/application_helper.rb
  2. 2
      app/views/boards/edit.html.erb
  3. 2
      app/views/boards/new.html.erb
  4. 7
      app/views/custom_fields/edit.html.erb
  5. 2
      app/views/custom_fields/new.html.erb
  6. 2
      app/views/enumerations/edit.html.erb
  7. 2
      app/views/enumerations/new.html.erb
  8. 2
      app/views/groups/_general.html.erb
  9. 2
      app/views/issue_categories/new.html.erb
  10. 11
      app/views/issues/_edit.html.erb
  11. 10
      app/views/issues/new.html.erb
  12. 3
      app/views/news/edit.html.erb
  13. 3
      app/views/news/new.html.erb
  14. 3
      app/views/news/show.html.erb
  15. 2
      app/views/projects/_edit.html.erb
  16. 2
      app/views/projects/copy.html.erb
  17. 2
      app/views/projects/new.html.erb
  18. 2
      app/views/roles/edit.html.erb
  19. 2
      app/views/roles/new.html.erb
  20. 7
      app/views/timelog/edit.html.erb
  21. 2
      app/views/users/_general.html.erb
  22. 2
      app/views/users/new.html.erb
  23. 2
      app/views/versions/edit.html.erb
  24. 2
      app/views/versions/new.html.erb
  25. 2
      app/views/wiki/rename.html.erb

@ -933,11 +933,10 @@ module ApplicationHelper
content_tag("label", label_text)
end
def labelled_tabular_form_for(record_or_name_or_array, *args, &proc)
options = args.extract_options!
options[:html] ||= {}
def labelled_tabular_form_for(record, options = {}, &block)
options.reverse_merge!(:builder => TabularFormBuilder, :lang => current_language, :html => {})
options[:html][:class] = 'tabular' unless options[:html].has_key?(:class)
form_for(*(args << options.merge(:builder => TabularFormBuilder, :lang => current_language, :as => record_or_name_or_array)), &proc)
form_for(record, options, &block)
end
def back_url_hidden_field_tag

@ -1,6 +1,6 @@
<h2><%= l(:label_board) %></h2>
<%= labelled_tabular_form_for :board, [@project, @board] do |f| %>
<%= labelled_tabular_form_for [@project, @board] do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= submit_tag l(:button_save) %>
<% end %>

@ -1,6 +1,6 @@
<h2><%= l(:label_board_new) %></h2>
<%= labelled_tabular_form_for :board, [@project, Board.new] do |f| %>
<%= labelled_tabular_form_for [@project, Board.new] do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= submit_tag l(:button_create) %>
<% end %>

@ -2,10 +2,9 @@
&#187; <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.type %>
&#187; <%=h @custom_field.name %></h2>
<%= labelled_tabular_form_for :custom_field,
@custom_field,
:url => { :action => "edit",
:id => @custom_field } do |f| %>
<%= labelled_tabular_form_for @custom_field, :as => :custom_field,
:url => { :action => "edit",
:id => @custom_field } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<% end %>

@ -2,7 +2,7 @@
&#187; <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.type %>
&#187; <%= l(:label_custom_field_new) %></h2>
<%= labelled_tabular_form_for :custom_field, @custom_field, :url => { :action => "new" } do |f| %>
<%= labelled_tabular_form_for @custom_field, :as => :custom_field, :url => { :action => "new" } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= hidden_field_tag 'type', @custom_field.type %>
<%= submit_tag l(:button_save) %>

@ -1,6 +1,6 @@
<h2><%= link_to l(@enumeration.option_name), enumerations_path %> &#187; <%=h @enumeration %></h2>
<%= labelled_tabular_form_for(@enumeration) do %>
<%= labelled_tabular_form_for @enumeration do %>
<%= render :partial => 'form' %>
<%= submit_tag l(:button_save) %>
<% end %>

@ -1,6 +1,6 @@
<h2><%= link_to l(@enumeration.option_name), enumerations_path %> &#187; <%=l(:label_enumeration_new)%></h2>
<%= labelled_tabular_form_for(@enumeration) do %>
<%= labelled_tabular_form_for @enumeration do %>
<%= render :partial => 'form' %>
<%= submit_tag l(:button_create) %>
<% end %>

@ -1,4 +1,4 @@
<%= labelled_tabular_form_for :group, @group, :url => group_path(@group), :html => {:method => :put} do |f| %>
<%= labelled_tabular_form_for @group, :url => group_path(@group), :html => {:method => :put}, :as => :group do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<% end %>

@ -1,6 +1,6 @@
<h2><%=l(:label_issue_category_new)%></h2>
<%= labelled_tabular_form_for :category, [@project, @category] do |f| %>
<%= labelled_tabular_form_for [@project, @category], :as => :category do |f| %>
<%= render :partial => 'issue_categories/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
<% end %>

@ -1,9 +1,8 @@
<%= labelled_tabular_form_for :issue, @issue,
:url => {:action => 'update', :id => @issue},
:html => {:id => 'issue-form',
:class => nil,
:method => :put,
:multipart => true} do |f| %>
<%= labelled_tabular_form_for @issue, :html => {
:id => 'issue-form',
:class => nil,
:multipart => true
} do |f| %>
<%= error_messages_for 'issue', 'time_entry' %>
<div class="box">
<% if @edit_allowed || !@allowed_statuses.empty? %>

@ -1,12 +1,10 @@
<h2><%=l(:label_issue_new)%></h2>
<%= labelled_tabular_form_for :issue,
@issue,
:url => project_issues_path(@project),
:html => { :multipart => true,
:id => 'issue-form',
:class => 'tabular new-issue-form' } do |f| %>
<%= labelled_tabular_form_for [@project, @issue],
:html => { :multipart => true,
:id => 'issue-form',
:class => 'tabular new-issue-form' } do |f| %>
<%= error_messages_for 'issue' %>

@ -1,7 +1,6 @@
<h2><%=l(:label_news)%></h2>
<%= labelled_tabular_form_for :news, @news, :url => news_path(@news),
:html => { :id => 'news-form', :method => :put } do |f| %>
<%= labelled_tabular_form_for @news, :html => { :id => 'news-form' } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%= link_to l(:label_preview),

@ -1,7 +1,6 @@
<h2><%=l(:label_news_new)%></h2>
<%= labelled_tabular_form_for :news, @news, :url => project_news_index_path(@project),
:html => { :id => 'news-form' } do |f| %>
<%= labelled_tabular_form_for [@project, @news], :html => { :id => 'news-form' } do |f| %>
<%= render :partial => 'news/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
<%= link_to l(:label_preview),

@ -16,8 +16,7 @@
<% if authorize_for('news', 'edit') %>
<div id="edit-news" style="display:none;">
<%= labelled_tabular_form_for :news, @news, :url => news_path(@news),
:html => { :id => 'news-form', :method => :put } do |f| %>
<%= labelled_tabular_form_for @news, :html => { :id => 'news-form' } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("edit-news"); return false;' %>

@ -1,4 +1,4 @@
<%= labelled_tabular_form_for :project, @project, :url => project_path(@project), :html => {:method => (@project.new_record? ? :post : :put) } do |f| %>
<%= labelled_tabular_form_for @project do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<% end %>

@ -1,6 +1,6 @@
<h2><%=l(:label_project_new)%></h2>
<%= labelled_tabular_form_for :project, @project, :url => { :action => "copy" } do |f| %>
<%= labelled_tabular_form_for @project, :url => { :action => "copy" } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<fieldset class="box"><legend><%= l(:button_copy) %></legend>

@ -1,6 +1,6 @@
<h2><%=l(:label_project_new)%></h2>
<%= labelled_tabular_form_for :project, @project, :url => { :action => "create" } do |f| %>
<%= labelled_tabular_form_for @project do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%= javascript_tag "Form.Element.focus('project_name');" %>

@ -1,6 +1,6 @@
<h2><%= link_to l(:label_role_plural), roles_path %> &#187; <%=h @role.name %></h2>
<%= labelled_tabular_form_for(:role, @role, :html => { :id => 'role_form' }) do |f| %>
<%= labelled_tabular_form_for @role, :html => { :id => 'role_form' }, :as => :role do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<% end %>

@ -1,6 +1,6 @@
<h2><%= link_to l(:label_role_plural), roles_path %> &#187; <%=l(:label_role_new)%></h2>
<%= labelled_tabular_form_for(:role, @role, :html => {:id => 'role_form'}) do |f| %>
<%= labelled_tabular_form_for @role, :html => {:id => 'role_form'}, :as => :role do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
<% end %>

@ -1,11 +1,6 @@
<h2><%= l(:label_spent_time) %></h2>
<%= labelled_tabular_form_for(:time_entry, @time_entry, :url => {
:action => (@time_entry.new_record? ? 'create' : 'update'),
:id => @time_entry,
:project_id => @time_entry.project
},
:html => {:method => @time_entry.new_record? ? :post : :put}) do |f| %>
<%= labelled_tabular_form_for [@time_entry.project, @time_entry], :as => :time_entry do |f| %>
<%= error_messages_for 'time_entry' %>
<%= back_url_hidden_field_tag %>

@ -1,4 +1,4 @@
<%= labelled_tabular_form_for :user, @user, :url => { :controller => 'users', :action => "update", :tab => nil }, :html => { :method => :put, :class => nil } do |f| %>
<%= labelled_tabular_form_for @user, :url => { :controller => 'users', :action => "update", :tab => nil }, :html => { :method => :put, :class => nil }, :as => :user do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<% if @user.active? -%>
<p><label><%= check_box_tag 'send_information', 1, true %> <%= l(:label_send_information) %></label></p>

@ -1,6 +1,6 @@
<h2><%= link_to l(:label_user_plural), :controller => 'users', :action => 'index' %> &#187; <%=l(:label_user_new)%></h2>
<%= labelled_tabular_form_for :user, @user, :url => { :action => "create" }, :html => { :class => nil } do |f| %>
<%= labelled_tabular_form_for @user, :url => { :action => "create" }, :html => { :class => nil }, :as => :user do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<p><label><%= check_box_tag 'send_information', 1, true %> <%= l(:label_send_information) %></label></p>
<p>

@ -1,6 +1,6 @@
<h2><%=l(:label_version)%></h2>
<%= labelled_tabular_form_for :version, @version, :url => version_path(@version), :html => {:method => :put} do |f| %>
<%= labelled_tabular_form_for @version do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<% end %>

@ -1,6 +1,6 @@
<h2><%=l(:label_version_new)%></h2>
<%= labelled_tabular_form_for :version, @version, :url => project_versions_path(@project) do |f| %>
<%= labelled_tabular_form_for [@project, @version] do |f| %>
<%= render :partial => 'versions/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
<% end %>

@ -2,7 +2,7 @@
<%= error_messages_for 'page' %>
<%= labelled_tabular_form_for :wiki_page, @page, :url => { :action => 'rename' } do |f| %>
<%= labelled_tabular_form_for @page, :url => { :action => 'rename' }, :as => :wiki_page do |f| %>
<div class="box">
<p><%= f.text_field :title, :required => true, :size => 100 %></p>
<p><%= f.check_box :redirect_existing_links %></p>

Loading…
Cancel
Save