#{link_to '', '#', :class=>'button icon-button icon-delete delete-highlight', :confirm=>_('Are you sure you want to remove this highlight')}
"
end
diff --git a/app/views/box_organizer/_highlights_block.html.erb b/app/views/box_organizer/_highlights_block.html.erb
index 36cc6e3..2093f44 100644
--- a/app/views/box_organizer/_highlights_block.html.erb
+++ b/app/views/box_organizer/_highlights_block.html.erb
@@ -4,8 +4,8 @@
<%= _('Image') %>
<%= _('Address') %>
<%= _('Position') %>
- <% for image in @block.images do %>
- <%= highlights_block_config_image_fields @block, image %>
+ <% @block.images.each_with_index do |image, index| %>
+ <%= highlights_block_config_image_fields @block, image, index %>
<% end %>
diff --git a/features/highlights_block.feature b/features/highlights_block.feature
index 74986ed..15ae21d 100644
--- a/features/highlights_block.feature
+++ b/features/highlights_block.feature
@@ -16,7 +16,7 @@ Feature: Edit Highlight Block
And I follow "Add a block"
And I choose "Highlights"
And I press "Add"
- And I follow "Edit" within ".highlights-block"
+ And I follow "Edit" within ".highlights-block"#Need to hover the mouse on the box
And I follow "New highlight"
And I fill in "block_images__address" with "/"
And I fill in "block_images__position" with "0"
@@ -24,3 +24,21 @@ Feature: Edit Highlight Block
And I press "Save"
And I follow "Edit" within ".highlights-block"
Then I should see "Title"
+
+ @selenium-fixme
+ Scenario: Remove one saved 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"#Need to hover the mouse on the box
+ And I press "Save"
+ And I follow "Edit" within ".highlights-block"
+ And I follow "" within ".delete-highlight"
+ And I confirm the browser dialog
+ Then I should not see "Title"
\ No newline at end of file
diff --git a/public/javascripts/highlight_block.js b/public/javascripts/highlight_block.js
index b0549e8..caf0f39 100644
--- a/public/javascripts/highlight_block.js
+++ b/public/javascripts/highlight_block.js
@@ -1,8 +1,27 @@
function highlight_table_row(evt) {
- evt.preventDefault();
- jQuery("#highlights-data-table").append(jQuery(".highlight-table-row tbody").html());
+ var row_number = parseInt(jQuery("#highlights-data-table tr").last().attr("data-row-number"));
+ var row_data = jQuery(".highlight-table-row tbody tr").clone();
+
+ row_data.attr("data-row-number", row_number+1 || 0);
+ jQuery("#highlights-data-table").append(row_data);
+ jQuery(".delete-highlight").on("confirm:complete", delete_highlight);
+
+ return false;
+}
+
+function delete_highlight(evt, answer) {
+ if(answer) {
+ var row_number = parseInt(jQuery(this).parent().parent().attr("data-row-number"));
+
+ if(row_number != NaN) {
+ jQuery("#highlights-data-table tr[data-row-number="+row_number+"]").remove();
+ }
+ }
+
+ return false;
}
jQuery(document).ready(function(){
jQuery(".new-highlight-button").click(highlight_table_row);
+ jQuery(".delete-highlight").on("confirm:complete", delete_highlight);
});
--
libgit2 0.21.2