Commit a65775c734571934f3acf2c113e628685f46d95b

Authored by MoisesMachado
1 parent 9b47f92b

ActionItem121: changed all the submit button of the form to conform with the sta…

…ndard of using the button_bar and the submit_button helpers 


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1198 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/design_blocks/list_block/views/edit.rhtml
@@ -16,5 +16,7 @@ @@ -16,5 +16,7 @@
16 <%= text_field 'design_block', 'limit_number'%> 16 <%= text_field 'design_block', 'limit_number'%>
17 </p> 17 </p>
18 18
19 - <%= submit_tag _('Save') %> 19 + <% button_bar do %>
  20 + <%= submit_button('save', _('Save')) %>
  21 + <% end %>
20 <% end %> 22 <% end %>
app/design_blocks/profile_info_block/views/edit.rhtml
@@ -6,5 +6,7 @@ @@ -6,5 +6,7 @@
6 <%= text_field 'design_block', 'title'%> 6 <%= text_field 'design_block', 'title'%>
7 </p> 7 </p>
8 8
9 - <%= submit_tag _('Save') %> 9 + <% button_bar do %>
  10 + <%= submit_button('save', _('Save')) %>
  11 + <% end %>
10 <% end %> 12 <% end %>
app/design_blocks/view_article/views/edit.rhtml
@@ -11,5 +11,7 @@ @@ -11,5 +11,7 @@
11 <%= select 'design_block', 'article_id', @articles.map{|a|[a.full_name, a.id]} %> 11 <%= select 'design_block', 'article_id', @articles.map{|a|[a.full_name, a.id]} %>
12 </p> 12 </p>
13 13
14 - <%= submit_tag _('Save') %> 14 + <% button_bar do %>
  15 + <%= submit_button('save', _('Save')) %>
  16 + <% end %>
15 <% end %> 17 <% end %>
app/helpers/application_helper.rb
@@ -179,15 +179,8 @@ module ApplicationHelper @@ -179,15 +179,8 @@ module ApplicationHelper
179 def labelled_form_field(label, field_html, field_id = nil) 179 def labelled_form_field(label, field_html, field_id = nil)
180 NoosferoFormBuilder::output_field(label, field_html, field_id) 180 NoosferoFormBuilder::output_field(label, field_html, field_id)
181 end 181 end
182 - alias_method :display_form_field, :labelled_form_field  
183 -  
184 - # FIXME: do not use window.history on the cancel button, instead go to the page where the user come from  
185 - def display_submit_tag(label, options = {})  
186 - cancel_button = ''  
187 - cancel_button = "<input type='button' class='bt_cancel' value='" + _('Cancel') + "' onclick='window.history.back()'> " if options[:with_cancel]  
188 - content_tag('p', submit_tag( label, :class => 'submit') + cancel_button, :class => 'submitline')  
189 - end  
190 182
  183 + alias_method :display_form_field, :labelled_form_field
191 184
192 def labelled_form_for(name, object = nil, options = {}, &proc) 185 def labelled_form_for(name, object = nil, options = {}, &proc)
193 object ||= instance_variable_get("@#{name}") 186 object ||= instance_variable_get("@#{name}")
@@ -278,7 +271,13 @@ module ApplicationHelper @@ -278,7 +271,13 @@ module ApplicationHelper
278 end 271 end
279 272
280 def submit_button(type, label, html_options = {}) 273 def submit_button(type, label, html_options = {})
281 - design_display_button_submit(type, label, { :class => 'with_text' }.merge(html_options)) 274 + bt_cancel = html_options[:cancel] ? "<input type='button' class='button bt_cancel' value='" + _('Cancel') + "' onclick='document.location.href = \"#{url_for html_options.delete(:cancel)}\"'> " : ''
  275 +
  276 + html_options[:class] = [html_options[:class], 'submit'].compact.join(' ')
  277 +
  278 + bt_submit = design_display_button_submit(type, label, { :class => 'with_text' }.merge(html_options))
  279 + content_tag('p', bt_submit + bt_cancel, :class => 'submitline')
  280 +
282 end 281 end
283 282
284 def button_to_function(type, label, js_code, html_options = {}) 283 def button_to_function(type, label, js_code, html_options = {})
app/views/account/forgot_password.rhtml
@@ -8,7 +8,9 @@ @@ -8,7 +8,9 @@
8 <%= labelled_form_field(_('Username'), (f.text_field :login)) %> 8 <%= labelled_form_field(_('Username'), (f.text_field :login)) %>
9 <%= labelled_form_field(_('E-mail'), (f.text_field :email)) %> 9 <%= labelled_form_field(_('E-mail'), (f.text_field :email)) %>
10 <div> 10 <div>
11 - <%= submit_tag _('Send change password procedure by e-mail') %> 11 + <% button_bar do %>
  12 + <%= submit_button('send', _('Send change password procedure by e-mail')) %>
  13 + <% end %>
12 </div> 14 </div>
13 15
14 <% end %> 16 <% end %>
app/views/account/login.rhtml
@@ -6,7 +6,9 @@ @@ -6,7 +6,9 @@
6 6
7 <%= display_form_field(_('Password'), password_field_tag(:password) ) %> 7 <%= display_form_field(_('Password'), password_field_tag(:password) ) %>
8 8
9 -<%= display_submit_tag 'Log in' %> 9 +<% button_bar do %>
  10 + <%= submit_button( 'login', _('Log in') )%>
  11 +<% end %>
10 12
11 <% end %> 13 <% end %>
12 14
app/views/account/new_password.rhtml
@@ -10,6 +10,8 @@ @@ -10,6 +10,8 @@
10 10
11 <%= labelled_form_field(_('Enter new password'), (f.password_field :password)) %> 11 <%= labelled_form_field(_('Enter new password'), (f.password_field :password)) %>
12 <%= labelled_form_field(_('Confirm the new password'), (f.password_field :password_confirmation)) %> 12 <%= labelled_form_field(_('Confirm the new password'), (f.password_field :password_confirmation)) %>
13 - <%= submit_tag _('Change password') %> 13 + <% button_bar do %>
  14 + <%= submit_button('change_password', _('Change password')) %>
  15 + <% end %>
14 16
15 <% end %> 17 <% end %>
app/views/account/signup.rhtml
@@ -18,5 +18,7 @@ @@ -18,5 +18,7 @@
18 </p> 18 </p>
19 <% end %> 19 <% end %>
20 20
21 -<%= display_submit_tag _('Sign up') %> 21 +<% button_bar do %>
  22 + <%= submit_button('save', _('Sign up'), :cancel => {:action => 'index'}) %>
  23 +<% end %>
22 <% end -%> 24 <% end -%>
app/views/categories/_form.rhtml
@@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
13 <%= select_color_for_category %> 13 <%= select_color_for_category %>
14 14
15 <%= f.text_field 'name' %> 15 <%= f.text_field 'name' %>
16 - <%= display_submit_tag _('Save') %>  
17 - <%= link_to _('Cancel'), :action => 'index' %> 16 + <% button_bar do %>
  17 + <%= submit_button('save', _('Save'), :cancel => {:action => 'index'}) %>
  18 + <% end%>
18 <% end %> 19 <% end %>
app/views/cms/edit.rhtml
@@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
13 <%# TODO display the tooltip (title below) in a directly visible way %> 13 <%# TODO display the tooltip (title below) in a directly visible way %>
14 <%= f.text_field('tag_list', :size => 64, :title => _('Separate tags with commas')) %> 14 <%= f.text_field('tag_list', :size => 64, :title => _('Separate tags with commas')) %>
15 15
16 - <%= design_display_button_submit('save', _('Save')) %>  
17 - <%= design_display_button('cancel', _('Cancel'), :action => (@article.parent ? 'view' : 'index'), :id => @article.parent) %> 16 + <% button_bar do %>
  17 + <%= submit_button('save', _('Save'), :cancel => [:action => (@article.parent ? 'view' : 'index')], :id => @article.parent) %>
  18 + <% end %>
18 <% end %> 19 <% end %>
app/views/consumed_products/new.rhtml
@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 <% form_for :consumption, @consumption do |f| %> 5 <% form_for :consumption, @consumption do |f| %>
6 <p> <%= _('Product:') %> <%= f.select "product_category_id", ProductCategory.find(:all).map{|pc| [pc.name, pc.id]} %></p> 6 <p> <%= _('Product:') %> <%= f.select "product_category_id", ProductCategory.find(:all).map{|pc| [pc.name, pc.id]} %></p>
7 <p> <%= _('Aditional specifications:') %><br> <%= f.text_area "aditional_specifications" %> </p> 7 <p> <%= _('Aditional specifications:') %><br> <%= f.text_area "aditional_specifications" %> </p>
8 - <%= submit_tag _('Add product') %>  
9 - <%= link_to _('Cancel'), :action => 'index' %> 8 + <% button_bar do %>
  9 + <%= submit_button('add', _('Add product'), :cancel => {:action => 'index'}) %>
  10 + <% end %>
10 <% end %> 11 <% end %>
app/views/content_viewer/_comment_form.rhtml
@@ -15,5 +15,7 @@ @@ -15,5 +15,7 @@
15 15
16 <%= labelled_form_field(_('Title'), text_field(:comment, :title)) %> 16 <%= labelled_form_field(_('Title'), text_field(:comment, :title)) %>
17 <%= labelled_form_field(_('Enter your comment'), text_area(:comment, :body)) %> 17 <%= labelled_form_field(_('Enter your comment'), text_area(:comment, :body)) %>
18 - <%= submit_tag _('Post comment') %> 18 + <% button_bar do %>
  19 + <%= submit_button('post', _('Post comment')) %>
  20 + <% end %>
19 <% end %> 21 <% end %>
app/views/enterprise_editor/edit.rhtml
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 4
5 <% form_tag :action => 'update', :id => @enterprise do %> 5 <% form_tag :action => 'update', :id => @enterprise do %>
6 <%= render :partial => 'form' %> 6 <%= render :partial => 'form' %>
7 -<p><%= submit_tag _('Update') %>  
8 -<%= link_to _('Cancel'), :action => 'index' %></p> 7 + <% button_bar do %>
  8 + <%= submit_button('save', _('Update'), :cancel => {:action => 'index'}) %>
  9 + <% end %>
9 <% end %> 10 <% end %>
app/views/enterprise_registration/basic_information.rhtml
@@ -29,8 +29,7 @@ @@ -29,8 +29,7 @@
29 <%= f.select('region_id', @regions) %> 29 <%= f.select('region_id', @regions) %>
30 30
31 <% button_bar do %> 31 <% button_bar do %>
32 - <%= submit_button('next', _('Next')) %>  
33 - <%= button 'cancel', _('Cancel'), :action => 'index' %> 32 + <%= submit_button('next', _('Next'), :cancel => {:action => 'index'}) %>
34 <% end %> 33 <% end %>
35 34
36 <% end %> 35 <% end %>
app/views/enterprise_validation/details.rhtml
@@ -15,7 +15,9 @@ @@ -15,7 +15,9 @@
15 <p><%= _('If this enterprise passes the criteria to be considered an solidarity enconomy enterprise, you can approve it by click the button below.') %></p> 15 <p><%= _('If this enterprise passes the criteria to be considered an solidarity enconomy enterprise, you can approve it by click the button below.') %></p>
16 16
17 <% form_tag :action => 'approve', :id => @pending.code do %> 17 <% form_tag :action => 'approve', :id => @pending.code do %>
18 -<%= submit_tag _('Approve') %> 18 + <% button_bar do %>
  19 + <%= submit_button('approve', _('Approve')) %>
  20 + <% end %>
19 <% end %> 21 <% end %>
20 22
21 <h4><%= _('Reject') %></h4> 23 <h4><%= _('Reject') %></h4>
@@ -25,6 +27,8 @@ @@ -25,6 +27,8 @@
25 <% form_tag :action => 'reject', :id => @pending.code do %> 27 <% form_tag :action => 'reject', :id => @pending.code do %>
26 <%= labelled_form_field(_('Please provide an explanation for the rejection. This explanation will be sent to the requestor (required).'), text_area_tag('reject_explanation'))%> 28 <%= labelled_form_field(_('Please provide an explanation for the rejection. This explanation will be sent to the requestor (required).'), text_area_tag('reject_explanation'))%>
27 <div> 29 <div>
28 - <%= submit_tag _('Reject') %> 30 + <% button_bar do %>
  31 + <%= submit_button('reject', _('Reject')) %>
  32 + <% end %>
29 </div> 33 </div>
30 <% end %> 34 <% end %>
app/views/environment_role_manager/affiliate.rhtml
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <% form_tag( {:action => 'give_role'}, {:method => :post}) do %> 3 <% form_tag( {:action => 'give_role'}, {:method => :post}) do %>
4 <%= select_tag 'role', options_for_select(@roles.map{|r|[r.name,r.id]}) %> 4 <%= select_tag 'role', options_for_select(@roles.map{|r|[r.name,r.id]}) %>
5 <%= hidden_field_tag 'person', current_user.person.id %> 5 <%= hidden_field_tag 'person', current_user.person.id %>
6 - <%= submit_tag _('Affiliate') %> 6 + <% button_bar do %>
  7 + <%= submit_button('affiliate', _('Affiliate', :cancel => {:action => 'index'}) %>
  8 + <% end %>
7 <% end %> 9 <% end %>
8 -  
9 -<%= link_to _('Back'), :action => 'index' %>  
app/views/environment_role_manager/change_role.rhtml
@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 <% end %> 8 <% end %>
9 <%= hidden_field_tag 'person', @admin.id %> 9 <%= hidden_field_tag 'person', @admin.id %>
10 10
11 - <%= display_submit_tag _('Save changes') %>  
12 - <%= link_to _('Cancel'), :action => 'index' %> 11 + <% button_bar do %>
  12 + <%= submit_button('save', _('Save changes'), :cancel => {:action => 'index'}) %>
  13 + <% end %>
13 <% end %> 14 <% end %>
app/views/environment_role_manager/make_admin.rhtml
@@ -9,5 +9,7 @@ @@ -9,5 +9,7 @@
9 <% @roles.each do |r| %> 9 <% @roles.each do |r| %>
10 <%= labelled_form_field(r.name, (check_box_tag "roles[]", r.id)) %> 10 <%= labelled_form_field(r.name, (check_box_tag "roles[]", r.id)) %>
11 <% end %> 11 <% end %>
12 -<%= display_submit_tag _('Make') %> 12 + <% button_bar do %>
  13 + <%= submit_button( 'save', _('Make'), :cancel => {:action => 'index'} ) %>
  14 + <% end %>
13 <% end %> 15 <% end %>
app/views/features/_features_table.rhtml
@@ -12,7 +12,9 @@ @@ -12,7 +12,9 @@
12 <%= labelled_form_field(_('Organization Approval Method'), select_organization_approval_method('environment', 'organization_approval_method')) %> 12 <%= labelled_form_field(_('Organization Approval Method'), select_organization_approval_method('environment', 'organization_approval_method')) %>
13 13
14 <div> 14 <div>
15 - <%= submit_tag _('Save changes') %> 15 + <% button_bar do %>
  16 + <%= submit_button('save', _('Save changes')) %>
  17 + <% end %>
16 </div> 18 </div>
17 19
18 <% end %> 20 <% end %>
app/views/manage_products/_form.rhtml
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 <%= display_form_field( _('Description:'), f.text_area(:description) ) %> 6 <%= display_form_field( _('Description:'), f.text_area(:description) ) %>
7 <%= display_form_field( _('Image:'), file_field_tag( "product[image_builder][uploaded_data]" ) ) %> 7 <%= display_form_field( _('Image:'), file_field_tag( "product[image_builder][uploaded_data]" ) ) %>
8 <%= display_form_field( _('category:'), f.select( :product_category_id,ProductCategory.find(:all).map{|pc|[pc.name,pc.id]}, {:include_blank => true} )) %> 8 <%= display_form_field( _('category:'), f.select( :product_category_id,ProductCategory.find(:all).map{|pc|[pc.name,pc.id]}, {:include_blank => true} )) %>
9 - <%= display_submit_tag(mode == 'new' ? _('Create product') : _('Save changes')) %>  
10 - <%= link_to _('Cancel'), :action => 'index' %> 9 + <% button_bar do %>
  10 + <%= submit_button('save', (mode == 'new' ? _('Create product') : _('Save changes')), :cancel => {:action => 'index'} ) %>
  11 + <% end %>
11 <% end %> 12 <% end %>
app/views/profile_editor/change_image.rhtml
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 :html => { :multipart => true }, 2 :html => { :multipart => true },
3 :url => { :action => 'change_image'} do |f| %> 3 :url => { :action => 'change_image'} do |f| %>
4 <%= display_form_field(_('Image'), f.file_field( :uploaded_data, { :onchange => 'updateImg(this.value)' } ) ) %> 4 <%= display_form_field(_('Image'), f.file_field( :uploaded_data, { :onchange => 'updateImg(this.value)' } ) ) %>
5 - <%= display_submit_tag(_('Upload')) %>  
6 - <%= link_to _('Cancel'), :action => 'index' %> 5 + <% button_bar do %>
  6 + <%= submit_button('save', _('Upload'), :cancel => {:action => 'index'}) %>
  7 + <% end %>
7 <% end %> 8 <% end %>
app/views/profile_editor/organization_info.rhtml
@@ -5,5 +5,7 @@ @@ -5,5 +5,7 @@
5 <%= f.text_field(:legal_form) %> 5 <%= f.text_field(:legal_form) %>
6 <%= f.text_field(:economic_activity) %> 6 <%= f.text_field(:economic_activity) %>
7 <%= f.text_area(:management_information) %> 7 <%= f.text_area(:management_information) %>
8 - <%= display_submit_tag(_('Save'), :with_cancel => true) %> 8 + <% button_bar do %>
  9 + <%= submit_button('save' , _('Save'), :cancel => {:action => 'index'}) %>
  10 + <% end %>
9 <% end %> 11 <% end %>
app/views/profile_editor/person_info.rhtml
@@ -9,6 +9,8 @@ @@ -9,6 +9,8 @@
9 <%= f.text_field(:city) %> 9 <%= f.text_field(:city) %>
10 <%= f.text_field(:state) %> 10 <%= f.text_field(:state) %>
11 <%= f.text_field(:country) %> 11 <%= f.text_field(:country) %>
12 - <%= display_submit_tag _('Save') %> 12 + <% button_bar do %>
  13 + <%= submit_button('save', _('Save'), :cancel => {:action => 'index'}) %>
  14 + <% end %>
13 15
14 <% end %> 16 <% end %>
app/views/profile_members/affiliate.rhtml
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <% form_tag( {:action => 'give_role'}, {:method => :post}) do %> 3 <% form_tag( {:action => 'give_role'}, {:method => :post}) do %>
4 <%= select_tag 'role', options_for_select(@roles.map{|r|[r.name,r.id]}) %> 4 <%= select_tag 'role', options_for_select(@roles.map{|r|[r.name,r.id]}) %>
5 <%= hidden_field_tag 'person', current_user.person.id %> 5 <%= hidden_field_tag 'person', current_user.person.id %>
6 - <%= submit_tag _('Affiliate') %> 6 + <% button_bar do %>
  7 + <%= submit_button('affiliate', _('Affiliate'), :cancel => {:action => 'index'}) %>
  8 + <% end %>
7 <% end %> 9 <% end %>
8 -  
9 -<%= link_to _('Back'), :action => 'index' %>  
app/views/profile_members/change_role.rhtml
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 <% end %> 9 <% end %>
10 <%= hidden_field_tag 'person', @member.id %> 10 <%= hidden_field_tag 'person', @member.id %>
11 11
12 - <%= display_submit_tag _('Save changes') %>  
13 - <%= link_to _('Cancel'), :action => 'index' %> 12 + <% button_bar do %>
  13 + <%= submit_button('save', _('Save changes'), :cancel => {:action => 'index'}) %>
  14 + <% end %>
14 <% end %> 15 <% end %>
app/views/region_validators/_search.rhtml
@@ -5,7 +5,9 @@ @@ -5,7 +5,9 @@
5 <%= item.name %> 5 <%= item.name %>
6 <% form_tag :action => 'add', :id => @region do %> 6 <% form_tag :action => 'add', :id => @region do %>
7 <%= hidden_field_tag :validator_id, item.id %> 7 <%= hidden_field_tag :validator_id, item.id %>
8 - <%= submit_tag _('Adicionar') %> 8 + <% button_bar do %>
  9 + <%= submit_button('add', _('Add')) %>
  10 + <% end %>
9 <% end %> 11 <% end %>
10 </li> 12 </li>
11 <% end %> 13 <% end %>
app/views/region_validators/region.rhtml
@@ -19,7 +19,9 @@ @@ -19,7 +19,9 @@
19 19
20 <% form_tag({}, { :method => 'get' }) do %> 20 <% form_tag({}, { :method => 'get' }) do %>
21 <%= text_field_tag :search, nil, :id => 'search_validator' %> 21 <%= text_field_tag :search, nil, :id => 'search_validator' %>
22 - <%= submit_tag _('Search') %> 22 + <% button_bar do %>
  23 + <%= submit_button('search', _('Search')) %>
  24 + <% end %>
23 <% end %> 25 <% end %>
24 26
25 <%= observe_field 'search_validator', :url => { :action => 'search', :id => @region.id }, :with => 'search', :frequency => 1, :update => 'search_results' %> 27 <%= observe_field 'search_validator', :url => { :action => 'search', :id => @region.id }, :with => 'search', :frequency => 1, :update => 'search_results' %>
app/views/role/_form.rhtml
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 <%= labelled_form_field(permission_name(p), (check_box_tag "role[permissions][]", p, @role.has_permission?(p))) %> 9 <%= labelled_form_field(permission_name(p), (check_box_tag "role[permissions][]", p, @role.has_permission?(p))) %>
10 <% end %> 10 <% end %>
11 11
12 - <%= display_submit_tag (mode == :edit) ? _('Save changes') : _('Create role')%>  
13 - <%= link_to _('Cancel'), :action => 'index' %> 12 + <% button_bar do %>
  13 + <%= submit_button('save', (mode == :edit) ? _('Save changes') : _('Create role'), :cancel => {:action => 'index'} ) %>
  14 + <% end %>
14 <% end %> 15 <% end %>