Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cleaned up setting forms for me and groups, combined avatar_field - f…

…ixes #3954
  • Loading branch information...
commit 7b5a954bea2ea8bd9438ef1028af7b9e5df98f1c 1 parent 0c52bcb
azul azul authored
10 app/helpers/common/ui/avatar_helper.rb
View
@@ -49,5 +49,15 @@ def square_avatar_style(entity, size='medium')
]
end
+ def avatar_field(entity)
+ action = entity.avatar ? :edit : :new
+ context = (entity == current_user) ? :me : entity
+ url = polymorphic_path [context, entity.avatar || :avatar],
+ :action => action
+ link_options = {:url => url, :icon => 'picture_edit'}
+
+ return avatar_for(entity,'large') + " " +
+ link_to_modal(:upload_image_link.t, link_options, :class => 'inline')
+ end
end
39 app/helpers/groups/settings_helper.rb
View
@@ -0,0 +1,39 @@
+module Groups::SettingsHelper
+
+ def group_settings_form
+ formy(:table_form) do |f|
+
+ f.heading :display.t
+ f.row do |r|
+ r.label :name.t
+ r.input text_field('group', 'name', :size => 40, :maxlength => 40)
+ r.info "(#{:required.t}) "
+ r.info :link_name_description.t
+ end
+
+ f.row do |r|
+ r.label :display_name.t
+ r.label_for 'group_full_name'
+ r.input text_field('group', 'full_name', :size => 40, :maxlength => 100)
+ r.info "(#{:optional.t}) "
+ r.info I18n.t(:descriptive_name_for_display)
+ end
+
+ f.row do |r|
+ r.label :icon.t
+ r.input avatar_field(@group)
+ end
+
+ f.heading :locale.t
+ f.row do |r|
+ r.label :language.t
+ r.label_for 'group_language'
+ r.input select('group', 'language', all_languages_for_select, { :include_blank => true })
+ end
+
+ f.buttons submit_tag(:save_button.t, :class => 'btn btn-primary')
+
+ end
+ end
+
+end
50 app/helpers/me/settings_helper.rb
View
@@ -0,0 +1,50 @@
+module Me::SettingsHelper
+
+ def my_settings_form
+ formy(:table_form) do |f|
+
+ f.heading :display.t
+ f.row do |r|
+ r.label :username.t
+ r.input text_field('user','login')
+ end
+
+ f.row do |r|
+ r.label :display_name.t
+ r.input text_field('user','display_name')
+ end
+
+ f.row do |r|
+ r.label :icon.t
+ r.input avatar_field(current_user)
+ end
+
+ f.heading :notification.t
+ f.row do |r|
+ r.label :email.t
+ r.input text_field('user','email')
+ end
+
+ ## TODO I18N:
+ f.row do |r|
+ r.label :notice.t
+ r.info :do_you_want_to_receive_email_notifications.t
+ r.input select('user', 'receive_notifications', [["No", ""], ["Yes: an email per change","Single"], ["Yes: just a summary email","Digest"]])
+ end
+
+ f.heading :locale.t
+ f.row do |r|
+ r.label :language.t
+ r.input select('user', 'language', all_languages_for_select, { :include_blank => true })
+ end
+
+ f.row do |r|
+ r.label :time_zone.t
+ r.input time_zone_select('user', 'time_zone', nil, :include_blank => true)
+ end
+
+ f.buttons submit_tag(:save_button.t, :class => 'btn btn-primary')
+ end
+ end
+
+end
33 app/views/groups/settings/_form.html.haml
View
@@ -1,33 +0,0 @@
--#
--# requires: form
--#
-
-= formy(:table_form) do |f|
-
- - f.row do |r|
- - r.label :icon.t
- - r.input content_tag(:div, avatar_for(@group, 'xlarge'), :class => 'float_left')
- - r.input content_tag(:div, edit_avatar_link, :class => 'float_left', :style => 'margin-left: 1em')
- - r.info ""
-
- - f.row do |r|
- - r.label :name.t
- - r.input text_field('group', 'name', :size => 40, :maxlength => 40)
- - r.info "(#{:required.t}) "
- - r.info :link_name_description.t
-
- - f.row do |r|
- - r.label :display_name.t
- - r.label_for 'group_full_name'
- - r.input text_field('group', 'full_name', :size => 40, :maxlength => 100)
- - r.info "(#{:optional.t}) "
- - r.info I18n.t(:descriptive_name_for_display)
-
- - f.row do |r|
- - r.label I18n.t(:language)
- - r.label_for 'group_language'
- - r.input select('group', 'language', all_languages_for_select, {:include_blank => true})
- - r.info "(#{:optional.t}) "
- - r.info :group_language.t(:group => group_type.t.downcase)
-
- - f.buttons submit_tag(:save_button.t)
3  app/views/groups/settings/show.html.haml
View
@@ -1,4 +1,3 @@
- form_tag(group_settings_path(@group), :method => 'put') do
- = render :partial => '/groups/settings/form'
-
+ = group_settings_form
51 app/views/me/settings/_form.html.erb
View
@@ -1,51 +0,0 @@
-<%
-url = current_user.avatar ? edit_me_avatar_path(current_user.avatar) : new_me_avatar_path
-avatar_form = avatar_for(current_user,'large') + "&nbsp;" + link_to_modal(:upload_image_link.t, {:url => url, :icon =>
-'picture_edit'}, :class => 'inline')
--%>
-<%= formy(:table_form) do |f|
-
- f.heading :display.t
- f.row do |r|
- r.label :username.t
- r.input text_field('user','login')
- end
-
- f.row do |r|
- r.label :display_name.t
- r.input text_field('user','display_name')
- end
-
- f.row do |r|
- r.label :icon.t
- r.input avatar_form
- end
-
- f.heading :notification.t
- f.row do |r|
- r.label :email.t
- r.input text_field('user','email')
- end
-
- ## TODO I18N:
- f.row do |r|
- r.label :notice.t
- r.info :do_you_want_to_receive_email_notifications.t
- r.input select('user', 'receive_notifications', [["No", ""], ["Yes: an email per change","Single"], ["Yes: just a summary email","Digest"]])
- end
-
- f.heading :locale.t
- f.row do |r|
- r.label :language.t
- r.input select('user', 'language', all_languages_for_select, { :include_blank => true })
- end
-
- f.row do |r|
- r.label :time_zone.t
- r.input time_zone_select('user', 'time_zone', nil, :include_blank => true)
- end
-
- f.buttons submit_tag(:save_button.t, :class => 'btn btn-primary')
-
-end %>
-
4 app/views/me/settings/show.html.haml
View
@@ -6,6 +6,4 @@
.form
- form_tag(me_settings_path, :method => :put) do
- = render :partial => '/me/settings/form'
-
-
+ = my_settings_form
Please sign in to comment.
Something went wrong with that request. Please try again.