Commit 52f7d6cb1997c7d2e14c905982a8e22edf23e6f8
1 parent
944c01f8
Exists in
master
and in
27 other branches
Fix Highlight block 'new highlight' button
(ActionItem3243) Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com> Signed-off-by: Parley Martins <parley@outlook.com>
Showing
4 changed files
with
44 additions
and
4 deletions
Show diff stats
app/models/highlights_block.rb
| 1 | class HighlightsBlock < Block | 1 | class HighlightsBlock < Block |
| 2 | 2 | ||
| 3 | - attr_accessible :images | 3 | + attr_accessible :images, :interval, :shuffle, :navigation |
| 4 | 4 | ||
| 5 | settings_items :images, :type => Array, :default => [] | 5 | settings_items :images, :type => Array, :default => [] |
| 6 | settings_items :interval, :type => 'integer', :default => 4 | 6 | settings_items :interval, :type => 'integer', :default => 4 |
app/views/box_organizer/_highlights_block.html.erb
| 1 | +<%= javascript_include_tag "highlight_block" %> | ||
| 2 | + | ||
| 1 | <strong><%= _('Highlights') %></strong> | 3 | <strong><%= _('Highlights') %></strong> |
| 2 | 4 | ||
| 3 | <table class="noborder"><tbody id="highlights-data-table"> | 5 | <table class="noborder"><tbody id="highlights-data-table"> |
| @@ -7,9 +9,13 @@ | @@ -7,9 +9,13 @@ | ||
| 7 | <% end %> | 9 | <% end %> |
| 8 | </tbody></table> | 10 | </tbody></table> |
| 9 | 11 | ||
| 10 | -<%= link_to_function(_('New highlight'), nil, :class => 'button icon-add with-text') do |page| | ||
| 11 | - page.insert_html :bottom, 'highlights-data-table', highlights_block_config_image_fields(@block) | ||
| 12 | -end %> | 12 | +<table class="hidden highlight-table-row"> |
| 13 | + <tbody> | ||
| 14 | + <%= highlights_block_config_image_fields(@block) %> | ||
| 15 | + </tbody> | ||
| 16 | +</table> | ||
| 17 | + | ||
| 18 | +<%= link_to(_('New highlight'), '#', :class => 'button icon-add with-text new-highlight-button')%> | ||
| 13 | 19 | ||
| 14 | <%= labelled_form_field _('Image transition:'), select('block', 'interval', [[_('No automatic transition'), 0]] + [1, 2, 3, 4, 5, 10, 20, 30, 60].map {|item| [n_('Every 1 second', 'Every %d seconds', item) % item, item]}) %> | 20 | <%= labelled_form_field _('Image transition:'), select('block', 'interval', [[_('No automatic transition'), 0]] + [1, 2, 3, 4, 5, 10, 20, 30, 60].map {|item| [n_('Every 1 second', 'Every %d seconds', item) % item, item]}) %> |
| 15 | 21 |
| @@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
| 1 | +Feature: Edit Highlight Block | ||
| 2 | + As a user | ||
| 3 | + I want to edit the highlight block | ||
| 4 | + | ||
| 5 | + Background: | ||
| 6 | + Given I am on the homepage | ||
| 7 | + And the following users | ||
| 8 | + | login | name | | ||
| 9 | + | jose | Jose Silva | | ||
| 10 | + And I am logged in as "jose" | ||
| 11 | + | ||
| 12 | + @selenium | ||
| 13 | + Scenario: Add new highlight | ||
| 14 | + Given I follow "Control panel" | ||
| 15 | + And I follow "Edit sideboxes" | ||
| 16 | + And I follow "Add a block" | ||
| 17 | + And I choose "Highlights" | ||
| 18 | + And I press "Add" | ||
| 19 | + And I follow "Edit" within ".highlights-block" | ||
| 20 | + And I follow "New highlight" | ||
| 21 | + And I fill in "block_images__address" with "/" | ||
| 22 | + And I fill in "block_images__position" with "0" | ||
| 23 | + And I fill in "block_images__title" with "test highlights" | ||
| 24 | + And I press "Save" | ||
| 25 | + And I follow "Edit" within ".highlights-block" | ||
| 26 | + Then I should see "Title" |
| @@ -0,0 +1,8 @@ | @@ -0,0 +1,8 @@ | ||
| 1 | +function highlight_table_row(evt) { | ||
| 2 | + evt.preventDefault(); | ||
| 3 | + jQuery("#highlights-data-table").append(jQuery(".highlight-table-row tbody").html()); | ||
| 4 | +} | ||
| 5 | + | ||
| 6 | +jQuery(document).ready(function(){ | ||
| 7 | + jQuery(".new-highlight-button").click(highlight_table_row); | ||
| 8 | +}); |