From aaefdf5b3737c64f7da056e5fc5fb2b01c9fcf71 Mon Sep 17 00:00:00 2001 From: Aurélio A. Heckert Date: Mon, 11 Mar 2013 15:08:46 -0300 Subject: [PATCH] A better highlights block config interface --- app/helpers/block_helper.rb | 17 +++++++++++++++++ app/views/box_organizer/_highlights_block.rhtml | 23 +++++------------------ public/stylesheets/application.css | 29 +++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 18 deletions(-) diff --git a/app/helpers/block_helper.rb b/app/helpers/block_helper.rb index 8fbe47f..1f65c02 100644 --- a/app/helpers/block_helper.rb +++ b/app/helpers/block_helper.rb @@ -6,4 +6,21 @@ module BlockHelper content_tag 'h3', content_tag('span', title), :class => tag_class end + def highlights_block_config_image_fields(block, image={}) + " + + + #{select_tag 'block[images][][image_id]', content_tag(:option) + option_groups_from_collection_for_select(block.folder_choices, :images, :name, :id, :name, image[:image_id].to_i)} + + #{text_field_tag 'block[images][][address]', image[:address], :class => 'highlight-address', :size => 20} + #{text_field_tag 'block[images][][position]', image[:position], :class => 'highlight-position', :size => 1} + + + + " + end + end diff --git a/app/views/box_organizer/_highlights_block.rhtml b/app/views/box_organizer/_highlights_block.rhtml index 734f1bf..548686a 100644 --- a/app/views/box_organizer/_highlights_block.rhtml +++ b/app/views/box_organizer/_highlights_block.rhtml @@ -1,27 +1,14 @@ <%= _('Highlights') %> - - +
<%= _('Image') %><%= _('Address') %><%= _('Position') %><%= _('Title') %>
+ <% for image in @block.images do %> - - - - - - + <%= highlights_block_config_image_fields @block, image %> <% end %> -
<%= _('Image') %><%= _('Address') %><%= _('Position') %>
- <%= select_tag 'block[images][][image_id]', content_tag(:option) + option_groups_from_collection_for_select(@block.folder_choices, :images, :name, :id, :name, image[:image_id].to_i), :style => "width: 100px" %>

-
<%= text_field_tag 'block[images][][address]', image[:address], :class => 'highlight-address', :size => 10 %><%= text_field_tag 'block[images][][position]', image[:position], :class => 'highlight-position', :size => 3 %><%= text_field_tag 'block[images][][title]', image[:title], :class => 'highlight-title', :size => 10 %>
+ <%= link_to_function(_('New highlight'), nil, :class => 'button icon-add with-text') do |page| - page.insert_html :bottom, 'highlights', content_tag('tr', - content_tag('td', select_tag('block[images][][image_id]', content_tag(:option) + option_groups_from_collection_for_select(@block.folder_choices, :images, :name, :id, :name), :style => "width: 100px")) + - content_tag('td', text_field_tag('block[images][][address]', nil, :class => 'highlight-address', :size => 10)) + - content_tag('td', text_field_tag('block[images][][position]', nil, :class => 'highlight-position', :size => 3)) + - content_tag('td', text_field_tag('block[images][][title]', nil, :class => 'highlight-position', :size => 10)) - ) + - javascript_tag("$('edit-link-list-block').scrollTop = $('edit-link-list-block').scrollHeight") + page.insert_html :bottom, 'highlights-data-table', highlights_block_config_image_fields(@block) end %> <%= 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/public/stylesheets/application.css b/public/stylesheets/application.css index ba382d3..545d48f 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -4314,6 +4314,35 @@ h1#agenda-title { text-align: center; overflow: hidden; } + +.block-config-options.HighlightsBlock-options .image-data-line select { + width: 150px; +} + +.block-config-options.HighlightsBlock-options td { + text-align: center; +} + +.block-config-options.HighlightsBlock-options .image-data-line td { + padding-top: 7px; +} + +.block-config-options.HighlightsBlock-options .image-title { + white-space: nowrap; + border-bottom: 1px solid #CCC; +} +.block-config-options.HighlightsBlock-options .image-title:last-child { + border: none; +} + +.block-config-options.HighlightsBlock-options .image-title td { + padding-bottom: 7px; +} + +.block-config-options.HighlightsBlock-options .image-title span { + padding-right: 5px; +} + /* Featured Products stuff */ .featured-product-items { -- libgit2 0.21.2