Commit dedae62f47b60867e72fda5aae1ad497636c1478
1 parent
54b441e2
Exists in
master
and in
29 other branches
Added options for target on model to avoid repetition
(ActionItem2795)
Showing
3 changed files
with
16 additions
and
5 deletions
Show diff stats
app/models/link_list_block.rb
... | ... | @@ -33,6 +33,12 @@ class LinkListBlock < Block |
33 | 33 | ['chat', N_('Chat')] |
34 | 34 | ] |
35 | 35 | |
36 | + TARGET_OPTIONS = [ | |
37 | + [N_('Same page'), '_self'], | |
38 | + [N_('New tab'), '_blank'], | |
39 | + [N_('New window'), '_new'], | |
40 | + ] | |
41 | + | |
36 | 42 | settings_items :links, Array, :default => [] |
37 | 43 | |
38 | 44 | before_save do |block| | ... | ... |
app/views/box_organizer/_link_list_block.rhtml
... | ... | @@ -9,9 +9,9 @@ |
9 | 9 | </td> |
10 | 10 | <td><%= text_field_tag 'block[links][][name]', link[:name], :class => 'link-name', :maxlength => 20 %></td> |
11 | 11 | <td class='cel-address'><%= text_field_tag 'block[links][][address]', link[:address], :class => 'link-address' %></td> |
12 | - <td> | |
13 | - <%= select_tag('block[links][][target]', options_for_select([[_('Same page'), '_self'], [_('New tab'), '_blank'], [_('New window'), '_new']], link[:target].blank? ? '_self' : link[:target])) %> | |
14 | - </td> | |
12 | + <td> | |
13 | + <%= select_tag('block[links][][target]', options_for_select(LinkListBlock::TARGET_OPTIONS, link[:target])) %> | |
14 | + </td> | |
15 | 15 | </tr> |
16 | 16 | <% end %> |
17 | 17 | </table> |
... | ... | @@ -21,8 +21,9 @@ |
21 | 21 | page.insert_html :bottom, 'links', content_tag('tr', |
22 | 22 | content_tag('td', icon_selector('ok')) + |
23 | 23 | content_tag('td', text_field_tag('block[links][][name]', '', :maxlength => 20)) + |
24 | - content_tag('td', text_field_tag('block[links][][address]', nil, :class => 'cel-address')) + | |
25 | - content_tag('td', select_tag('block[links][][target]',options_for_select([['Mesma pagina', '_self'], ['Nova aba', '_blank'], ['Nova Janela', '_new']], '_self'))) | |
24 | + content_tag('td', text_field_tag('block[links][][address]', nil, :class => 'link-address'), :class => 'cel-address') + | |
25 | + content_tag('td', select_tag('block[links][][target]', | |
26 | +options_for_select(LinkListBlock::TARGET_OPTIONS, link[:target]))) | |
26 | 27 | ) + |
27 | 28 | javascript_tag("$('edit-link-list-block').scrollTop = $('edit-link-list-block').scrollHeight") |
28 | 29 | end %> | ... | ... |
test/unit/link_list_block_test.rb
... | ... | @@ -83,4 +83,8 @@ class LinkListBlockTest < ActiveSupport::TestCase |
83 | 83 | assert_equal 'always', block.display |
84 | 84 | end |
85 | 85 | |
86 | + should 'have options for links target' do | |
87 | + assert_equivalent LinkListBlock::TARGET_OPTIONS.map {|t|t[1]}, ['_self', '_blank', '_new'] | |
88 | + end | |
89 | + | |
86 | 90 | end | ... | ... |