Skip to content
Snippets Groups Projects
Commit bf47814d authored by Antonio De Marco's avatar Antonio De Marco
Browse files

Fix layout rendering #80

parent 3a322a26
No related branches found
No related tags found
No related merge requests found
Showing
with 72 additions and 39 deletions
......@@ -4,6 +4,7 @@ namespace Drupal\ui_patterns_layouts\Plugin\Layout;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Layout\LayoutDefinition;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\ui_patterns\UiPatternsManager;
......@@ -30,12 +31,12 @@ class PatternLayout extends LayoutDefault implements PluginFormInterface, Contai
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* @param \Drupal\Core\Layout\LayoutDefinition $plugin_definition
* The plugin implementation definition.
* @param \Drupal\ui_patterns\UiPatternsManager $pattern_manager
* Pattern manager service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, UiPatternsManager $pattern_manager) {
public function __construct(array $configuration, $plugin_id, LayoutDefinition $plugin_definition, UiPatternsManager $pattern_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->patternManager = $pattern_manager;
}
......@@ -57,7 +58,6 @@ class PatternLayout extends LayoutDefault implements PluginFormInterface, Contai
*/
public function build(array $regions) {
$configuration = $this->getConfiguration();
$definition = $this->getPluginDefinition();
// Remove default field template if "Only content" option has been selected.
if ($configuration['pattern']['field_templates'] == 'only_content') {
......@@ -72,7 +72,7 @@ class PatternLayout extends LayoutDefault implements PluginFormInterface, Contai
return [
'#type' => 'pattern',
'#id' => $definition['pattern'],
'#id' => $this->getPluginDefinition()->get('additional')['pattern'],
'#fields' => $fields,
];
}
......
......@@ -12,7 +12,7 @@ use Drupal\Core\Layout\LayoutDefinition;
* Implements hook_layout_alter().
*/
function ui_patterns_layouts_layout_alter(&$definitions) {
// @todo: Use layout deriver instead.
$pattern_definitions = \Drupal::service('plugin.manager.ui_patterns')->getDefinitions();
foreach ($pattern_definitions as $pattern_definition) {
$definition = [
......@@ -24,8 +24,8 @@ function ui_patterns_layouts_layout_alter(&$definitions) {
'pattern' => $pattern_definition['id'],
'template' => 'pattern-' . $pattern_definition['id'],
];
foreach ($pattern_definition['fields'] as $field_name => $field) {
$definition['regions'][$field_name]['label'] = $field['label'];
foreach ($pattern_definition['fields'] as $field) {
$definition['regions'][$field['name']]['label'] = $field['label'];
}
$definitions['pattern_' . $pattern_definition['id']] = new LayoutDefinition($definition);
}
......
......@@ -13,6 +13,8 @@ dependencies:
module:
- comment
- image
- link
- paragraphs
- path
- text
id: node.article.default
......@@ -28,45 +30,76 @@ content:
summary_rows: 3
placeholder: ''
third_party_settings: { }
region: content
comment:
type: comment_default
weight: 20
weight: 8
settings: { }
third_party_settings: { }
region: content
created:
type: datetime_timestamp
weight: 10
weight: 5
settings: { }
third_party_settings: { }
region: content
field_image:
type: image_image
weight: 4
weight: 3
settings:
progress_indicator: throbber
preview_image_style: thumbnail
third_party_settings: { }
region: content
field_links:
type: link_default
weight: 11
region: content
settings:
placeholder_url: ''
placeholder_title: ''
third_party_settings: { }
field_paragraphs:
type: entity_reference_paragraphs
weight: 10
region: content
settings:
title: Paragraph
title_plural: Paragraphs
edit_mode: open
add_mode: dropdown
form_display_mode: default
default_paragraph_type: ''
third_party_settings: { }
field_tags:
type: entity_reference_autocomplete_tags
weight: 3
settings: { }
weight: 2
settings:
match_operator: CONTAINS
size: 60
placeholder: ''
third_party_settings: { }
region: content
path:
type: path
weight: 30
weight: 9
settings: { }
third_party_settings: { }
region: content
promote:
type: boolean_checkbox
settings:
display_label: true
weight: 15
weight: 6
third_party_settings: { }
region: content
sticky:
type: boolean_checkbox
settings:
display_label: true
weight: 16
weight: 7
third_party_settings: { }
region: content
title:
type: string_textfield
weight: 0
......@@ -74,14 +107,14 @@ content:
size: 60
placeholder: ''
third_party_settings: { }
region: content
uid:
type: entity_reference_autocomplete
weight: 5
weight: 4
settings:
match_operator: CONTAINS
size: 60
placeholder: ''
third_party_settings: { }
hidden:
field_links: true
field_paragraphs: true
region: content
hidden: { }
......@@ -17,6 +17,7 @@ content:
placeholder: ''
third_party_settings: { }
type: string_textarea
region: content
field_title:
weight: 0
settings:
......@@ -24,6 +25,7 @@ content:
placeholder: ''
third_party_settings: { }
type: string_textfield
region: content
hidden:
created: true
status: true
......
......@@ -27,6 +27,7 @@ content:
settings: { }
third_party_settings: { }
label: hidden
region: content
comment:
type: comment_default
weight: 110
......@@ -35,6 +36,7 @@ content:
view_mode: default
pager_id: 0
third_party_settings: { }
region: content
field_image:
type: image
weight: -1
......@@ -43,6 +45,7 @@ content:
image_link: ''
third_party_settings: { }
label: hidden
region: content
field_tags:
type: entity_reference_label
weight: 10
......@@ -50,8 +53,10 @@ content:
settings:
link: true
third_party_settings: { }
region: content
links:
weight: 100
region: content
hidden:
field_image: true
field_links: true
......
......@@ -120,6 +120,7 @@ content:
plugin: ds_field_template
source: body
label: hidden
region: content
field_image:
type: image
weight: 1
......@@ -135,6 +136,7 @@ content:
lb-col: false
classes: { }
label: hidden
region: content
field_links:
type: link
weight: 4
......@@ -163,6 +165,7 @@ content:
weight: 1
plugin: ds_field_template
source: field_links__title
region: content
field_paragraphs:
type: entity_reference_revisions_entity_view
weight: 3
......@@ -171,6 +174,7 @@ content:
view_mode: default
link: ''
third_party_settings: { }
region: content
field_tags:
type: entity_reference_label
weight: 9
......@@ -180,6 +184,7 @@ content:
third_party_settings:
ds:
ds_limit: ''
region: content
hidden:
comment: true
links: true
......@@ -11,8 +11,7 @@ third_party_settings:
ds:
layout:
id: pattern_jumbotron
path: null
library: ''
library: null
disable_css: false
entity_classes: all_classes
settings:
......@@ -29,18 +28,20 @@ bundle: jumbotron
mode: default
content:
field_subtitle:
type: basic_string
weight: 1
label: above
region: subtitle
label: hidden
settings: { }
third_party_settings: { }
type: basic_string
field_title:
type: string
weight: 0
label: above
region: title
label: hidden
settings:
link_to_entity: false
third_party_settings: { }
type: string
hidden:
created: true
uid: true
excluded:
- block.block.ui_patterns_test_theme_account_menu
- block.block.ui_patterns_test_theme_branding
- block.block.ui_patterns_test_theme_breadcrumbs
- block.block.ui_patterns_test_theme_content
- block.block.ui_patterns_test_theme_footer
- block.block.ui_patterns_test_theme_help
- block.block.ui_patterns_test_theme_local_actions
- block.block.ui_patterns_test_theme_local_tasks
- block.block.ui_patterns_test_theme_main_menu
- block.block.ui_patterns_test_theme_messages
- block.block.ui_patterns_test_theme_powered
- block.block.ui_patterns_test_theme_search
- block.block.ui_patterns_test_theme_tools
- ui_patterns_test_theme.settings
required: true
......@@ -30,8 +30,8 @@ dependencies:
- ui_patterns_ds
- ui_patterns_field_group
- ui_patterns_layouts
- ui_patterns_views
- ui_patterns_library
- ui_patterns_views
- user
- views
- views_ui
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment