Skip to content

Commit aab508d

Browse files
ccaillybtry
authored andcommitted
fix: adjust dashboard widget height
1 parent 21ecb76 commit aab508d

4 files changed

Lines changed: 98 additions & 8 deletions

File tree

install/install.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class PluginFormcreatorInstall {
8383
'2.13.4' => '2.13.5',
8484
'2.13.5' => '2.13.6',
8585
'2.13.6' => '2.13.7',
86+
'2.13.7' => '2.13.10',
8687
];
8788

8889
protected bool $resyncIssues = false;
@@ -764,7 +765,7 @@ protected function createMiniDashboardBigNumbers() {
764765
// With counters
765766
$x = 0;
766767
$w = 4; // Width
767-
$h = 1; // Height
768+
$h = 2; // Height
768769
$s = 0; // space between widgets
769770
$y = 0;
770771
foreach ($cards as $key => $options) {

install/upgrade_to_2.13.10.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
3+
/**
4+
* ---------------------------------------------------------------------
5+
* Formcreator is a plugin which allows creation of custom forms of
6+
* easy access.
7+
* ---------------------------------------------------------------------
8+
* LICENSE
9+
*
10+
* This file is part of Formcreator.
11+
*
12+
* Formcreator is free software; you can redistribute it and/or modify
13+
* it under the terms of the GNU General Public License as published by
14+
* the Free Software Foundation; either version 2 of the License, or
15+
* (at your option) any later version.
16+
*
17+
* Formcreator is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU General Public License
23+
* along with Formcreator. If not, see <http://www.gnu.org/licenses/>.
24+
* ---------------------------------------------------------------------
25+
* @copyright Copyright © 2011 - 2021 Teclib'
26+
* @license http://www.gnu.org/licenses/gpl.txt GPLv3+
27+
* @link https://github.com/pluginsGLPI/formcreator/
28+
* @link https://pluginsglpi.github.io/formcreator/
29+
* @link http://plugins.glpi-project.org/#/plugin/formcreator
30+
* ---------------------------------------------------------------------
31+
*/
32+
33+
use Glpi\Dashboard\Dashboard;
34+
use Glpi\Dashboard\Item;
35+
36+
class PluginFormcreatorUpgradeTo2_13_10
37+
{
38+
/** @var Migration */
39+
protected $migration;
40+
41+
public function isResyncIssuesRequired()
42+
{
43+
return false;
44+
}
45+
46+
/**
47+
* @param Migration $migration
48+
*/
49+
public function upgrade(Migration $migration)
50+
{
51+
$this->migration = $migration;
52+
$this->resizeWidgets();
53+
}
54+
55+
/**
56+
* Resize widgets of the `plugin_formcreator_issue_counters` dashboard to match
57+
* the mini_tickets core dashboard style
58+
*
59+
* @return void
60+
*/
61+
public function resizeWidgets()
62+
{
63+
// Get container
64+
$dashboard = new Dashboard();
65+
$found = $dashboard->getFromDB("plugin_formcreator_issue_counters");
66+
67+
if (!$found) {
68+
// Unable to fetch dashboard
69+
return;
70+
};
71+
72+
$di = new Item();
73+
$cards = $di->find(['dashboards_dashboards_id' => $dashboard->fields['id']]);
74+
75+
foreach ($cards as $card) {
76+
$di = new Item();
77+
$di->update([
78+
'id' => $card['id'],
79+
'height' => 2,
80+
]);
81+
}
82+
}
83+
}

install/upgrade_to_2.13.7.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* ---------------------------------------------------------------------
45
* Formcreator is a plugin which allows creation of custom forms of
@@ -33,18 +34,21 @@
3334
use Glpi\Dashboard\Item;
3435
use Glpi\Toolbox\Sanitizer;
3536

36-
class PluginFormcreatorUpgradeTo2_13_7 {
37+
class PluginFormcreatorUpgradeTo2_13_7
38+
{
3739
/** @var Migration */
3840
protected $migration;
3941

40-
public function isResyncIssuesRequired() {
42+
public function isResyncIssuesRequired()
43+
{
4144
return false;
4245
}
4346

4447
/**
4548
* @param Migration $migration
4649
*/
47-
public function upgrade(Migration $migration) {
50+
public function upgrade(Migration $migration)
51+
{
4852
$this->migration = $migration;
4953
$this->fixEncodingInQuestions();
5054
$this->resizeWidgets();
@@ -57,7 +61,8 @@ public function upgrade(Migration $migration) {
5761
*
5862
* @return void
5963
*/
60-
public function fixEncodingInQuestions() {
64+
public function fixEncodingInQuestions()
65+
{
6166
global $DB;
6267

6368
$table = 'glpi_plugin_formcreator_questions';
@@ -94,7 +99,8 @@ public function fixEncodingInQuestions() {
9499
*
95100
* @return void
96101
*/
97-
public function resizeWidgets() {
102+
public function resizeWidgets()
103+
{
98104
// Get container
99105
$dashboard = new Dashboard();
100106
$found = $dashboard->getFromDB("plugin_formcreator_issue_counters");
@@ -118,7 +124,7 @@ public function resizeWidgets() {
118124
'y' => 0,
119125
]);
120126

121-
$x +=4;
127+
$x += 4;
122128
}
123129
}
124130
}

setup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
global $CFG_GLPI;
3535
// Version of the plugin (major.minor.bugfix)
36-
define('PLUGIN_FORMCREATOR_VERSION', '2.13.9');
36+
define('PLUGIN_FORMCREATOR_VERSION', '2.13.10');
3737
// Schema version of this version (major.minor only)
3838
define('PLUGIN_FORMCREATOR_SCHEMA_VERSION', '2.13');
3939
// is or is not an official release of the plugin

0 commit comments

Comments
 (0)