mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-25 18:59:04 +02:00
SetupNewDashboardForm: Use SPL object hash as an element name
This commit is contained in:
parent
0da632444c
commit
ea4e0b8719
@ -96,7 +96,11 @@ class DashletForm extends SetupNewDashboardForm
|
|||||||
$this->clearPopulatedValue('pane');
|
$this->clearPopulatedValue('pane');
|
||||||
}
|
}
|
||||||
|
|
||||||
$populatedPane = $this->requestUrl->getParam('pane', $this->getPopulatedValue('pane', reset($panes)));
|
$populatedPane = $this->getPopulatedValue('pane', $this->requestUrl->getParam('pane'));
|
||||||
|
if (! $populatedPane || ! in_array($populatedPane, $panes)) {
|
||||||
|
$populatedPane = reset($panes);
|
||||||
|
}
|
||||||
|
|
||||||
$disable = empty($panes) || $populatedHome === self::CREATE_NEW_HOME;
|
$disable = empty($panes) || $populatedHome === self::CREATE_NEW_HOME;
|
||||||
$this->addElement('select', 'pane', [
|
$this->addElement('select', 'pane', [
|
||||||
'class' => 'autosubmit',
|
'class' => 'autosubmit',
|
||||||
@ -250,9 +254,7 @@ class DashletForm extends SetupNewDashboardForm
|
|||||||
* supposed to when the original home contains a dashboard with the same name
|
* supposed to when the original home contains a dashboard with the same name
|
||||||
* {@see DashboardHome::manageEntry()} for details
|
* {@see DashboardHome::manageEntry()} for details
|
||||||
*/
|
*/
|
||||||
$selectedPane = $this->getPopulatedValue('pane');
|
if (! $currentHome->hasEntry($currentPane->getName()) || $currentHome->getName() === $orgHome->getName()) {
|
||||||
if ((! $selectedPane || $selectedPane === self::CREATE_NEW_PANE)
|
|
||||||
&& ! $currentHome->hasEntry($currentPane->getName())) {
|
|
||||||
$orgHome->setEntries([]);
|
$orgHome->setEntries([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class SetupNewDashboardForm extends BaseDashboardForm
|
|||||||
foreach (self::$moduleDashlets as $module => $dashlets) {
|
foreach (self::$moduleDashlets as $module => $dashlets) {
|
||||||
/** @var Dashlet $dashlet */
|
/** @var Dashlet $dashlet */
|
||||||
foreach ($dashlets as $dashlet) {
|
foreach ($dashlets as $dashlet) {
|
||||||
$element = str_replace(' ', '_', $module . '|' . $dashlet->getName());
|
$element = spl_object_hash($dashlet);
|
||||||
if ($this->getPopulatedValue($element) === 'y' || (! $strict && $this->getPopulatedValue($element))) {
|
if ($this->getPopulatedValue($element) === 'y' || (! $strict && $this->getPopulatedValue($element))) {
|
||||||
$title = $this->getPopulatedValue($element);
|
$title = $this->getPopulatedValue($element);
|
||||||
$url = $this->getPopulatedValue($element . '_url');
|
$url = $this->getPopulatedValue($element . '_url');
|
||||||
@ -123,7 +123,7 @@ class SetupNewDashboardForm extends BaseDashboardForm
|
|||||||
$multi = new DashletListMultiSelect($dashlet);
|
$multi = new DashletListMultiSelect($dashlet);
|
||||||
$multi->setCheckBox($this->createElement(
|
$multi->setCheckBox($this->createElement(
|
||||||
'checkbox',
|
'checkbox',
|
||||||
$module . '|' . $dashlet->getName(),
|
spl_object_hash($dashlet),
|
||||||
['class' => 'sr-only']
|
['class' => 'sr-only']
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -161,19 +161,24 @@ class SetupNewDashboardForm extends BaseDashboardForm
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! empty(self::$moduleDashlets)) {
|
if (! empty(self::$moduleDashlets)) {
|
||||||
foreach (self::$moduleDashlets as $module => $dashlets) {
|
foreach (self::$moduleDashlets as $_ => $dashlets) {
|
||||||
/** @var Dashlet $dashlet */
|
/** @var Dashlet $dashlet */
|
||||||
foreach ($dashlets as $dashlet) {
|
foreach ($dashlets as $dashlet) {
|
||||||
$this->addHtml(HtmlElement::create('h3', null, t($dashlet->getTitle())));
|
$this->addHtml(HtmlElement::create('h3', null, t($dashlet->getTitle())));
|
||||||
|
|
||||||
$this->addElement('text', $module . '|' . $dashlet->getName(), [
|
$objHash = spl_object_hash($dashlet);
|
||||||
|
if ($this->getPopulatedValue('btn_next')) {
|
||||||
|
$this->clearPopulatedValue($objHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addElement('text', $objHash, [
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'label' => t('Dashlet Title'),
|
'label' => t('Dashlet Title'),
|
||||||
'value' => $dashlet->getTitle(),
|
'value' => $dashlet->getTitle(),
|
||||||
'description' => t('Enter a title for the dashlet'),
|
'description' => t('Enter a title for the dashlet'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->addElement('textarea', $module . '|' . $dashlet->getName() . '_url', [
|
$this->addElement('textarea', $objHash . '_url', [
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'label' => t('Url'),
|
'label' => t('Url'),
|
||||||
'value' => $dashlet->getUrl()->getRelativeUrl(),
|
'value' => $dashlet->getUrl()->getRelativeUrl(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user