Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHS-4998: Add hb-raised-cards--uniform-height as checkbox on collections #1429

Merged
merged 4 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@
"drupal/bricks": {
"https://www.drupal.org/project/bricks/issues/3003176": "https://www.drupal.org/files/issues/2018-09-28/bricks-entity_usage-3003176.patch"
},
"drupal/conditional_fields": {
"https://www.drupal.org/project/conditional_fields/issues/2902164": "https://www.drupal.org/files/issues/2023-09-28/2902164-149.patch"
},
"drupal/config_ignore": {
"https://www.drupal.org/project/config_ignore/issues/2857247": "https://www.drupal.org/files/issues/2020-01-11/support-for-export-2857247-44.patch",
"https://www.drupal.org/project/config_ignore/issues/2865419": "https://www.drupal.org/files/issues/2020-07-20/config_ignore-wildcard_force_import.patch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
config:
- field.field.paragraph.hs_collection.field_hs_collection_items
- field.field.paragraph.hs_collection.field_hs_collection_per_row
- field.field.paragraph.hs_collection.field_hs_collection_uh
- field.field.paragraph.hs_collection.field_paragraph_style
- field.field.paragraph.hs_collection.field_raised_cards
- paragraphs.paragraphs_type.hs_collection
Expand All @@ -17,7 +18,7 @@ mode: default
content:
field_hs_collection_items:
type: paragraphs_browser
weight: 3
weight: 4
region: content
settings:
title: Component
Expand All @@ -36,13 +37,40 @@ content:
paragraphs_browser: content
modal_width: 80%
modal_height: auto
show_group_label: true
show_group_filter: true
third_party_settings: { }
field_hs_collection_per_row:
type: options_select
weight: 0
region: content
settings: { }
third_party_settings: { }
field_hs_collection_uh:
type: boolean_checkbox
weight: 3
region: content
settings:
display_label: true
third_party_settings:
conditional_fields:
d755369a-3372-40fb-896b-2cfddbdaff67:
entity_type: paragraph
bundle: hs_collection
dependee: field_raised_cards
settings:
state: visible
reset: false
condition: checked
grouping: AND
values_set: 1
value: ''
values: { }
value_form:
value: false
effect: show
effect_options: { }
selector: ''
field_paragraph_style:
type: options_select
weight: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
config:
- field.field.paragraph.hs_collection.field_hs_collection_items
- field.field.paragraph.hs_collection.field_hs_collection_per_row
- field.field.paragraph.hs_collection.field_hs_collection_uh
- field.field.paragraph.hs_collection.field_paragraph_style
- field.field.paragraph.hs_collection.field_raised_cards
- paragraphs.paragraphs_type.hs_collection
Expand All @@ -26,6 +27,7 @@ content:
region: content
hidden:
field_hs_collection_per_row: true
field_hs_collection_uh: true
field_paragraph_style: true
field_raised_cards: true
search_api_excerpt: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
uuid: 0297c036-02a9-4fd7-8d37-b9effb034279
langcode: en
status: true
dependencies:
config:
- field.storage.paragraph.field_hs_collection_uh
- paragraphs.paragraphs_type.hs_collection
id: paragraph.hs_collection.field_hs_collection_uh
field_name: field_hs_collection_uh
entity_type: paragraph
bundle: hs_collection
label: 'Uniform Height'
description: 'Applies the uniform height styling to the raised cards. This option is decorative.'
required: false
translatable: false
default_value:
-
value: 1
default_value_callback: ''
settings:
on_label: 'On'
off_label: 'Off'
field_type: boolean
18 changes: 18 additions & 0 deletions config/default/field.storage.paragraph.field_hs_collection_uh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
uuid: c9d0623e-1800-4484-ba92-5fdfb0e22159
langcode: en
status: true
dependencies:
module:
- paragraphs
id: paragraph.field_hs_collection_uh
field_name: field_hs_collection_uh
entity_type: paragraph
type: boolean
settings: { }
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* @file
* Deploy hooks for paragraph components.
*/

/**
* Update existing hs_collection content if raised cards is enabled.
*/
function hs_paragraph_types_deploy_hs_collection_uh_field(&$sandbox) {
$paragraph_storage = \Drupal::entityTypeManager()->getStorage('paragraph');
if (empty($sandbox['ids'])) {
$sandbox['ids'] = $paragraph_storage->getQuery()
->accessCheck(FALSE)
->condition('type', 'hs_collection')
->condition('field_raised_cards', TRUE)
->execute();
$sandbox['total'] = count($sandbox['ids']);
}
$paragraph_ids = array_splice($sandbox['ids'], 0, 10);

/** @var \Drupal\paragraphs\Entity */
foreach($paragraph_storage->loadMultiple($paragraph_ids) as $paragraph) {
$paragraph->set('field_hs_collection_uh', TRUE);
$paragraph->save();
}

$sandbox['#finished'] = count($sandbox['ids']) ? 1 - count($sandbox['ids']) / $sandbox['total'] : 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@
{% if paragraph.field_raised_cards.value == true %}
{% set raised_cards = true %}
{% endif %}
{% if paragraph.field_hs_collection_uh.value == true %}
{% set uniform_height = true %}
{% endif %}
{%
set classes = [
'paragraph',
'paragraph--type--' ~ paragraph.bundle|clean_class,
view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
not paragraph.isPublished() ? 'paragraph--unpublished',
raised_cards ? 'hb-raised-cards hb-raised-cards--uniform-height'
raised_cards ? 'hb-raised-cards',
raised_cards and uniform_height ? 'hb-raised-cards--uniform-height'
]
%}

Expand Down