Commit 6261e6cf64886a14ca7a58f0e3308e881eb86470
Committed by
alcampelo
1 parent
49568a03
Exists in
master
and in
29 other branches
add title field to link list block
(ActionItem2925)
Showing
4 changed files
with
25 additions
and
16 deletions
Show diff stats
app/models/link_list_block.rb
@@ -63,7 +63,7 @@ class LinkListBlock < Block | @@ -63,7 +63,7 @@ class LinkListBlock < Block | ||
63 | def link_html(link) | 63 | def link_html(link) |
64 | klass = 'icon-' + link[:icon] if link[:icon] | 64 | klass = 'icon-' + link[:icon] if link[:icon] |
65 | sanitize_link( | 65 | sanitize_link( |
66 | - link_to(link[:name], expand_address(link[:address]), :target => link[:target], :class => klass) | 66 | + link_to(link[:name], expand_address(link[:address]), :target => link[:target], :class => klass, :title => link[:title]) |
67 | ) | 67 | ) |
68 | end | 68 | end |
69 | 69 |
app/views/box_organizer/_link_list_block.rhtml
1 | <strong><%= _('Links') %></strong> | 1 | <strong><%= _('Links') %></strong> |
2 | -<div id='edit-link-list-block' style='width:450px'> | ||
3 | -<table id='links' class='noborder'> | ||
4 | - <tr><th><%= _('Icon') %></th><th><%= _('Name') %></th><th><%= _('Address') %></th><th><%= _('Target') %></th></tr> | 2 | +<div id='edit-link-list-block' style='width: 820px;'> |
3 | +<table id='links' class='noborder' style="width:auto;"> | ||
4 | + <tr> | ||
5 | + <th><%= _('Icon') %></th> | ||
6 | + <th><%= _('Name') %></th> | ||
7 | + <th><%= _('Address') %></th> | ||
8 | + <th><%= _('Title') %></th> | ||
9 | + <th><%= _('Target') %></th> | ||
10 | + </tr> | ||
5 | <% for link in @block.links do %> | 11 | <% for link in @block.links do %> |
6 | - <tr> | ||
7 | - <td> | ||
8 | - <%= icon_selector(link['icon']) %> | ||
9 | - </td> | ||
10 | - <td><%= text_field_tag 'block[links][][name]', link[:name], :class => 'link-name', :maxlength => 20 %></td> | ||
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(LinkListBlock::TARGET_OPTIONS, link[:target])) %> | ||
14 | - </td> | ||
15 | - </tr> | 12 | + <tr> |
13 | + <td><%= icon_selector(link['icon']) %></td> | ||
14 | + <td><%= text_field_tag 'block[links][][name]', link[:name], :class => 'link-name', :maxlength => 20 %></td> | ||
15 | + <td class='cel-address'><%= text_field_tag 'block[links][][address]', link[:address], :class => 'link-address' %></td> | ||
16 | + <td><%= text_field_tag 'block[links][][title]', link[:title], :class => 'link-title' %></td> | ||
17 | + <td><%= select_tag('block[links][][target]', options_for_select(LinkListBlock::TARGET_OPTIONS, link[:target])) %></td> | ||
18 | + </tr> | ||
16 | <% end %> | 19 | <% end %> |
17 | </table> | 20 | </table> |
18 | </div> | 21 | </div> |
@@ -22,8 +25,8 @@ | @@ -22,8 +25,8 @@ | ||
22 | content_tag('td', icon_selector('ok')) + | 25 | content_tag('td', icon_selector('ok')) + |
23 | content_tag('td', text_field_tag('block[links][][name]', '', :maxlength => 20)) + | 26 | content_tag('td', text_field_tag('block[links][][name]', '', :maxlength => 20)) + |
24 | content_tag('td', text_field_tag('block[links][][address]', nil, :class => 'link-address'), :class => 'cel-address') + | 27 | 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]))) | 28 | + content_tag('td', text_field_tag('block[links][][title]', '', :class => 'link-title'), :class => 'cel-address' ) + |
29 | + content_tag('td', select_tag('block[links][][target]', options_for_select(LinkListBlock::TARGET_OPTIONS))) | ||
27 | ) + | 30 | ) + |
28 | javascript_tag("$('edit-link-list-block').scrollTop = $('edit-link-list-block').scrollHeight") | 31 | javascript_tag("$('edit-link-list-block').scrollTop = $('edit-link-list-block').scrollHeight") |
29 | end %> | 32 | end %> |
public/stylesheets/application.css
@@ -1832,6 +1832,7 @@ a.button.disabled, input.disabled { | @@ -1832,6 +1832,7 @@ a.button.disabled, input.disabled { | ||
1832 | 1832 | ||
1833 | #edit-link-list-block table { | 1833 | #edit-link-list-block table { |
1834 | width: 100%; | 1834 | width: 100%; |
1835 | + margin-bottom: 10px; | ||
1835 | } | 1836 | } |
1836 | #edit-link-list-block table .cel-address { | 1837 | #edit-link-list-block table .cel-address { |
1837 | width: 220px; | 1838 | width: 220px; |
test/unit/link_list_block_test.rb
@@ -86,4 +86,9 @@ class LinkListBlockTest < ActiveSupport::TestCase | @@ -86,4 +86,9 @@ class LinkListBlockTest < ActiveSupport::TestCase | ||
86 | assert_equivalent LinkListBlock::TARGET_OPTIONS.map {|t|t[1]}, ['_self', '_blank', '_new'] | 86 | assert_equivalent LinkListBlock::TARGET_OPTIONS.map {|t|t[1]}, ['_self', '_blank', '_new'] |
87 | end | 87 | end |
88 | 88 | ||
89 | + should 'link with title' do | ||
90 | + l = LinkListBlock.new | ||
91 | + assert_match /title="mytitle"/, l.link_html({:name => 'mylink', :address => '/myaddress', :title => 'mytitle'}) | ||
92 | + end | ||
93 | + | ||
89 | end | 94 | end |