Commit 4fd8a4fe9b23b57ac53835e47b7b5c538fd2d98d
1 parent
5182ce64
Exists in
master
and in
29 other branches
ActionItem404: a little better on the profile editor and a new helper to create …
…radio groups on labeled forms. git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1835 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
9 changed files
with
113 additions
and
15 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -209,6 +209,47 @@ module ApplicationHelper | @@ -209,6 +209,47 @@ module ApplicationHelper | ||
209 | END_SRC | 209 | END_SRC |
210 | class_eval src, __FILE__, __LINE__ | 210 | class_eval src, __FILE__, __LINE__ |
211 | end | 211 | end |
212 | + | ||
213 | + # Create a formatable radio collection | ||
214 | + # Tha values parameter is a array of [value, label] arrays like this: | ||
215 | + # [ ['en',_('English')], ['pt',_('Portuguese')], ['es',_('Spanish')] ] | ||
216 | + # The option :size will set how many radios will be showed in each line | ||
217 | + # Example: use :size => 3 as option if you want 3 radios by line | ||
218 | + def radio_group( object_name, method, values, options = {} ) | ||
219 | + line_size = options[:size] || 0 | ||
220 | + line_item = 0 | ||
221 | + html = "\n" | ||
222 | + values.each { |val, h_val| | ||
223 | + id = object_name.to_s() +'_'+ method.to_s() +'_'+ val.to_s() | ||
224 | + # Não está apresentando o sexo selecionado ao revisitar | ||
225 | + # http://localhost:3000/myprofile/manuel/profile_editor/edit :-( | ||
226 | + html += self.class.content_tag( 'span', | ||
227 | + @template.radio_button( object_name, method, val, | ||
228 | + :id => id, :object => @object ) + | ||
229 | + self.class.content_tag( 'label', h_val, :for => id ), | ||
230 | + :class => 'lineitem' + (line_item+=1).to_s() ) +"\n" | ||
231 | + if line_item == line_size | ||
232 | + line_item = 0 | ||
233 | + html += "<br />\n" | ||
234 | + end | ||
235 | + } | ||
236 | + html += "<br />\n" if line_size == 0 || ( values.size % line_size ) > 0 | ||
237 | + column = object.class.columns_hash[method.to_s] | ||
238 | + text = | ||
239 | + ( column ? | ||
240 | + column.human_name : | ||
241 | + _(method.to_s.humanize) | ||
242 | + ) | ||
243 | + label_html = self.class.content_tag 'label', text, | ||
244 | + :class => 'formlabel' | ||
245 | + control_html = self.class.content_tag 'div', html, | ||
246 | + :class => 'formfield type-radio '+ | ||
247 | + 'fieldgroup linesize'+line_size.to_s() | ||
248 | + | ||
249 | + self.class.content_tag 'div', label_html + control_html, | ||
250 | + :class => 'formfieldline' | ||
251 | + end | ||
252 | + | ||
212 | end | 253 | end |
213 | 254 | ||
214 | def category_color | 255 | def category_color |
@@ -568,7 +609,10 @@ module ApplicationHelper | @@ -568,7 +609,10 @@ module ApplicationHelper | ||
568 | # end | 609 | # end |
569 | 610 | ||
570 | def file_field_or_thumbnail(label, image, i) | 611 | def file_field_or_thumbnail(label, image, i) |
571 | - display_form_field( label, (render :partial => (image && image.valid? ? 'shared/show_thumbnail' : 'shared/change_image'), :locals => { :i => i, :image => image }) ) | 612 | + display_form_field label, ( |
613 | + render :partial => (image && image.valid? ? 'shared/show_thumbnail' : 'shared/change_image'), | ||
614 | + :locals => { :i => i, :image => image } | ||
615 | + ) | ||
572 | end | 616 | end |
573 | 617 | ||
574 | end | 618 | end |
app/views/profile_editor/_person.rhtml
1 | <%= f.text_field(:name) %> | 1 | <%= f.text_field(:name) %> |
2 | <%= f.text_field(:contact_information) %> | 2 | <%= f.text_field(:contact_information) %> |
3 | <%= f.text_field(:contact_phone) %> | 3 | <%= f.text_field(:contact_phone) %> |
4 | - <%= _('Sex: ') %> | ||
5 | - <%= display_form_field(_('Male'), radio_button(:profile, :sex, 'male')) %> | ||
6 | - <%= display_form_field(_('Female'), radio_button(:profile, :sex, 'female')) %> | 4 | + <%# use :size => 3 if you want 3 radios by line %> |
5 | + <%= f.radio_group :profile, :sex, [ ['male',_('Male')], ['female',_('Female')] ] %> | ||
7 | <%= f.text_field(:birth_date) %> | 6 | <%= f.text_field(:birth_date) %> |
8 | <%= f.text_field(:address) %> | 7 | <%= f.text_field(:address) %> |
9 | <%= f.text_field(:city) %> | 8 | <%= f.text_field(:city) %> |
app/views/profile_editor/edit.rhtml
@@ -5,10 +5,12 @@ | @@ -5,10 +5,12 @@ | ||
5 | <% labelled_form_for :profile_data, @profile, :html => { :multipart => true } do |f| %> | 5 | <% labelled_form_for :profile_data, @profile, :html => { :multipart => true } do |f| %> |
6 | <%= render :partial => partial_for_class(@profile.class), :locals => { :f => f } %> | 6 | <%= render :partial => partial_for_class(@profile.class), :locals => { :f => f } %> |
7 | 7 | ||
8 | - <h1><%= _('Change picture') %></h1> | ||
9 | - <% f.fields_for :image_builder, @profile.image do |i| %> | ||
10 | - <%= file_field_or_thumbnail(_('Image:'), @profile.image, i) %> | ||
11 | - <% end %> | 8 | + <div id="profile_change_picture"> |
9 | + <h1><%= _('Change picture') %></h1> | ||
10 | + <% f.fields_for :image_builder, @profile.image do |i| %> | ||
11 | + <%= file_field_or_thumbnail(_('Image:'), @profile.image, i) %> | ||
12 | + <% end %> | ||
13 | + </div> | ||
12 | 14 | ||
13 | <h1><%= _('Privacy options') %></h1> | 15 | <h1><%= _('Privacy options') %></h1> |
14 | <p> | 16 | <p> |
app/views/shared/_change_image.rhtml
1 | <%= i.file_field( :uploaded_data, { :onchange => 'updateImg(this.value)' } ) %> | 1 | <%= i.file_field( :uploaded_data, { :onchange => 'updateImg(this.value)' } ) %> |
2 | - | ||
3 | - <br/> | ||
4 | - | ||
5 | - <%= link_to_function(_('Cancel'), nil, :id => 'cancel-change-image-link', :style => 'display: none') do |page| | 2 | + <%= link_to_function(_('Cancel'), nil, :id => 'cancel-change-image-link', :class => 'button icon-cancel with-text', :style => 'display: none') do |page| |
6 | page['change-image-link'].show | 3 | page['change-image-link'].show |
7 | page['change-image'].replace_html '' | 4 | page['change-image'].replace_html '' |
8 | end %> | 5 | end %> |
app/views/shared/_show_thumbnail.rhtml
@@ -2,10 +2,10 @@ | @@ -2,10 +2,10 @@ | ||
2 | 2 | ||
3 | <br/> | 3 | <br/> |
4 | 4 | ||
5 | - <%= link_to_function(_('Change image'), nil, :id => 'change-image-link') do |page| | 5 | + <%= link_to_function(_('Change image'), nil, :id => 'change-image-link', :class => 'button icon-open with-text') do |page| |
6 | page['change-image'].replace_html :partial => 'shared/change_image', :locals => { :i => i, :image => image } | 6 | page['change-image'].replace_html :partial => 'shared/change_image', :locals => { :i => i, :image => image } |
7 | page['change-image-link'].hide | 7 | page['change-image-link'].hide |
8 | page['cancel-change-image-link'].show | 8 | page['cancel-change-image-link'].show |
9 | end %> | 9 | end %> |
10 | 10 | ||
11 | - <div id='change-image'> </div> | 11 | + <div id='change-image'> </div> <br/> |
245 Bytes
public/designs/icons/default/style.css
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | .icon-home { background-image: url(gnome-home.png) } | 2 | .icon-home { background-image: url(gnome-home.png) } |
3 | .icon-new { background-image: url(gtk-new.png) } | 3 | .icon-new { background-image: url(gtk-new.png) } |
4 | .icon-close { background-image: url(cancel-HC.gif) } | 4 | .icon-close { background-image: url(cancel-HC.gif) } |
5 | -.icon-open { background-image: url(gtk-open.png) } | 5 | +.icon-open { background-image: url(folder-open.gif) } |
6 | .icon-cms { background-image: url(abiword_48.png) } | 6 | .icon-cms { background-image: url(abiword_48.png) } |
7 | .icon-save { background-image: url(save-HC.gif) } | 7 | .icon-save { background-image: url(save-HC.gif) } |
8 | .icon-up { background-image: url(go-up-HC.gif) } | 8 | .icon-up { background-image: url(go-up-HC.gif) } |
public/designs/themes/zen3/stylesheets/controller_profile_editor.css
0 → 100644
@@ -0,0 +1,28 @@ | @@ -0,0 +1,28 @@ | ||
1 | + | ||
2 | +.categorie_box { | ||
3 | + -moz-border-radius: 4px; | ||
4 | + border: 1px solid #F57900; | ||
5 | + margin-bottom: 2px; | ||
6 | + padding: 2px 0px; | ||
7 | +} | ||
8 | + | ||
9 | +#content .categorie_box h5 { | ||
10 | + margin: 0px; | ||
11 | + padding: 0px; | ||
12 | + line-height: 22px; | ||
13 | +} | ||
14 | + | ||
15 | +#content ul.categories { | ||
16 | + padding: 5px 4px 3px 4px; | ||
17 | +} | ||
18 | + | ||
19 | +ul.categories li { | ||
20 | + -moz-border-radius: 9px; | ||
21 | + border-bottom: 1px solid #FFF; | ||
22 | +} | ||
23 | + | ||
24 | +ul.categories li.cat_checked { | ||
25 | + background: #F57900; | ||
26 | + border-bottom: 1px solid #CE5C00; | ||
27 | +} | ||
28 | + |
public/stylesheets/forms.css
@@ -43,3 +43,31 @@ | @@ -43,3 +43,31 @@ | ||
43 | text-align: center; | 43 | text-align: center; |
44 | } | 44 | } |
45 | 45 | ||
46 | +.fieldgroup span { | ||
47 | + display: block; | ||
48 | + float: left; | ||
49 | +} | ||
50 | +.fieldgroup br { | ||
51 | + clear: left; | ||
52 | +} | ||
53 | + | ||
54 | +.linesize0 span { padding-right: 15px } | ||
55 | +.linesize1 span { width: 99% } | ||
56 | +.linesize2 span { width: 49% } | ||
57 | +.linesize3 span { width: 33% } | ||
58 | + | ||
59 | +.type-img input { | ||
60 | + float: left; | ||
61 | + margin-right: 10px; | ||
62 | +} | ||
63 | +.type-img br { | ||
64 | + clear: left; | ||
65 | +} | ||
66 | + | ||
67 | +#profile_change_picture label { | ||
68 | + display: none; | ||
69 | +} | ||
70 | +#profile_change_picture img { | ||
71 | + margin-left: 10px; | ||
72 | +} | ||
73 | + |