소스 검색

Add the ability to set up the top & bottom blocks classes

Hugo Briand 11 년 전
부모
커밋
0f195300c6
3개의 변경된 파일20개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 0
      DependencyInjection/Configuration.php
  2. 16 0
      Resources/doc/reference/dashboard.rst
  3. 3 5
      Resources/views/Core/dashboard.html.twig

+ 1 - 0
DependencyInjection/Configuration.php

@@ -118,6 +118,7 @@ class Configuration implements ConfigurationInterface
                                         ->prototype('variable')->defaultValue(array())->end()
                                     ->end()
                                     ->scalarNode('position')->defaultValue('right')->end()
+                                    ->scalarNode('class')->defaultValue('col-md-4')->end()
                                 ->end()
                             ->end()
                         ->end()

+ 16 - 0
Resources/doc/reference/dashboard.rst

@@ -295,3 +295,19 @@ LEFTLEFTLEF CENTERCENTE RIGHTRIGHTRI
 LEFTLEFTLEF CENTERCENTE RIGHTRIGHTRI
 
 BOTTOMBOTTOMBOTTOMBOTTOMBOTTOMBOTTOM
+
+On ``top`` and ``bottom`` positions, you can also specify an optionnal ``class`` option to set the width of the block.
+
+.. configuration-block::
+
+    .. code-block:: yaml
+
+        # app/config/config.yml
+        sonata_admin:
+            dashboard:
+                blocks:
+                    # display one dashboard block in the top zone with a col-md-6 HTML class
+                    -
+                        position: top
+                        class: col-md-6
+                        type: sonata.admin.block.admin_list

+ 3 - 5
Resources/views/Core/dashboard.html.twig

@@ -18,10 +18,9 @@ file that was distributed with this source code.
     {{ sonata_block_render_event('sonata.admin.dashboard.top', { 'admin_pool': admin_pool }) }}
 
     {% if blocks.top|length > 0 %}
-        {% set class = 'col-md-' ~ 12 // blocks.top|length %}
         <div class="row">
             {% for block in blocks.top %}
-                <div class="{{ class }}">
+                <div class="{{ block.class }}">
                     {{ sonata_block_render({ 'type': block.type, 'settings': block.settings}) }}
                 </div>
             {% endfor %}
@@ -31,7 +30,7 @@ file that was distributed with this source code.
     <div class="row">
         {% set has_center = false %}
 
-        <div class="{% if blocks.center|length > 0 %}col-md-3{% else %}col-md-6{% endif %}">
+        <div class="{% if blocks.center|length > 0 %}col-md-4{% else %}col-md-6{% endif %}">
             {% for block in blocks.left %}
                 {{ sonata_block_render({ 'type': block.type, 'settings': block.settings}) }}
             {% endfor %}
@@ -53,10 +52,9 @@ file that was distributed with this source code.
     </div>
 
     {% if blocks.bottom|length > 0 %}
-        {% set class = 'col-md-' ~ 12 // blocks.bottom|length %}
         <div class="row">
             {% for block in blocks.bottom %}
-                <div class="{{ class }}">
+                <div class="{{ block.class }}">
                     {{ sonata_block_render({ 'type': block.type, 'settings': block.settings}) }}
                 </div>
             {% endfor %}