Skip to content

Commit

Permalink
API Use dynamic config for ModalController forms
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Nov 25, 2024
1 parent 6c48657 commit 1738a21
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 123 deletions.
7 changes: 4 additions & 3 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ SilverStripe\Admin\LeftAndMain:
Name: cmsmodals
---
SilverStripe\Admin\ModalController:
extensions:
- SilverStripe\CMS\Forms\InternalLinkModalExtension
link_modal_form_factories:
editorInternalLink: SilverStripe\CMS\Forms\InternalLinkFormFactory
editorAnchorLink: SilverStripe\CMS\Forms\AnchorLinkFormFactory
---
Name: cmshierarchy
---
SilverStripe\ORM\Hierarchy\Hierarchy:
node_threshold_total: 50
node_threshold_leaf: 250
node_threshold_leaf: 250
2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_sslink-anchor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_sslink-internal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/src/legacy/TinyMCE_sslink-anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const plugin = {
};

const modalId = 'insert-link__dialog-wrapper--anchor';
const sectionConfigKey = 'SilverStripe\\CMS\\Controllers\\CMSPageEditController';
const sectionConfigKey = 'SilverStripe\\Admin\\LeftAndMain';
const formName = 'editorAnchorLink';
const InsertLinkInternalModal = provideInjector(createInsertLinkModal(sectionConfigKey, formName));

Expand Down
2 changes: 1 addition & 1 deletion client/src/legacy/TinyMCE_sslink-internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const plugin = {
};

const modalId = 'insert-link__dialog-wrapper--internal';
const sectionConfigKey = 'SilverStripe\\CMS\\Controllers\\CMSPageEditController';
const sectionConfigKey = 'SilverStripe\\Admin\\LeftAndMain';
const formName = 'editorInternalLink';
const InsertLinkInternalModal = provideInjector(createInsertLinkModal(sectionConfigKey, formName));

Expand Down
8 changes: 0 additions & 8 deletions code/Controllers/CMSPageEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Page;
use SilverStripe\Admin\LeftAndMain;
use SilverStripe\Admin\ModalController;
use SilverStripe\CampaignAdmin\AddToCampaignHandler;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Controller;
Expand Down Expand Up @@ -37,18 +36,11 @@ class CMSPageEditController extends CMSMain

public function getClientConfig(): array
{
$modalController = ModalController::singleton();
return ArrayLib::array_merge_recursive(parent::getClientConfig(), [
'form' => [
'AddToCampaignForm' => [
'schemaUrl' => $this->Link('schema/AddToCampaignForm'),
],
'editorInternalLink' => [
'schemaUrl' => $modalController->Link('schema/editorInternalLink'),
],
'editorAnchorLink' => [
'schemaUrl' => $modalController->Link('schema/editorAnchorLink/:pageid'),
],
],
]);
}
Expand Down
4 changes: 2 additions & 2 deletions code/Forms/AnchorLinkFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ protected function getFormFields($controller, $name, $context)

// Ensure current page is selected
$pageIDField = $fields->dataFieldByName('PageID');
$pageIDField->setValue((int)$context['PageID']);
$pageIDField->setValue((int)$context['ItemID']);

// Get anchor selector field
$fields->insertAfter(
Expand All @@ -22,6 +22,6 @@ protected function getFormFields($controller, $name, $context)

public function getRequiredContext()
{
return array_merge(parent::getRequiredContext(), [ 'PageID' ]);
return array_merge(parent::getRequiredContext(), [ 'ItemID' ]);
}
}
62 changes: 0 additions & 62 deletions code/Forms/InternalLinkModalExtension.php

This file was deleted.

Loading

0 comments on commit 1738a21

Please sign in to comment.