Skip to content

Commit 9272cda

Browse files
fix: resize dashboard to match GLPI's core (#3306)
1 parent 016696a commit 9272cda

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

inc/common.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ public static function showMiniDashboard(): void {
871871

872872
if (PluginFormcreatorEntityconfig::getUsedConfig('is_dashboard_visible', Session::getActiveEntity()) == PluginFormcreatorEntityconfig::CONFIG_DASHBOARD_VISIBLE) {
873873
if (version_compare(GLPI_VERSION, '10.0.3') > 0) {
874-
$dashboard = new Glpi\Dashboard\Grid('plugin_formcreator_issue_counters', 33, 1, 'mini_core');
874+
$dashboard = new Glpi\Dashboard\Grid('plugin_formcreator_issue_counters', 33, 2, 'mini_core');
875875
} else {
876876
$dashboard = new Glpi\Dashboard\Grid('plugin_formcreator_issue_counters', 33, 0, 'mini_core');
877877
}

install/upgrade_to_2.13.7.php

+37
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
* ---------------------------------------------------------------------
3030
*/
3131

32+
use Glpi\Dashboard\Dashboard;
33+
use Glpi\Dashboard\Item;
3234
use Glpi\Toolbox\Sanitizer;
3335

3436
class PluginFormcreatorUpgradeTo2_13_7 {
@@ -45,6 +47,7 @@ public function isResyncIssuesRequired() {
4547
public function upgrade(Migration $migration) {
4648
$this->migration = $migration;
4749
$this->fixEncodingInQuestions();
50+
$this->resizeWidgets();
4851
}
4952

5053
/**
@@ -83,4 +86,38 @@ public function fixEncodingInQuestions() {
8386
);
8487
}
8588
}
89+
90+
/**
91+
* Resize widgets of the `plugin_formcreator_issue_counters` dashboard to match
92+
* the mini_tickets core dashboard style
93+
*
94+
* @return void
95+
*/
96+
public function resizeWidgets() {
97+
// Get container
98+
$dashboard = new Dashboard();
99+
$found = $dashboard->getFromDB("plugin_formcreator_issue_counters");
100+
101+
if (!$found) {
102+
// Unable to fetch dashboard
103+
return;
104+
};
105+
106+
$di = new Item();
107+
$cards = $di->find(['dashboards_dashboards_id' => $dashboard->fields['id']]);
108+
$x = 0;
109+
110+
foreach ($cards as $card) {
111+
$di = new Item();
112+
$di->update([
113+
'id' => $card['id'],
114+
'width' => 4,
115+
'height' => 2,
116+
'x' => $x,
117+
'y' => 0,
118+
]);
119+
120+
$x +=4;
121+
}
122+
}
86123
}

0 commit comments

Comments
 (0)