Commit 86a8b05b24ee7ce48cc62f53d18a089c29154efa
1 parent
7c51138c
Exists in
master
and in
29 other branches
ActionItem70: enhancing categories_helper
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@542 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
25 additions
and
8 deletions
Show diff stats
app/controllers/environment_admin/categories_controller.rb
app/helpers/categories_helper.rb
| 1 | module CategoriesHelper | 1 | module CategoriesHelper |
| 2 | + | ||
| 3 | + include GetText | ||
| 4 | + | ||
| 5 | + COLORS = [ | ||
| 6 | + [ N_('Do not display at the menu'), nil ], | ||
| 7 | + [ N_('Blue'), 1 ], | ||
| 8 | + [ N_('Red'), 2 ], | ||
| 9 | + [ N_('Green'), 3 ], | ||
| 10 | + [ N_('Orange'), 4 ], | ||
| 11 | + ] | ||
| 12 | + | ||
| 2 | def select_color_for_category | 13 | def select_color_for_category |
| 3 | if @category.top_level? | 14 | if @category.top_level? |
| 4 | - options = [ | ||
| 5 | - [ _('Do not display at the menu'), nil ], | ||
| 6 | - [ _('Blue'), 1 ], | ||
| 7 | - [ _('Red'), 2 ], | ||
| 8 | - [ _('Green'), 3 ], | ||
| 9 | - [ _('Orange'), 4 ], | ||
| 10 | - ] | ||
| 11 | - labelled_form_field(_('Display at the menu?'), select('category', 'display_color', options)) | 15 | + labelled_form_field(_('Display at the menu?'), select('category', 'display_color', CategoriesHelper::COLORS.map {|item| [gettext(item[0]), item[1]] })) |
| 12 | else | 16 | else |
| 13 | "" | 17 | "" |
| 14 | end | 18 | end |
| 15 | end | 19 | end |
| 16 | 20 | ||
| 21 | + def display_color_for_category(category) | ||
| 22 | + color = category.display_color | ||
| 23 | + if color.nil? | ||
| 24 | + "" | ||
| 25 | + else | ||
| 26 | + "[" + gettext(CategoriesHelper::COLORS.find {|item| item[1] == color}.first) + "]" | ||
| 27 | + end | ||
| 28 | + end | ||
| 29 | + | ||
| 17 | end | 30 | end |