From 7c51138ce73c5aab63c1558543ffc2f817514dc1 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Tue, 25 Sep 2007 18:33:56 +0000 Subject: [PATCH] ActionItem70: extracting the color selection into a helper --- app/helpers/categories_helper.rb | 17 +++++++++++++++++ app/views/categories/_form.rhtml | 14 ++------------ 2 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 app/helpers/categories_helper.rb diff --git a/app/helpers/categories_helper.rb b/app/helpers/categories_helper.rb new file mode 100644 index 0000000..5a84fb1 --- /dev/null +++ b/app/helpers/categories_helper.rb @@ -0,0 +1,17 @@ +module CategoriesHelper + def select_color_for_category + if @category.top_level? + options = [ + [ _('Do not display at the menu'), nil ], + [ _('Blue'), 1 ], + [ _('Red'), 2 ], + [ _('Green'), 3 ], + [ _('Orange'), 4 ], + ] + labelled_form_field(_('Display at the menu?'), select('category', 'display_color', options)) + else + "" + end + end + +end diff --git a/app/views/categories/_form.rhtml b/app/views/categories/_form.rhtml index e8629e0..3a99803 100644 --- a/app/views/categories/_form.rhtml +++ b/app/views/categories/_form.rhtml @@ -5,19 +5,9 @@ <%= hidden_field_tag('parent_id', @category.parent.id) %> <% end %> - <% if @category.top_level? %> - <% - options = [ - [ _('Do not display at the menu'), nil ], - [ _('Blue'), 1 ], - [ _('Red'), 2 ], - [ _('Green'), 3 ], - [ _('Orange'), 4 ], - ] - %> - <%= labelled_form_field(_('Display at the menu?'), f.select('display_color', options)) %> - <% end %> + <%= select_color_for_category %> <%= f.text_field 'name' %> <%= submit_tag _('Save') %> + <%= link_to _('Cancel'), :action => 'index' %> <% end %> -- libgit2 0.21.2