Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
Merge branch '8.x-2.x' into alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
duozersk committed May 20, 2020
2 parents e8a6ee9 + e040b5d commit f7c3200
Show file tree
Hide file tree
Showing 138 changed files with 2,079 additions and 207 deletions.
13 changes: 8 additions & 5 deletions composer.json
Expand Up @@ -177,7 +177,8 @@
"drupal/core": {
"1236098 - Notice: Undefined index in _color_rewrite_stylesheet()": "https://www.drupal.org/files/issues/undefined-index-in-_color_rewrite_stylesheet-1236098-37.patch",
"2484693 - Telephone Link field formatter InvalidArgumentException with 5 digits or fewer in the number": "https://www.drupal.org/files/issues/2484693-54.patch",
"2862702 - PrepareModulesEntityUninstallForm::formTitle does not exist": "https://www.drupal.org/files/issues/2862702-3.patch"
"2862702 - PrepareModulesEntityUninstallForm::formTitle does not exist": "https://www.drupal.org/files/issues/2862702-3.patch",
"2996114 - JSON:API Argument error": "https://www.drupal.org/files/issues/2020-02-11/2996114-124.patch"
},
"drupal/media_entity": {
"2918172 - Media Entity upgrade -> add revision fields": "https://www.drupal.org/files/issues/2918172-5.patch",
Expand All @@ -202,19 +203,19 @@
}
},
"require": {
"php": ">=5.6",
"php": ">=7.1",
"cweagans/composer-patches": "^1.5.0",
"composer/installers": "^1.0",
"drupal/core-composer-scaffold": "^8.8",
"drupal/core-recommended": "^8.8",
"drupal/features": "3.8",
"drupal/confi": "1.4",
"drupal/config_update": "^1.6",
"drupal/entity": "1.0-rc1",
"drupal/entity": "1.0.0-rc2",
"drupal/media_entity": "2.0.0-beta3",
"drupal/media_entity_image": "1.x-dev",
"drupal/media_entity_document": "1.x-dev",
"drupal/address": "1.4",
"drupal/address": "1.8",
"drupal/paragraphs": "1.6",
"drupal/entity_reference_revisions": "~1.6",
"drupal/pathauto": "~1.6",
Expand Down Expand Up @@ -296,6 +297,8 @@
"drupal/twig_tweak": "^2.4",
"drupal/image_widget_crop": "^2.2",
"drupal/geysir": "^1.1",
"drupal/media_directories": "^1.0"
"drupal/media_directories": "^1.0",
"drupal/editor_advanced_link": "^1.6",
"drupal/link_attributes": "^1.10"
}
}
Empty file added composer.lock
Empty file.
47 changes: 33 additions & 14 deletions modules/custom/openy_ckeditor/openy_ckeditor.module
Expand Up @@ -7,6 +7,7 @@

use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Entity\EntityInterface;
use Drupal\taxonomy\Entity\Term;

/**
* Implements hook_theme().
Expand All @@ -15,7 +16,8 @@ function openy_ckeditor_theme($existing, $type, $theme, $path) {
return [
'list_branch_amenities' => [
'variables' => [
'content' => [],
'amenities_open' => [],
'amenities_closed' => NULL,
],
'template' => 'list-branch-amenities',
],
Expand Down Expand Up @@ -56,22 +58,16 @@ function openy_ckeditor_tokens($type, $tokens, array $data, array $options, Bubb
return $replacements;
}
}
$amenities_ids = [];
foreach ($amenities_values as $id) {
$amenities_ids[] = $id['target_id'];
}
$amenities = \Drupal::service('entity_type.manager')
->getStorage('taxonomy_term')
->loadMultiple($amenities_ids);
$amenities_view = [];
foreach ($amenities as $amenity) {
$amenities_view[] = \Drupal::service('entity.manager')
->getViewBuilder('taxonomy_term')
->view($amenity, 'default');
$has_closed = FALSE;
if ($node->hasField('field_location_amenities_closed')) {
$has_closed = TRUE;
$closed_amenities_values = $node->field_location_amenities_closed->getValue();
}

$render_array = [
'#theme' => 'list_branch_amenities',
'#content' => $amenities_view,
'#amenities_open' => _openy_ckeditor_prepare_amenities_view($amenities_values),
'#amenities_closed' => $has_closed ? _openy_ckeditor_prepare_amenities_view($closed_amenities_values) : [],
];
$replacements[$original] = render($render_array);
break;
Expand All @@ -81,6 +77,29 @@ function openy_ckeditor_tokens($type, $tokens, array $data, array $options, Bubb
return $replacements;
}

/**
* Helper function.
* Prepares list of renderable terms based on reference field value.
*
* @param $field_value
*
* @return array $amenities_view
*/
function _openy_ckeditor_prepare_amenities_view($field_value) {
$amenities_ids = [];
foreach ($field_value as $id) {
$amenities_ids[] = $id['target_id'];
}
$amenities = Term::loadMultiple($amenities_ids);
$amenities_view = [];
foreach ($amenities as $amenity) {
$amenities_view[] = \Drupal::service('entity.manager')
->getViewBuilder('taxonomy_term')
->view($amenity, 'default');
}
return $amenities_view;
}

/**
* Implements hook_page_attachments_alter().
*/
Expand Down
Expand Up @@ -15,17 +15,33 @@
'row',
]
%}

<div{{ attributes.addClass(classes) }}>
{% if content|length %}
{% set amenitiesPerColumn = (content|length / 2)|round(0, 'ceil') %}
{% for amenity in content %}
{% if amenitiesPerColumn == 1 or loop.index % amenitiesPerColumn == 1 %}
<div class="col-md-6">
{% endif %}
{{ amenity }}
{% if loop.last or loop.index % amenitiesPerColumn == 0 %}
</div>
{% endif %}
{% endfor %}
{% if amenities_open|length %}
{% if amenities_closed|length %}
<div class="col-md-6 amenities-open">
<div class="header-amenities">{{ 'What\'s Available'|t }}</div>
{% for amenity in amenities_open %}
{{ amenity }}
{% endfor %}
</div>
<div class="col-md-6 amenities-closed">
<div class="header-amenities">{{ 'What\'s Closed'|t }}</div>
{% for amenity in amenities_closed %}
{{ amenity }}
{% endfor %}
</div>
{% else %}
{% set amenitiesPerColumn = (amenities_open|length / 2)|round(0, 'ceil') %}
{% for amenity in amenities_open %}
{% if amenitiesPerColumn == 1 or loop.index % amenitiesPerColumn == 1 %}
<div class="col-md-6">
{% endif %}
{{ amenity }}
{% if loop.last or loop.index % amenitiesPerColumn == 0 %}
</div>
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
</div>
1 change: 1 addition & 0 deletions modules/custom/openy_data_wrapper/src/DataWrapper.php
Expand Up @@ -224,6 +224,7 @@ public function getLocations() {

$location_ids = $this->queryFactory->get('node')
->condition('type', 'branch')
->addTag('data_wrapper_locations')
->execute();

if (!$location_ids) {
Expand Down
Expand Up @@ -8,7 +8,7 @@ dependencies:
- field.field.block_content.branch_amenities.field_sb_link
- field.field.block_content.branch_amenities.field_sb_title
module:
- link
- link_attributes
id: block_content.branch_amenities.default
targetEntityType: block_content
bundle: branch_amenities
Expand All @@ -27,8 +27,17 @@ content:
settings:
placeholder_url: ''
placeholder_title: ''
enabled_attributes:
target: true
rel: true
class: true
id: false
name: false
accesskey: false
aria-label: false
title: false
third_party_settings: { }
type: link_default
type: link_attributes
region: content
field_sb_title:
weight: 0
Expand Down
@@ -0,0 +1,53 @@
langcode: en
status: true
dependencies:
config:
- field.field.paragraph.branch_amenities.field_amenities_block
- paragraphs.paragraphs_type.branch_amenities
module:
- entity_browser_entity_form
id: paragraph.branch_amenities.default
targetEntityType: paragraph
bundle: branch_amenities
mode: default
content:
field_amenities_block:
type: options_select
weight: 0
region: content
settings: { }
third_party_settings:
entity_browser_entity_form:
entity_browser_id: _none
paragraph_background_color:
type: options_select
weight: -9
region: content
settings: { }
third_party_settings: { }
paragraph_background_image:
type: entity_browser_entity_reference
settings:
entity_browser: images_library
field_widget_display: rendered_entity
field_widget_display_settings:
view_mode: thumbnail_for_preview
open: false
field_widget_edit: true
field_widget_remove: true
field_widget_replace: false
selection_mode: selection_append
weight: -10
region: content
third_party_settings: { }
paragraph_background_overlay:
type: boolean_checkbox
settings:
display_label: true
weight: -8
region: content
third_party_settings: { }
hidden:
created: true
status: true
uid: true
@@ -0,0 +1,22 @@
langcode: en
status: true
dependencies:
config:
- field.field.paragraph.branch_amenities.field_amenities_block
- paragraphs.paragraphs_type.branch_amenities
id: paragraph.branch_amenities.default
targetEntityType: paragraph
bundle: branch_amenities
mode: default
content:
field_amenities_block:
type: entity_reference_entity_view
weight: 0
region: content
label: hidden
settings:
link: true
view_mode: default
third_party_settings: { }
hidden:
search_api_excerpt: true
@@ -0,0 +1,33 @@
langcode: en
status: true
dependencies:
config:
- block_content.type.branch_amenities
- field.storage.paragraph.field_amenities_block
- paragraphs.paragraphs_type.branch_amenities
module:
- datalayer
third_party_settings:
datalayer:
expose: 1
label: field_amenities_block
id: paragraph.branch_amenities.field_amenities_block
field_name: field_amenities_block
entity_type: paragraph
bundle: branch_amenities
label: 'Amenities Block'
description: ''
required: true
translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: 'default:block_content'
handler_settings:
target_bundles:
branch_amenities: branch_amenities
sort:
field: _none
auto_create: false
auto_create_bundle: ''
field_type: entity_reference
@@ -0,0 +1,19 @@
langcode: en
status: true
dependencies:
module:
- block_content
- paragraphs
id: paragraph.field_amenities_block
field_name: field_amenities_block
entity_type: paragraph
type: entity_reference
settings:
target_type: block_content
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: branch_amenities
label: 'Branch Amenities'
icon_uuid: null
description: 'Display Amenities of the current branch'
behavior_plugins: { }
Expand Up @@ -11,6 +11,7 @@ dependencies:
- drupal:field
- drupal:language
- drupal:link
- link_attributes:link_attributes
- openy_block:openy_block
- openy_block_custom_simple:openy_block_custom_simple
- paragraphs:paragraphs
Expand Down
Expand Up @@ -26,3 +26,42 @@ function openy_block_branch_amenities_update_8001() {
}
}
}

/**
* New paragraph with branch amenities.
*/
function openy_block_branch_amenities_update_8002()
{
$config_dir = drupal_get_path('module', 'openy_block_branch_amenities') . '/config/install/';
$config_importer = \Drupal::service('openy_upgrade_tool.importer');
$config_importer->setDirectory($config_dir);
$config_importer->importConfigs([
'paragraphs.paragraphs_type.branch_amenities',
'field.storage.paragraph.field_amenities_block',
'field.field.paragraph.branch_amenities.field_amenities_block',
'core.entity_form_display.paragraph.branch_amenities.default',
'core.entity_view_display.paragraph.branch_amenities.default',
]);
}

/**
* Update Open Y Block Branch Amenities feature to use link attributes widget.
*/
function openy_block_branch_amenities_update_8003() {
$config_dir = drupal_get_path('module', 'openy_block_branch_amenities') . '/config/install/';
// Update multiple configurations.
$configs = [
'core.entity_form_display.block_content.branch_amenities.default' =>[
'content.field_sb_link.settings.enabled_attributes',
'content.field_sb_link.type',
],
];

$config_updater = \Drupal::service('openy_upgrade_tool.param_updater');
foreach ($configs as $config_name => $params) {
$config = $config_dir . $config_name . '.yml';
foreach ($params as $param) {
$config_updater->update($config, $config_name, $param);
}
}
}

0 comments on commit f7c3200

Please sign in to comment.