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

Make banner block type display configurable. #109

Merged
merged 11 commits into from
Mar 30, 2021
Merged

Make banner block type display configurable. #109

merged 11 commits into from
Mar 30, 2021

Conversation

j4-m
Copy link
Contributor

@j4-m j4-m commented Jan 25, 2021

  • Adds a block form which allows admins to choose the alter banner types they want the block to display
  • Use the configuration to filter the queried alter banners before render.

@j4-m j4-m changed the title Make alter banner block type display configurable. Make banner block type display configurable. Jan 25, 2021
* Adds a block form which allows admins to choose the alter banner types they want the block to display
* Use the configuration to filter the queried alter banners before render.
@andybroomfield
Copy link
Contributor

Thanks @Iam-Jam
Do you know why the tests are failing, saying missing schemas?

@j4-m j4-m marked this pull request as draft January 26, 2021 18:39
@j4-m
Copy link
Contributor Author

j4-m commented Jan 26, 2021

Moving to WIP as we'll need to update the tests to cover the new configuration.

@andybroomfield
Copy link
Contributor

Thanks for your work so far @Iam-Jam.
I'm seeing an error on the block configuration screen on first install.

Error message
Warning: Invalid argument supplied for foreach() in Drupal\Core\Render\Element\Checkboxes::valueCallback() (line 100 of core/lib/Drupal/Core/Render/Element/Checkboxes.php).

@j4-m
Copy link
Contributor Author

j4-m commented Jan 27, 2021

No worries @andybroomfield. As of the latest commits, there shouldn't be any errors when saving the configuration form and hopefully the schema issue has been resolve too... just need add some test coverage now.

@j4-m j4-m marked this pull request as ready for review January 27, 2021 16:40
Copy link
Contributor

@andybroomfield andybroomfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your efforts on this @Iam-Jam.

I'm still seeing the following error on the block configuration page when first installing the module.

Error message
Warning: Invalid argument supplied for foreach() in Drupal\Core\Render\Element\Checkboxes::valueCallback() (line 100 of core/lib/Drupal/Core/Render/Element/Checkboxes.php).

To replicate, do a fresh install and enable localgov_alert_banner. Then go to the block configuration screen without having placed a block.
The error will disapear once I save the block for the first time.

Screenshot 2021-01-29 at 1 45 05 pm

Additonal amends:

  • Can we change the label Display types to Banner types to match the admin view.
  • Would it be possible to have the negate this condition option added

@finnlewis
Copy link
Member

I can confirm the same error.
I can't immediately see why the default_value key is just "" when it is expecting an array.
If you can show me how to fix this, I can use it as a debugging demo at OxDUG!

'#options' => $config_options,
'#title' => $this->t('Display types'),
'#description' => $this->t('If no types are selected all will be displayed.'),
'#default_value' => !empty($config['include_types']) ? $config['include_types'] : '',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@finnlewis @Iam-Jam I think this might be what is causing the error.
I think default value should be an array (even if it is null).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep that's it @andybroomfield. I had actually spotted this before but forgot to fix it. Shame this hasn't been picked up in tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm that changing
'#default_value' => !empty($config['include_types']) ? $config['include_types'] : '',
to
'#default_value' => !empty($config['include_types']) ? $config['include_types'] : [],
resolves this issue. If we can get this change added we can get this in a new release.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto. @j4-m could you commit the change to your forked branch?

@finnlewis
Copy link
Member

finnlewis commented Feb 3, 2021

Yes - I got the same place following the debugger and the code changes :)

@andybroomfield
Copy link
Contributor

Hi @j4-m Thanks for your efforts so far. I'm stlll getting the error, did we get anywhere with this?

@j4-m
Copy link
Contributor Author

j4-m commented Mar 30, 2021

@andybroomfield @finnlewis the amendment to the default value has just gone in.

Copy link
Contributor

@andybroomfield andybroomfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error now fixed so clear to merge @j4-m

@j4-m j4-m merged commit 34092d7 into localgovdrupal:master Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support different alert banners in different blocks (either derivers or instance configuration)
3 participants