Skip to content
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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and

## [Unreleased]

## [0.2.0] - 2026-05-05

### Added
- **Format IDs** setting and `format_ids` shortcode/block attribute to lock the widget to specific BMLT format IDs (single ID or comma-separated list). Supported globally via the settings form, per-block via the block config form, and per-shortcode via `[crumb format_ids="17,54"]`.

## [0.1.0] - 2026-04-26

Initial release. Wraps the [Crumb meeting finder widget](https://github.com/bmlt-enabled/crumb-widget) for Drupal 10.3+ / 11.
Expand All @@ -26,5 +31,6 @@ Initial release. Wraps the [Crumb meeting finder widget](https://github.com/bmlt
- Crumb logo (`crumb-logo.svg`) and project icon (`icon-256x256.png`).
- `LICENSE.txt` (GPL-2.0-or-later) — required for drupal.org publication.

[Unreleased]: https://github.com/bmlt-enabled/crumb-drupal/compare/v0.1.0...HEAD
[Unreleased]: https://github.com/bmlt-enabled/crumb-drupal/compare/v0.2.0...HEAD
[0.2.0]: https://github.com/bmlt-enabled/crumb-drupal/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/bmlt-enabled/crumb-drupal/releases/tag/v0.1.0
1 change: 1 addition & 0 deletions config/install/crumb.settings.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
server: 'https://latest.aws.bmlt.app/main_server/'
service_body: '1047,1048'
format_ids: ''
view: ''
css_template: ''
base_path: ''
Expand Down
6 changes: 6 additions & 0 deletions config/schema/crumb.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ crumb.settings:
service_body:
type: string
label: 'Service Body IDs'
format_ids:
type: string
label: 'Format IDs'
view:
type: string
label: 'Default view'
Expand All @@ -31,6 +34,9 @@ block.settings.crumb_widget:
service_body:
type: string
label: 'Service Body IDs override'
format_ids:
type: string
label: 'Format IDs override'
view:
type: string
label: 'View override'
Expand Down
4 changes: 4 additions & 0 deletions src/CrumbRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function build(array $overrides = []): array {
}

$service_body = $overrides['service_body'] ?? $config->get('service_body');
$format_ids = $overrides['format_ids'] ?? $config->get('format_ids');
$view_raw = $overrides['view'] ?? $config->get('view') ?? '';
$view = in_array($view_raw, self::ALLOWED_VIEWS, TRUE) ? $view_raw : '';
$base_path = trim((string) ($config->get('base_path') ?? ''), '/');
Expand All @@ -50,6 +51,9 @@ public function build(array $overrides = []): array {
if ($service_body !== NULL && $service_body !== '') {
$attributes['data-service-body'] = trim((string) $service_body);
}
if ($format_ids !== NULL && $format_ids !== '') {
$attributes['data-format-ids'] = trim((string) $format_ids);
}
if ($view !== '') {
$attributes['data-view'] = $view;
}
Expand Down
9 changes: 9 additions & 0 deletions src/Form/CrumbSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public function buildForm(array $form, FormStateInterface $form_state): array {
'#placeholder' => '42 or 42,57,103',
];

$form['format_ids'] = [
'#type' => 'textfield',
'#title' => $this->t('Format IDs'),
'#description' => $this->t('Optional. Single ID or comma-separated list of BMLT format IDs to lock the widget to. Leave empty to show all formats. Can be overridden per-block or per-shortcode.'),
'#default_value' => $config->get('format_ids') ?? '',
'#placeholder' => '17 or 17,54,78',
];

$form['css_template'] = [
'#type' => 'select',
'#title' => $this->t('CSS Template'),
Expand Down Expand Up @@ -156,6 +164,7 @@ public function submitForm(array &$form, FormStateInterface $form_state): void {
$this->config('crumb.settings')
->set('server', trim((string) $form_state->getValue('server')))
->set('service_body', trim((string) $form_state->getValue('service_body')))
->set('format_ids', trim((string) $form_state->getValue('format_ids')))
->set('css_template', (string) $form_state->getValue('css_template'))
->set('base_path', trim((string) $form_state->getValue('base_path'), "/ \t\n\r\0\x0B"))
->set('view', (string) $form_state->getValue('view'))
Expand Down
13 changes: 12 additions & 1 deletion src/Plugin/Block/CrumbBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function defaultConfiguration(): array {
return [
'server' => '',
'service_body' => NULL,
'format_ids' => '',
'view' => '',
'geolocation' => '',
] + parent::defaultConfiguration();
Expand All @@ -72,6 +73,13 @@ public function blockForm($form, FormStateInterface $form_state): array {
'#description' => $this->t('Optional. Single ID or comma-separated. Leave blank to inherit; enter a single space to explicitly omit and show all meetings.'),
'#default_value' => $config['service_body'] ?? '',
];
$form['format_ids'] = [
'#type' => 'textfield',
'#title' => $this->t('Format IDs'),
'#description' => $this->t('Optional. Single ID or comma-separated. Leave blank to inherit from global settings.'),
'#default_value' => $config['format_ids'] ?? '',
'#placeholder' => '17 or 17,54,78',
];
$form['view'] = [
'#type' => 'select',
'#title' => $this->t('Default view'),
Expand Down Expand Up @@ -100,7 +108,7 @@ public function blockForm($form, FormStateInterface $form_state): array {
* {@inheritdoc}
*/
public function blockSubmit($form, FormStateInterface $form_state): void {
foreach (['server', 'service_body', 'view', 'geolocation'] as $key) {
foreach (['server', 'service_body', 'format_ids', 'view', 'geolocation'] as $key) {
$this->configuration[$key] = $form_state->getValue($key);
}
}
Expand All @@ -119,6 +127,9 @@ public function build(): array {
if (isset($config['service_body']) && $config['service_body'] !== '') {
$overrides['service_body'] = trim($config['service_body']);
}
if (isset($config['format_ids']) && $config['format_ids'] !== '') {
$overrides['format_ids'] = trim($config['format_ids']);
}
if (!empty($config['view'])) {
$overrides['view'] = $config['view'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Filter/CrumbFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function process($text, $langcode): FilterProcessResult {
*/
public function tips($long = FALSE) {
if ($long) {
return $this->t('Use <code>[crumb]</code> to embed the Crumb meeting finder. Optional attributes: <code>server</code>, <code>service_body</code>, <code>view</code>, <code>geolocation</code>. Example: <code>[crumb server="https://your-server/main_server" service_body="42" view="map" geolocation="true"]</code>');
return $this->t('Use <code>[crumb]</code> to embed the Crumb meeting finder. Optional attributes: <code>server</code>, <code>service_body</code>, <code>format_ids</code>, <code>view</code>, <code>geolocation</code>. Example: <code>[crumb server="https://your-server/main_server" service_body="42" format_ids="17,54" view="map" geolocation="true"]</code>');
}
return $this->t('Use [crumb] to embed the meeting finder.');
}
Expand Down
21 changes: 21 additions & 0 deletions tests/src/Unit/CrumbRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ private function makeRenderer(array $settings = []): CrumbRenderer {
$defaults = [
'server' => 'https://example.com/main_server/',
'service_body' => '42',
'format_ids' => '',
'view' => '',
'css_template' => '',
'base_path' => '',
Expand Down Expand Up @@ -86,6 +87,26 @@ public function testEmptyServiceBodyOverrideOmitsAttribute(): void {
);
}

public function testFormatIdsOverrideAddsAttribute(): void {
$build = $this->makeRenderer()->build(['format_ids' => '17,54']);
$this->assertSame('17,54', $build['widget']['#attributes']['data-format-ids']);
}

public function testFormatIdsFromConfigAddsAttribute(): void {
$build = $this->makeRenderer(['format_ids' => '42'])->build();
$this->assertSame('42', $build['widget']['#attributes']['data-format-ids']);
}

public function testEmptyFormatIdsOmitsAttribute(): void {
$build = $this->makeRenderer(['format_ids' => ''])->build();
$this->assertArrayNotHasKey('data-format-ids', $build['widget']['#attributes']);
}

public function testEmptyFormatIdsOverrideOmitsAttribute(): void {
$build = $this->makeRenderer(['format_ids' => '99'])->build(['format_ids' => '']);
$this->assertArrayNotHasKey('data-format-ids', $build['widget']['#attributes']);
}

public function testInvalidViewIsIgnored(): void {
$build = $this->makeRenderer()->build(['view' => 'gallery']);
$this->assertArrayNotHasKey('data-view', $build['widget']['#attributes']);
Expand Down