From 0fd45066b059f58d6f64d3451916a6f7908679a3 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 2 Jul 2020 22:37:03 -0400 Subject: [PATCH] Fix auto-refresh of CKEditor configurator form --- CRM/Admin/Form/CKEditorConfig.php | 43 ++++++++++++++++++----- js/wysiwyg/admin.ckeditor-configurator.js | 3 +- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/CRM/Admin/Form/CKEditorConfig.php b/CRM/Admin/Form/CKEditorConfig.php index 7a65a9537a..6de81d37ca 100644 --- a/CRM/Admin/Form/CKEditorConfig.php +++ b/CRM/Admin/Form/CKEditorConfig.php @@ -48,6 +48,25 @@ class CRM_Admin_Form_CKEditorConfig extends CRM_Core_Form { public function preProcess() { CRM_Utils_Request::retrieve('preset', 'String', $this, FALSE, 'default', 'GET'); + CRM_Utils_System::appendBreadCrumb([ + [ + 'url' => CRM_Utils_System::url('civicrm/admin/setting/preferences/display', 'reset=1'), + 'title' => ts('Display Preferences'), + ], + ]); + + // Initial build + if (empty($_POST['qfKey'])) { + $this->addResources(); + } + } + + /** + * Add resources during initial build or rebuild + * + * @throws CRM_Core_Exception + */ + public function addResources() { $settings = $this->getConfigSettings(); CRM_Core_Resources::singleton() @@ -72,13 +91,6 @@ class CRM_Admin_Form_CKEditorConfig extends CRM_Core_Form { $this->assign('skin', CRM_Utils_Array::value('skin', $settings)); $this->assign('extraPlugins', CRM_Utils_Array::value('extraPlugins', $settings)); $this->assign('configUrl', $configUrl); - - CRM_Utils_System::appendBreadCrumb([ - [ - 'url' => CRM_Utils_System::url('civicrm/admin/setting/preferences/display', 'reset=1'), - 'title' => ts('Display Preferences'), - ], - ]); } /** @@ -91,6 +103,12 @@ class CRM_Admin_Form_CKEditorConfig extends CRM_Core_Form { 'type' => 'next', 'name' => ts('Save'), ], + // Hidden button used to refresh form + [ + 'type' => 'submit', + 'class' => 'hiddenElement', + 'name' => ts('Save'), + ], [ 'type' => 'cancel', 'name' => ts('Cancel'), @@ -115,8 +133,16 @@ class CRM_Admin_Form_CKEditorConfig extends CRM_Core_Form { else { if (!empty($_POST[$this->getButtonName('next')])) { $this->save($_POST); + CRM_Core_Session::setStatus(ts("You may need to clear your browser's cache to see the changes in CiviCRM."), ts('CKEditor Saved'), 'success'); + } + // The "submit" hidden button saves but does not redirect + if (!empty($_POST[$this->getButtonName('submit')])) { + $this->save($_POST); + $this->addResources(); + } + else { + CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin/ckeditor', ['reset' => 1])); } - CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin/setting/preferences/display', ['reset' => 1])); } } @@ -157,7 +183,6 @@ class CRM_Admin_Form_CKEditorConfig extends CRM_Core_Form { } } self::saveConfigFile($this->get('preset'), $config); - CRM_Core_Session::setStatus(ts("You may need to clear your browser's cache to see the changes in CiviCRM."), ts('CKEditor Saved'), 'success'); } /** diff --git a/js/wysiwyg/admin.ckeditor-configurator.js b/js/wysiwyg/admin.ckeditor-configurator.js index f46c48fce9..9d87afc0dc 100644 --- a/js/wysiwyg/admin.ckeditor-configurator.js +++ b/js/wysiwyg/admin.ckeditor-configurator.js @@ -109,7 +109,8 @@ .on('change', '.config-param', function(e) { changedWhileOpen = true; if (!selectorOpen) { - $('#CKEditorConfig').submit().block(); + $('#_qf_CKEditorConfig_submit-bottom').click(); + $('#CKEditorConfig').block(); } }) .on('change', 'input.crm-config-option-name', changeOptionName) -- 2.25.1