NavigationController: Rerender the layout when removing menu entries

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-25 10:51:44 +02:00
parent 2952eaefcd
commit 086579b254
2 changed files with 9 additions and 3 deletions

View File

@ -257,7 +257,7 @@ class NavigationController extends Controller
$form->setTitle(sprintf($this->translate('Remove Navigation Item %s'), $itemName)); $form->setTitle(sprintf($this->translate('Remove Navigation Item %s'), $itemName));
$form->setOnSuccess(function (ConfirmRemovalForm $form) use ($itemName, $navigationConfigForm) { $form->setOnSuccess(function (ConfirmRemovalForm $form) use ($itemName, $navigationConfigForm) {
try { try {
$navigationConfigForm->delete($itemName); $itemConfig = $navigationConfigForm->delete($itemName);
} catch (NotFoundError $e) { } catch (NotFoundError $e) {
Notification::success(sprintf(t('Navigation Item "%s" not found. No action required'), $itemName)); Notification::success(sprintf(t('Navigation Item "%s" not found. No action required'), $itemName));
return true; return true;
@ -267,6 +267,10 @@ class NavigationController extends Controller
} }
if ($navigationConfigForm->save()) { if ($navigationConfigForm->save()) {
if ($itemConfig->type === 'menu-item') {
$form->getResponse()->setRerenderLayout();
}
Notification::success(sprintf(t('Navigation Item "%s" successfully removed'), $itemName)); Notification::success(sprintf(t('Navigation Item "%s" successfully removed'), $itemName));
return true; return true;
} }

View File

@ -8,6 +8,7 @@ use Icinga\Application\Config;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use Icinga\Authentication\Auth; use Icinga\Authentication\Auth;
use Icinga\Data\ConfigObject;
use Icinga\Exception\IcingaException; use Icinga\Exception\IcingaException;
use Icinga\Exception\NotFoundError; use Icinga\Exception\NotFoundError;
use Icinga\Exception\ProgrammingError; use Icinga\Exception\ProgrammingError;
@ -449,7 +450,7 @@ class NavigationConfigForm extends ConfigForm
* *
* @param string $name * @param string $name
* *
* @return $this * @return ConfigObject The navigation item's config
* *
* @throws NotFoundError In case no navigation item with the given name is found * @throws NotFoundError In case no navigation item with the given name is found
* @throws IcingaException In case the navigation item has still children * @throws IcingaException In case the navigation item has still children
@ -473,9 +474,10 @@ class NavigationConfigForm extends ConfigForm
); );
} }
$section = $config->getSection($name);
$config->removeSection($name); $config->removeSection($name);
$this->setIniConfig($config); $this->setIniConfig($config);
return $this; return $section;
} }
/** /**