Skip to content

Commit

Permalink
fix: resize dashboard to match GLPI's core (#3306)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienClairembault committed Jun 21, 2023
1 parent 016696a commit 9272cda
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inc/common.class.php
Expand Up @@ -871,7 +871,7 @@ public static function showMiniDashboard(): void {

if (PluginFormcreatorEntityconfig::getUsedConfig('is_dashboard_visible', Session::getActiveEntity()) == PluginFormcreatorEntityconfig::CONFIG_DASHBOARD_VISIBLE) {
if (version_compare(GLPI_VERSION, '10.0.3') > 0) {
$dashboard = new Glpi\Dashboard\Grid('plugin_formcreator_issue_counters', 33, 1, 'mini_core');
$dashboard = new Glpi\Dashboard\Grid('plugin_formcreator_issue_counters', 33, 2, 'mini_core');
} else {
$dashboard = new Glpi\Dashboard\Grid('plugin_formcreator_issue_counters', 33, 0, 'mini_core');
}
Expand Down
37 changes: 37 additions & 0 deletions install/upgrade_to_2.13.7.php
Expand Up @@ -29,6 +29,8 @@
* ---------------------------------------------------------------------
*/

use Glpi\Dashboard\Dashboard;
use Glpi\Dashboard\Item;
use Glpi\Toolbox\Sanitizer;

class PluginFormcreatorUpgradeTo2_13_7 {
Expand All @@ -45,6 +47,7 @@ public function isResyncIssuesRequired() {
public function upgrade(Migration $migration) {
$this->migration = $migration;
$this->fixEncodingInQuestions();
$this->resizeWidgets();
}

/**
Expand Down Expand Up @@ -83,4 +86,38 @@ public function fixEncodingInQuestions() {
);
}
}

/**
* Resize widgets of the `plugin_formcreator_issue_counters` dashboard to match
* the mini_tickets core dashboard style
*
* @return void
*/
public function resizeWidgets() {
// Get container
$dashboard = new Dashboard();
$found = $dashboard->getFromDB("plugin_formcreator_issue_counters");

if (!$found) {
// Unable to fetch dashboard
return;
};

$di = new Item();
$cards = $di->find(['dashboards_dashboards_id' => $dashboard->fields['id']]);
$x = 0;

foreach ($cards as $card) {
$di = new Item();
$di->update([
'id' => $card['id'],
'width' => 4,
'height' => 2,
'x' => $x,
'y' => 0,
]);

$x +=4;
}
}
}

0 comments on commit 9272cda

Please sign in to comment.