Skip to content

Commit

Permalink
VACMC-19551: CLP draft promos (#19640)
Browse files Browse the repository at this point in the history
* VACMS-19551: Updates Promo blocks widget config for CLP

* VACMS-19551: adding patches

* VACMS-19551: Adds latest revision option as true to entity browser

* VACMS-19551: Updates composer.lock

* VACMS-19551: Updates composer.lock

* VACMS-19551: Updates from main.

* VACMS-19551: Updates composer.lock

* VACMS-19551: Updates the form and field config for promos

* VACMS-19551: updated patch for entity_browser

* VACMS-19551: updated patch

* VACMS-19551: Updates code that was preventing block removal

* VACMS-19551: Updates composer.lock

* VACMS-19551: updated patch for entity browser

* VACMS-19551: Updates Cypress (with TODO)

* VACMS-19551: Adds test steps

* VACMS-19551: Gets the Cypress test working

* VACMS-19551: Removing the IEF-based test

* VACMS-19551: Updates Cypress with new waits

* VACMS-19551: Updates composer.lock

* VACMS-19551: Updates composer.lock again

---------

Co-authored-by: Edmund Dunn <[email protected]>
  • Loading branch information
omahane and edmund-dunn authored Dec 6, 2024
1 parent 2e8855d commit 428854d
Show file tree
Hide file tree
Showing 11 changed files with 1,689 additions and 486 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@
},
"drupal/entity_browser": {
"2856138 - Entity browser cardinality validation": "patches/2856138-entity-browser-cardinality-validation.patch",
"3191302 - Make modal iframe tab accessible": "patches/3191302-make-modal-iframe-tab-accessible.patch"
"3191302 - Make modal iframe tab accessible": "patches/3191302-make-modal-iframe-tab-accessible.patch",
"3483265 - Make it possible to show latest revision in form widget": "patches/3483265-make-it-possible-to-show-latest-revision-in-fomr-widget.patch"
},
"drupal/entity_browser_table": {
"3194622 - Custom field validation should not be applied to remove button": "patches/3794622-limit-remove-button-validators.patch",
Expand Down
591 changes: 172 additions & 419 deletions composer.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ status: true
dependencies:
config:
- entity_browser.browser.audiences_checkboxes
- entity_browser.browser.events_browser
- entity_browser.browser.promo_blocks_browser
- field.field.node.campaign_landing_page.field_administration
- field.field.node.campaign_landing_page.field_benefit_categories
- field.field.node.campaign_landing_page.field_clp_audience
Expand Down Expand Up @@ -48,6 +48,7 @@ dependencies:
- node.type.campaign_landing_page
- workflows.workflow.editorial
module:
- change_labels
- content_moderation
- entity_browser
- entity_browser_entity_form
Expand Down Expand Up @@ -320,6 +321,7 @@ content:
field_widget_display_settings: { }
additional_fields:
options: null
show_latest_revision: false
third_party_settings:
limited_field_widgets:
limit_values: 2
Expand All @@ -336,6 +338,7 @@ content:
open: false
field_widget_display_settings: { }
selection_mode: selection_append
show_latest_revision: false
third_party_settings: { }
field_clp_events_header:
type: string_textfield_with_counter
Expand Down Expand Up @@ -375,6 +378,7 @@ content:
field_widget_replace: 0
additional_fields:
options: null
show_latest_revision: false
third_party_settings: { }
field_clp_faq_cta:
type: paragraphs
Expand Down Expand Up @@ -729,26 +733,26 @@ content:
textcount_status_message: '<span class="remaining_count">@remaining_count</span> characters remaining'
third_party_settings: { }
field_clp_what_you_can_do_promos:
type: inline_entity_form_complex_table_view_mode
type: entity_reference_browser_table_widget
weight: 7
region: content
settings:
form_mode: default
override_labels: true
label_singular: Promo
label_plural: Promos
allow_new: true
allow_existing: true
match_operator: CONTAINS
allow_duplicate: false
collapsible: false
collapsed: false
revision: true
removed_reference: optional
allow_system_delete: false
entity_browser: promo_blocks_browser
field_widget_display: linked_title
field_widget_display_settings:
target_blank: '1'
field_widget_edit: '1'
field_widget_remove: '1'
show_latest_revision: '1'
selection_mode: selection_append
additional_fields:
options:
status: status
field_widget_replace: 0
open: 0
third_party_settings:
entity_browser_entity_form:
entity_browser_id: promo_blocks_browser
change_labels:
add_another: ''
field_clp_why_this_matters:
type: string_textarea_with_counter
weight: 2
Expand Down
15 changes: 13 additions & 2 deletions config/sync/entity_browser.browser.promo_blocks_browser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies:
config:
- views.view.custom_block_entity_browsers
module:
- entity_browser_entity_form
- views
name: promo_blocks_browser
label: 'Promo blocks browser'
Expand All @@ -16,16 +17,26 @@ display_configuration:
auto_open: false
selection_display: no_display
selection_display_configuration: { }
widget_selector: single
widget_selector: tabs
widget_selector_configuration: { }
widgets:
03832723-7601-4ed8-82e3-09617277e3bb:
id: view
uuid: 03832723-7601-4ed8-82e3-09617277e3bb
label: ''
label: 'Add existing promo'
weight: 1
settings:
submit_text: 'Select promo'
auto_select: false
view: custom_block_entity_browsers
view_display: entity_browser_2
0fd08d3a-6f12-4949-8672-19dd8d928877:
id: entity_form
uuid: 0fd08d3a-6f12-4949-8672-19dd8d928877
label: 'Add new promo'
weight: 2
settings:
submit_text: 'Save promo'
entity_type: block_content
bundle: promo
form_mode: default
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ dependencies:
- node.type.campaign_landing_page
module:
- entity_reference_validators
- tmgmt_content
third_party_settings:
entity_reference_validators:
circular_reference: false
circular_reference_deep: false
duplicate_reference: true
tmgmt_content:
excluded: false
id: node.campaign_landing_page.field_clp_what_you_can_do_promos
field_name: field_clp_what_you_can_do_promos
entity_type: node
Expand All @@ -29,6 +33,7 @@ settings:
promo: promo
sort:
field: _none
auto_create: false
direction: ASC
auto_create: true
auto_create_bundle: ''
field_type: entity_reference
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function __construct(
UserPermsService $user_perms_service,
WorkflowContentControl $workflow_content_control,
Flagger $flagger,
NotificationsManager $notifications_manager
NotificationsManager $notifications_manager,
) {
$this->entityTypeManager = $entity_type_manager;
$this->userPermsService = $user_perms_service;
Expand Down Expand Up @@ -351,7 +351,7 @@ protected function getIefTypeFields(NodeInterface $node): array {
$field_displays = $form_display->toArray();

foreach ($field_displays['content'] as $field_name => $field_display) {
if ($this->isNodeIef($node, $field_name)) {
if ($this->isNodeOrBlockIef($node, $field_name)) {
$operations = [
'field_widget_edit' => !empty($field_display['settings']['field_widget_edit']),
'field_widget_remove' => !empty($field_display['settings']['field_widget_remove']),
Expand All @@ -366,7 +366,7 @@ protected function getIefTypeFields(NodeInterface $node): array {
}

/**
* Checks to see if a field is an entity reference that targets a node.
* Determines whether an entity reference targets a node or content block.
*
* @param \Drupal\node\NodeInterface $node
* The node object.
Expand All @@ -376,7 +376,7 @@ protected function getIefTypeFields(NodeInterface $node): array {
* @return bool
* TRUE if it is an ief field targeting a node, FALSE otherwise.
*/
protected function isNodeIef(NodeInterface $node, $field_name): bool {
protected function isNodeOrBlockIef(NodeInterface $node, $field_name): bool {
$field_definition = $node->getFieldDefinition($field_name);
if (empty($field_definition)) {
return FALSE;
Expand All @@ -388,7 +388,7 @@ protected function isNodeIef(NodeInterface $node, $field_name): bool {
];
$target_type = $field_definition->getItemDefinition()->getSettings()['target_type'] ?? '';

return (in_array($fieldType, $field_types_for_ief)) && ($target_type === "node");
return (in_array($fieldType, $field_types_for_ief)) && ($target_type === "node" || $target_type === "block_content");
}

/**
Expand Down
Loading

0 comments on commit 428854d

Please sign in to comment.