commit ee066ed54e29ab5bde65ed27955157dcae0bc297 Author: Julien Dubois Date: Fri Jun 24 12:20:06 2016 +0200 ISsue #2079037: Display visibility settings of the blocks in a dedicated column. diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 2f96a90..fdd41a1 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -57,6 +57,9 @@ function block_theme() { 'block' => array( 'render element' => 'elements', ), + 'block_edit_form' => array( + 'render element' => 'form', + ), ); } diff --git a/core/themes/classy/templates/block/block-edit-form.html.twig b/core/themes/classy/templates/block/block-edit-form.html.twig new file mode 100644 index 0000000..de6b3e3 --- /dev/null +++ b/core/themes/classy/templates/block/block-edit-form.html.twig @@ -0,0 +1,30 @@ +{# +/** + * @file + * Theme override for a block edit form. + * + * Two column template for the block add/edit form. + * + * This template will be used when a block edit form specifies 'block_edit_form' + * as its #theme callback. Otherwise, by default, block add/edit forms will be + * themed by form.html.twig. + * + * Available variables: + * - form: The block add/edit form. + * + * @see seven_form_block_form_alter() + */ +#} +
+
+ {{ form|without('visibility', 'actions') }} +
+
+

{{ 'Visibility'|t }}

+ {{ form.visibility.title }} + {{ form.visibility }} +
+ +
diff --git a/core/themes/seven/css/layout/block-add.css b/core/themes/seven/css/layout/block-add.css new file mode 100644 index 0000000..83b6688 --- /dev/null +++ b/core/themes/seven/css/layout/block-add.css @@ -0,0 +1,48 @@ +/** + * @todo Implement the appropriate CSS. This is a copy/paste from + * node.module.css to have the basic layout of the block. + */ +/* Wide screens */ +@media +screen and (min-width: 780px), +(orientation: landscape) and (min-device-height: 780px) { + + .layout-region-block-main, + .layout-region-block-footer { + float: left; /* LTR */ + width: 65%; + padding-right: 2em; /* LTR */ + box-sizing: border-box; + } + + [dir="rtl"] .layout-region-block-main, + [dir="rtl"] .layout-region-block-footer { + float: right; + padding-left: 2em; + padding-right: 0; + } + + .layout-region-block-secondary { + float: right; /* LTR */ + width: 35%; + } + + [dir="rtl"] .layout-region-block-secondary { + float: left; + } + + /* @todo File an issue to add a standard class to all text-like inputs */ + .layout-region-block-secondary .form-autocomplete, + .layout-region-block-secondary .form-text, + .layout-region-block-secondary .form-tel, + .layout-region-block-secondary .form-email, + .layout-region-block-secondary .form-url, + .layout-region-block-secondary .form-search, + .layout-region-block-secondary .form-number, + .layout-region-block-secondary .form-color, + .layout-region-block-secondary textarea { + box-sizing: border-box; + width: 100%; + max-width: 100%; + } +} \ No newline at end of file diff --git a/core/themes/seven/seven.libraries.yml b/core/themes/seven/seven.libraries.yml index a5b6d8a..e8e01df 100644 --- a/core/themes/seven/seven.libraries.yml +++ b/core/themes/seven/seven.libraries.yml @@ -43,6 +43,12 @@ node-form: dependencies: - node/form +block-form: + version: VERSION + css: + layout: + css/layout/block-add.css: {} + maintenance-page: version: VERSION js: diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index 5ace6b8..e342ba1 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -186,3 +186,18 @@ function seven_form_node_form_alter(&$form, FormStateInterface $form_state) { $form['revision_information']['#type'] = 'container'; $form['revision_information']['#group'] = 'meta'; } + +/** + * Implements hook_form_BASE_FORM_ID_alter() for \Drupal\node\NodeForm. + * + * Changes vertical tabs to container and adds meta information. + */ +function seven_form_block_form_alter(&$form, FormStateInterface $form_state) { + $form['#theme'] = array('block_edit_form'); + $form['#attached']['library'][] = 'seven/block-form'; + + // Reparent the conditions options to the container. + foreach ($form['visibility'] as $condition_name => $condition) { + $form['visibility'][$condition_name]['#group'] = 'visibility'; + } +}