From 52f7d6cb1997c7d2e14c905982a8e22edf23e6f8 Mon Sep 17 00:00:00 2001 From: Fabio Teixeira Date: Mon, 4 Aug 2014 15:32:47 -0300 Subject: [PATCH] Fix Highlight block 'new highlight' button --- app/models/highlights_block.rb | 2 +- app/views/box_organizer/_highlights_block.html.erb | 12 +++++++++--- features/highlights_block.feature | 26 ++++++++++++++++++++++++++ public/javascripts/highlight_block.js | 8 ++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 features/highlights_block.feature create mode 100644 public/javascripts/highlight_block.js diff --git a/app/models/highlights_block.rb b/app/models/highlights_block.rb index 1ebeb9a..f12d7ec 100644 --- a/app/models/highlights_block.rb +++ b/app/models/highlights_block.rb @@ -1,6 +1,6 @@ class HighlightsBlock < Block - attr_accessible :images + attr_accessible :images, :interval, :shuffle, :navigation settings_items :images, :type => Array, :default => [] settings_items :interval, :type => 'integer', :default => 4 diff --git a/app/views/box_organizer/_highlights_block.html.erb b/app/views/box_organizer/_highlights_block.html.erb index 548686a..36cc6e3 100644 --- a/app/views/box_organizer/_highlights_block.html.erb +++ b/app/views/box_organizer/_highlights_block.html.erb @@ -1,3 +1,5 @@ +<%= javascript_include_tag "highlight_block" %> + <%= _('Highlights') %> @@ -7,9 +9,13 @@ <% end %>
-<%= link_to_function(_('New highlight'), nil, :class => 'button icon-add with-text') do |page| - page.insert_html :bottom, 'highlights-data-table', highlights_block_config_image_fields(@block) -end %> + + + <%= highlights_block_config_image_fields(@block) %> + + + +<%= link_to(_('New highlight'), '#', :class => 'button icon-add with-text new-highlight-button')%> <%= 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]}) %> diff --git a/features/highlights_block.feature b/features/highlights_block.feature new file mode 100644 index 0000000..74986ed --- /dev/null +++ b/features/highlights_block.feature @@ -0,0 +1,26 @@ +Feature: Edit Highlight Block + As a user + I want to edit the highlight block + + Background: + Given I am on the homepage + And the following users + | login | name | + | jose | Jose Silva | + And I am logged in as "jose" + + @selenium + Scenario: Add new highlight + Given I follow "Control panel" + And I follow "Edit sideboxes" + And I follow "Add a block" + And I choose "Highlights" + And I press "Add" + And I follow "Edit" within ".highlights-block" + And I follow "New highlight" + And I fill in "block_images__address" with "/" + And I fill in "block_images__position" with "0" + And I fill in "block_images__title" with "test highlights" + And I press "Save" + And I follow "Edit" within ".highlights-block" + Then I should see "Title" diff --git a/public/javascripts/highlight_block.js b/public/javascripts/highlight_block.js new file mode 100644 index 0000000..b0549e8 --- /dev/null +++ b/public/javascripts/highlight_block.js @@ -0,0 +1,8 @@ +function highlight_table_row(evt) { + evt.preventDefault(); + jQuery("#highlights-data-table").append(jQuery(".highlight-table-row tbody").html()); +} + +jQuery(document).ready(function(){ + jQuery(".new-highlight-button").click(highlight_table_row); +}); -- libgit2 0.21.2