unlcms / project-herbie

Drupal 10 implementation at the University of Nebraska–Lincoln
https://cms.unl.edu
GNU General Public License v2.0
5 stars 6 forks source link

Create Cards Block Type #90

Closed macburgee1 closed 4 years ago

macburgee1 commented 4 years ago

Fields:

Use field descriptions to provide guidance how to use certain fields, such as overline vs subhead and CTAs. If both Headline Link and CTA are populated, then uses markup element and #states to display warning message.

todo - Decide if images that are in transparent presentation should have option to present with/without border.

macburgee1 commented 4 years ago

image

image

image

image

image

image

image

image

image

image

image

image

image

image

image

macburgee1 commented 4 years ago

Blocked by #99

macburgee1 commented 4 years ago

Taking back to implement dcf-inverse changes in #110

macburgee1 commented 4 years ago

Changes made

ericras commented 4 years ago

1 No Contextual Edit button

When editing a node through the layout tab there is no contextual button to edit an existing card.

2 Headline vs Title

Is there a reason to have a separate Headline field instead of using Title for that purpose? If there needs to be both (so the Title can be used on the administrative side?) then the Display Title checkbox doesn't make sense since it doesn't display regardless.

macburgee1 commented 4 years ago

Re #1, that's a Drupal core issue: Contextual links of reusable content blocks are not displayed when rendering entities built via Layout Builder.

Re #2, I believe the Inline Block Title Automatic module addresses this issue.

My vote is that we defer #1 with a follow-up issue and include #2 with this PR (with the latter subject to review under this PR).

ericras commented 4 years ago

3 Unable to add image

TypeError: Argument 3 passed to _block_form_alter_block_type_form_alter_invoke() must be of the type string, null given, called in /Library/WebServer/Documents/workspace/herbiesandbox/web/modules/contrib/block_form_alter/block_form_alter.module on line 84 in _block_form_alter_block_type_form_alter_invoke() (line 98 of /Library/WebServer/Documents/workspace/herbiesandbox/web/modules/contrib/block_form_alter/block_form_alter.module) #0

macburgee1 commented 4 years ago

Interesting.. can you provide steps to reproduce? Argument 3 should be a form_id string, I believe...

ericras commented 4 years ago

We'll need to follow up on (1) because not being able to edit existing content is a pretty big deal.

I think that module for (2) looks good. My first inclination is to not have a headline field and just use the title.... but for consistency with reusable blocks where that's used for the administrative block description, I think that module makes sense.

ericras commented 4 years ago

3 - I'm just creating a card inside the layout builder. Then uploading an image and writing alt text. Then when I click "Add Block" nothing happens visually, the ajax call returns:

AjaxError: 
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /workspace/herbiesandbox/web/layout_builder/add/block/overrides/node.4/0/content/inline_block%3Acard?_wrapper_format=drupal_dialog&ajax_form=1
StatusText: OK
ResponseText: 

and the thing before was the PHP error that was logged

ericras commented 4 years ago

3 - during the ajax photo upload it works fine and $block_type = 'card'. But when the "Add Block" button is clicked then block_type = null. This only happens when a photo has been added. If a photo is not included I can create a card.

macburgee1 commented 4 years ago

Ok. I'll look in to that

ericras commented 4 years ago

Upon clicking "Add Block", block_form_alter_form_alter() is not executed if I've added an image so that temp value (block_form_alter--block-type) doesn't get created. Can't figure out why yet

ericras commented 4 years ago

A fix I came up with without fully understanding the flow is that _block_form_alter_block_type_form_alter_inline_block_process() needs to be able to generate $block_type.

function _block_form_alter_block_type_form_alter_inline_block_process(array &$element, FormStateInterface &$form_state) {

  // START copied from block_form_alter_form_alter 
  $build_info = $form_state->getBuildInfo();
  $block = $build_info['callback_object']->getCurrentComponent();
  $component_config = $block->get('configuration');

  $block_id = explode(':', $component_config['id']);
  $plugin_id = $block_id[0];

  // Inline blocks.
  if ($plugin_id == 'inline_block') {
    $block_type = $block_id[1];
  }
  // END copied from block_form_alter_form_alter 

  $block_type = isset($form_state->getTemporaryValue('block_form_alter--block-type')) ? $form_state->getTemporaryValue('block_form_alter--block-type') : $block_type;
  _block_form_alter_block_type_form_alter_invoke($element, $form_state, $block_type);
  return $element;
}

EDIT: does $block_type need to ever be set in hook_form_alter() and stored with setTemporaryValue or can it just always be generated in _block_form_alter_block_type_form_alter_inline_block_process() ?

macburgee1 commented 4 years ago

The Block Form Alter issue was addressed here: https://www.drupal.org/project/block_form_alter/issues/3074355

macburgee1 commented 4 years ago

I believe I misunderstood the contextual links issue. The aforementioned core issue is to render contextual links on the front end (e.g. /node/1), whereas the actual issue was that contextual links failed to render in layout builder (e.g. /node/1/layout). This issue was caused by missing markup in block--block-content-card.html.twig. I added back {{ title_prefix }} and {{ title_suffix }} to resolve the issue.

macburgee1 commented 4 years ago

The Inline Block Title Automatic has been added. I believe all issues raised during the PR review have been addressed.