Commit 7e2ac2d57d7a9f384036eb19c2814410db6d71a6

Authored by Victor Costa
2 parents e83ed4e9 e6562b97

Merge branch 'AI3279-new_block_store' into stable

app/controllers/box_organizer_controller.rb
... ... @@ -3,7 +3,7 @@ class BoxOrganizerController < ApplicationController
3 3 before_filter :login_required
4 4  
5 5 def index
6   - @available_blocks = available_blocks.uniq
  6 + @available_blocks = available_blocks.uniq.sort_by(&:pretty_name)
7 7 end
8 8  
9 9 def move_block
... ...
app/helpers/boxes_helper.rb
... ... @@ -193,7 +193,7 @@ module BoxesHelper
193 193 if block.nil? or modifiable?(block)
194 194 draggable_id = "encodeURIComponent(jQuery(ui.draggable).attr('id'))"
195 195 draggable_type = "encodeURIComponent(jQuery(ui.draggable).attr('data-block-type'))"
196   - content_tag('div', _('Drop Here'), :id => id, :class => 'block-target' ) + drop_receiving_element(id, :url => { :action => 'move_block', :target => id }, :accept => box.acceptable_blocks, :hoverclass => 'block-target-hover', :with => "'type='+"+draggable_type+"+'&id=' + "+draggable_id, :activeClass => 'block-target-active')
  196 + content_tag('div', _('Drop Here'), :id => id, :class => 'block-target' ) + drop_receiving_element(id, :url => { :action => 'move_block', :target => id }, :accept => box.acceptable_blocks, :hoverclass => 'block-target-hover', :with => "'type='+"+draggable_type+"+'&id=' + "+draggable_id, :activeClass => 'block-target-active', :tolerance => 'pointer')
197 197 else
198 198 ""
199 199 end
... ...
app/views/box_organizer/index.html.erb
... ... @@ -8,9 +8,10 @@
8 8 <% end %>
9 9  
10 10 <div id="block-store">
  11 + <input type="text" id="block-store-filter" placeholder="<%= _('Filter blocks') %>" title="<%= _('Filter blocks') %>">
11 12 <div id="block-types">
12 13 <% @available_blocks.each do |block| %>
13   - <div id="block-<%= block.name.to_css_class %>" class="block-type <%= block.name.to_css_class %>" data-block-type="<%= block.name %>">
  14 + <div id="block-<%= block.name.to_css_class %>" class="block-type <%= block.name.to_css_class %>" data-block-type="<%= block.name %>" data-block-name="<%= block.pretty_name %>">
14 15 <div class="button-bar">
15 16 <%= modal_button 'help', _('Help on this block'),
16 17 {:action => 'show_block_type_info', :type => block.name},
... ...
plugins/container_block/public/style.css
... ... @@ -60,3 +60,6 @@
60 60 #box-organizer.shadow .container-block-plugin_container-block {
61 61 opacity: 1;
62 62 }
  63 +#content #box-organizer .container-block-plugin_container-block {
  64 + padding-top: 20px;
  65 +}
... ...
public/javascripts/block-store.js
  1 +function filterBlocks() {
  2 + jQuery('#block-store #block-types').slick('slickFilter', function() {
  3 + var name = $(this).data('block-name');
  4 + var filter = $('#block-store #block-store-filter').val();
  5 + return name.toLowerCase().indexOf(filter.toLowerCase()) > -1;
  6 + });
  7 +}
  8 +
1 9 function cloneDraggableBlock(el, blockIcon) {
2 10 el.addClass('ui-draggable-dragging');
3 11 return blockIcon;
... ... @@ -13,29 +21,30 @@ function stopDragBlock() {
13 21 }
14 22  
15 23 function initBlockStore() {
  24 + jQuery('#block-store').show();
16 25 var store = jQuery('#block-store #block-types').slick({
17   - infinite: true,
  26 + infinite: false,
18 27 dots: true,
19 28 draggable: false,
20 29 respondTo: 'slider',
21 30 slidesToShow: 7,
22   - slidesToScroll: 4,
  31 + slidesToScroll: 6,
23 32 responsive: [
24 33 {
25 34 breakpoint: 2048,
26 35 settings: {
27 36 slidesToShow: 10,
28   - slidesToScroll: 4,
  37 + slidesToScroll: 9,
29 38 }
30 39 },
31 40 {
32 41 breakpoint: 1024,
33 42 settings: {
34 43 slidesToShow: 8,
35   - slidesToScroll: 4,
  44 + slidesToScroll: 7,
36 45 }
37 46 }
38 47 ]
39 48 });
40   - jQuery('#block-store').show();
  49 + jQuery('#block-store #block-store-filter').keyup(filterBlocks);
41 50 }
... ...
public/stylesheets/block-store.css
... ... @@ -27,6 +27,13 @@
27 27 /************************************************
28 28 * block store styles
29 29 ************************************************/
  30 +#block-store #block-store-filter {
  31 + float: right;
  32 + margin-bottom: 8px;
  33 +}
  34 +#block-store #block-types {
  35 + clear: both;
  36 +}
30 37 #block-store {
31 38 display: none;
32 39 }
... ...
test/functional/profile_design_controller_test.rb
... ... @@ -362,6 +362,12 @@ class ProfileDesignControllerTest &lt; ActionController::TestCase
362 362 assert_tag :tag => 'a', :content => 'Back to control panel'
363 363 end
364 364  
  365 + should 'display avaliable blocks in alphabetical order' do
  366 + @controller.stubs(:available_blocks).returns([TagsBlock, ArticleBlock])
  367 + get :index, :profile => 'designtestuser'
  368 + assert_equal assigns(:available_blocks), [ArticleBlock, TagsBlock]
  369 + end
  370 +
365 371 should 'not allow products block if environment do not let' do
366 372 env = Environment.default
367 373 env.disable('products_for_enterprises')
... ...