From b6077c9a6ea423743b9fec1037ed5f41f5a10128 Mon Sep 17 00:00:00 2001 From: "sws-developers@lists.stanford.edu" Date: Thu, 17 Mar 2022 20:58:33 +0000 Subject: [PATCH 1/4] Back to dev --- stanford_fields.info.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stanford_fields.info.yml b/stanford_fields.info.yml index 68fb7be..5e3a5db 100755 --- a/stanford_fields.info.yml +++ b/stanford_fields.info.yml @@ -3,6 +3,6 @@ type: module description: 'Field types, widgets and formatters to enhance Drupal and Contrib.' core_version_requirement: ^8 || ^9 package: Stanford -version: 8.x-1.10 +version: 8.x-1.11-dev dependencies: - drupal:field From 4be7becca9e1c215fec7981872a26f144e3fb9bd Mon Sep 17 00:00:00 2001 From: Ian Monroe Date: Tue, 22 Mar 2022 17:35:23 -0600 Subject: [PATCH 2/4] Updated localist URL references (#26) --- .../Field/FieldWidget/LocalistUrlWidgetTest.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/src/Kernel/Plugin/Field/FieldWidget/LocalistUrlWidgetTest.php b/tests/src/Kernel/Plugin/Field/FieldWidget/LocalistUrlWidgetTest.php index beec1d0..ff7a253 100644 --- a/tests/src/Kernel/Plugin/Field/FieldWidget/LocalistUrlWidgetTest.php +++ b/tests/src/Kernel/Plugin/Field/FieldWidget/LocalistUrlWidgetTest.php @@ -75,7 +75,7 @@ protected function setUp(): void { $entity_form_display->setComponent('su_localist_url', [ 'type' => 'localist_url', 'settings' => [ - 'base_url' => 'https://stanford.enterprise.localist.com', + 'base_url' => 'https://events.stanford.edu', ], ])->removeComponent('created')->save(); @@ -97,7 +97,7 @@ public function testWidgetForm() { $node->set('su_localist_url', [ [ - 'uri' => 'https://stanford.enterprise.localist.com/api/2/events?group_id=37955145294460&days=365', + 'uri' => 'https://events.stanford.edu/api/2/events?group_id=37955145294460&days=365', 'title' => '', 'options' => '', ], @@ -115,7 +115,7 @@ public function testWidgetForm() { $widget_value = $form['su_localist_url']['widget']; $this->assertIsArray($widget_value[0]); - $this->assertEquals('https://stanford.enterprise.localist.com/api/2/events?group_id=37955145294460&days=365', $widget_value[0]['uri']['#default_value']); + $this->assertEquals('https://events.stanford.edu/api/2/events?group_id=37955145294460&days=365', $widget_value[0]['uri']['#default_value']); $this->assertEquals('details', $widget_value[0]['filters']['#type']); $this->assertIsArray($widget_value[0]['filters']['type']['event_audience']); $this->assertIsArray($widget_value[0]['filters']['type']['event_audience']['#options']); @@ -152,7 +152,7 @@ public function testSettingsForm() { $config = [ 'field_definition' => $field_def, 'settings' => [ - 'base_url' => 'https://stanford.enterprise.localist.com', + 'base_url' => 'https://events.stanford.edu', ], 'third_party_settings' => [], ]; @@ -160,13 +160,13 @@ public function testSettingsForm() { $widget = LocalistUrlWidget::create(\Drupal::getContainer(), $config, '', $definition); $summary = $widget->settingsSummary(); $this->assertCount(1, $summary); - $this->assertEquals('Base URL: https://stanford.enterprise.localist.com', (string) $summary[0]); + $this->assertEquals('Base URL: https://events.stanford.edu', (string) $summary[0]); $form = []; $form_state = new FormState(); $element = $widget->settingsForm($form, $form_state); $this->assertCount(4, $element); - $this->assertEquals("https://stanford.enterprise.localist.com", $element['base_url']['#default_value']); + $this->assertEquals("https://events.stanford.edu", $element['base_url']['#default_value']); $this->assertArrayHasKey('select_distinct', $element); $element['#parents'] = []; @@ -187,7 +187,7 @@ public function testSettingsForm() { protected function getValidValue() { return [ [ - 'uri' => 'https://stanford.enterprise.localist.com/api/2/events?group_id=37955145294460&days=365', + 'uri' => 'https://events.stanford.edu/api/2/events?group_id=37955145294460&days=365', 'title' => '', 'attributes' => [], 'filters' => [ From 2f98910621a511a24d893ec869eb5ea092c6b3e9 Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Mon, 4 Apr 2022 09:49:40 -0700 Subject: [PATCH 3/4] Graceful fallback if the localist base url is not set --- src/Plugin/Field/FieldWidget/LocalistUrlWidget.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Plugin/Field/FieldWidget/LocalistUrlWidget.php b/src/Plugin/Field/FieldWidget/LocalistUrlWidget.php index 13e83df..06a5622 100644 --- a/src/Plugin/Field/FieldWidget/LocalistUrlWidget.php +++ b/src/Plugin/Field/FieldWidget/LocalistUrlWidget.php @@ -156,7 +156,10 @@ public function settingsSummary() { */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element = parent::formElement($items, $delta, $element, $form, $form_state); - + // Fallback to inherited link widget if the base_url is not set. + if (!$this->getSetting('base_url')) { + return $element; + } $element['uri']['#access'] = FALSE; $element['title']['#access'] = FALSE; $element['attributes']['#access'] = FALSE; @@ -196,6 +199,9 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen * {@inheritDoc} */ public function massageFormValues(array $values, array $form, FormStateInterface $form_state) { + if (!$this->getSetting('base_url')) { + return parent::massageFormValues($values, $form, $form_state); + } foreach ($values as $delta => &$value) { From c97cc2d84deccd96bff39ad4007fe4b690b1938a Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Tue, 5 Apr 2022 15:12:52 -0700 Subject: [PATCH 4/4] 8.1.11 --- CHANGELOG.md | 8 ++++++++ stanford_fields.info.yml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f53a650..d25e5c7 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ # Stanford Fields +8.x-1.11 +-------------------------------------------------------------------------------- +_Release Date: 2022-04-05_ + +- Graceful fallback if the localist base url is not set +- Updated localist URL references (#26) + + 8.x-1.10 -------------------------------------------------------------------------------- _Release Date: 2022-03-17_ diff --git a/stanford_fields.info.yml b/stanford_fields.info.yml index 5e3a5db..856f838 100755 --- a/stanford_fields.info.yml +++ b/stanford_fields.info.yml @@ -3,6 +3,6 @@ type: module description: 'Field types, widgets and formatters to enhance Drupal and Contrib.' core_version_requirement: ^8 || ^9 package: Stanford -version: 8.x-1.11-dev +version: 8.x-1.11 dependencies: - drupal:field