Skip to content

Commit

Permalink
fix: adjust dashboard widget height
Browse files Browse the repository at this point in the history
  • Loading branch information
ccailly committed Apr 22, 2024
1 parent 3efc9cd commit f3891f0
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 8 deletions.
3 changes: 2 additions & 1 deletion install/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class PluginFormcreatorInstall {
'2.13.4' => '2.13.5',
'2.13.5' => '2.13.6',
'2.13.6' => '2.13.7',
'2.13.7' => '2.13.10',
];

protected bool $resyncIssues = false;
Expand Down Expand Up @@ -764,7 +765,7 @@ protected function createMiniDashboardBigNumbers() {
// With counters
$x = 0;
$w = 4; // Width
$h = 1; // Height
$h = 2; // Height
$s = 0; // space between widgets
$y = 0;
foreach ($cards as $key => $options) {
Expand Down
83 changes: 83 additions & 0 deletions install/upgrade_to_2.13.10.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

/**
* ---------------------------------------------------------------------
* Formcreator is a plugin which allows creation of custom forms of
* easy access.
* ---------------------------------------------------------------------
* LICENSE
*
* This file is part of Formcreator.
*
* Formcreator is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Formcreator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Formcreator. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
* @copyright Copyright © 2011 - 2021 Teclib'
* @license http://www.gnu.org/licenses/gpl.txt GPLv3+
* @link https://github.com/pluginsGLPI/formcreator/
* @link https://pluginsglpi.github.io/formcreator/
* @link http://plugins.glpi-project.org/#/plugin/formcreator
* ---------------------------------------------------------------------
*/

use Glpi\Dashboard\Dashboard;
use Glpi\Dashboard\Item;

class PluginFormcreatorUpgradeTo2_13_10
{
/** @var Migration */
protected $migration;

public function isResyncIssuesRequired()
{
return false;
}

/**
* @param Migration $migration
*/
public function upgrade(Migration $migration)
{
$this->migration = $migration;
$this->resizeWidgets();
}

/**
* 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']]);

foreach ($cards as $card) {
$di = new Item();
$di->update([
'id' => $card['id'],
'height' => 2,
]);
}
}
}
18 changes: 12 additions & 6 deletions install/upgrade_to_2.13.7.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* ---------------------------------------------------------------------
* Formcreator is a plugin which allows creation of custom forms of
Expand Down Expand Up @@ -33,18 +34,21 @@
use Glpi\Dashboard\Item;
use Glpi\Toolbox\Sanitizer;

class PluginFormcreatorUpgradeTo2_13_7 {
class PluginFormcreatorUpgradeTo2_13_7
{
/** @var Migration */
protected $migration;

public function isResyncIssuesRequired() {
public function isResyncIssuesRequired()
{
return false;
}

/**
* @param Migration $migration
*/
public function upgrade(Migration $migration) {
public function upgrade(Migration $migration)
{
$this->migration = $migration;
$this->fixEncodingInQuestions();
$this->resizeWidgets();
Expand All @@ -57,7 +61,8 @@ public function upgrade(Migration $migration) {
*
* @return void
*/
public function fixEncodingInQuestions() {
public function fixEncodingInQuestions()
{
global $DB;

$table = 'glpi_plugin_formcreator_questions';
Expand Down Expand Up @@ -94,7 +99,8 @@ public function fixEncodingInQuestions() {
*
* @return void
*/
public function resizeWidgets() {
public function resizeWidgets()
{
// Get container
$dashboard = new Dashboard();
$found = $dashboard->getFromDB("plugin_formcreator_issue_counters");
Expand All @@ -118,7 +124,7 @@ public function resizeWidgets() {
'y' => 0,
]);

$x +=4;
$x += 4;
}
}
}
2 changes: 1 addition & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

global $CFG_GLPI;
// Version of the plugin (major.minor.bugfix)
define('PLUGIN_FORMCREATOR_VERSION', '2.13.9');
define('PLUGIN_FORMCREATOR_VERSION', '2.13.10');
// Schema version of this version (major.minor only)
define('PLUGIN_FORMCREATOR_SCHEMA_VERSION', '2.13');
// is or is not an official release of the plugin
Expand Down

0 comments on commit f3891f0

Please sign in to comment.