diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9dba22b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 4.0.1 - 2023-04-21 +### Fixed +- Fixed missing revalidation URLs field diff --git a/src/services/Revalidator.php b/src/services/Revalidator.php index 5f04e0d..23d87ed 100644 --- a/src/services/Revalidator.php +++ b/src/services/Revalidator.php @@ -49,12 +49,12 @@ public function init (): void Event::on( Sections::class, - Sections::EVENT_AFTER_SAVE_SECTION, - [$this, 'onAfterSectionSave'] + Sections::EVENT_BEFORE_SAVE_SECTION, + [$this, 'onBeforeSectionSave'] ); } - public function onAfterElementSave (ModelEvent $event): void + public function onAfterElementSave (SectionEvent $event): void { /** @var Element $element */ $element = $event->sender; @@ -70,7 +70,7 @@ public function onAfterRenderTemplate (TemplateEvent $event): void $this->injectAdditionalUrisTable($event); } - public function onAfterSectionSave (SectionEvent $event): void + public function onBeforeSectionSave (SectionEvent $event): void { if (!empty($event->section)) $this->saveAdditionalURIs($event->section->uid); @@ -86,7 +86,7 @@ public function onAfterSectionSave (SectionEvent $event): void */ public function injectAdditionalUrisTable (TemplateEvent $event): void { - if ($event->template !== 'settings/sections/_edit') + if ($event->template !== 'settings/sections/_edit.twig') return; $sectionId = $event->variables['sectionId']; @@ -111,6 +111,9 @@ public function injectAdditionalUrisTable (TemplateEvent $event): void ], ], 'rows' => $this->getAdditionalURIs($sectionUid, true), + 'initJs' => true, + 'allowAdd' => true, + 'allowDelete' => true, ]); } @@ -164,6 +167,7 @@ public function saveAdditionalURIs (string $sectionUid): void if ($request->getIsConsoleRequest()) return; + // FIXME: Can add but can't delete $uris = $request->getBodyParam('bAdditionalRevalidateUris'); $key = "utility-belt.revalidator.uris.$sectionUid"; $config = Craft::$app->getProjectConfig();