Skip to content

Commit 2dd5df6

Browse files
Bump gridstack from 11.5.1 to 12.1.1
* Bump gridstack from 11.5.1 to 12.1.1 Bumps [gridstack](https://github.com/gridstack/gridstack.js) from 11.5.1 to 12.1.1. - [Release notes](https://github.com/gridstack/gridstack.js/releases) - [Changelog](https://github.com/gridstack/gridstack.js/blob/master/doc/CHANGES.md) - [Commits](https://github.com/gridstack/gridstack.js/commits/v12.1.1) --- updated-dependencies: - dependency-name: gridstack dependency-version: 12.1.1 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Review CSS imports * Fix styles * Switch to CSS vars
1 parent 63bd902 commit 2dd5df6

File tree

8 files changed

+20
-134
lines changed

8 files changed

+20
-134
lines changed

css/includes/components/_racks.scss

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,6 @@
105105
}
106106

107107
.grid-stack {
108-
.grid-stack-item {
109-
.grid-stack-item-content,
110-
.placeholder-content {
111-
left: 0;
112-
right: 0;
113-
}
114-
}
115-
116108
.grid-stack-placeholder > .placeholder-content {
117109
border: 1px dashed #bcbf33;
118110
background-color: rgba(229, 245, 105, 50%);
@@ -153,7 +145,7 @@ ul.indexes {
153145
content: "\2b";
154146
left: 45%;
155147
color: grey;
156-
top: 1px;
148+
top: 3px;
157149
font: var(--fa-font-solid);
158150
font-size: 1em;
159151
position: absolute;
@@ -206,8 +198,8 @@ ul.indexes {
206198
float: left;
207199

208200
&::after {
209-
left: calc(50% - 4px);
210-
top: calc(50% - 0.5em - 4px);
201+
left: calc(50% - 5px);
202+
top: calc(50% - 6px);
211203
}
212204
}
213205
}
@@ -430,7 +422,7 @@ ul.indexes {
430422
.grid-rack {
431423
width: 217px;
432424
background:
433-
var(--tblr-body-bg) repeating-linear-gradient(
425+
var(--tblr-bg-surface) repeating-linear-gradient(
434426
transparent,
435427
transparent 21px,
436428
var(--tblr-bg-surface-tertiary) 21px,

css/standalone/dashboard.scss

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
* ---------------------------------------------------------------------
3232
*/
3333

34-
$item_margin: 3px;
3534
$toolbar_height: 40px;
3635
$filter_height: 62px;
3736
$break_phones: 700px;
@@ -563,20 +562,23 @@ $break_tablet: 1400px;
563562
.grid-guide {
564563
display: none;
565564
position: absolute;
566-
top: calc(#{$toolbar_height} + #{$filter_height} + 16px);
565+
bottom: var(--gs-cell-height);
567566
width: calc(100% + 1px);
568567
border: 1px solid var(--tblr-body-bg);
569568
border-width: 0 1px 1px 0;
570569
background-image:
571570
linear-gradient(to right, var(--tblr-body-bg) 1px, transparent 1px),
572571
linear-gradient(to bottom, var(--tblr-body-bg) 1px, transparent 1px);
572+
background-size: var(--gs-cell-height) var(--gs-cell-height);
573573

574574
.cell-add {
575575
opacity: 0;
576576
z-index: 2;
577577
position: relative;
578578
cursor: pointer;
579579
border: 2px dashed #777;
580+
width: var(--gs-cell-height);
581+
height: var(--gs-cell-height);
580582

581583
&:hover {
582584
opacity: 1;
@@ -638,11 +640,6 @@ $break_tablet: 1400px;
638640
}
639641
}
640642

641-
.placeholder-content {
642-
left: $item_margin;
643-
right: $item_margin;
644-
}
645-
646643
.loading-card {
647644
height: 100%;
648645
border: 1px solid rgba($color: #000, $alpha: 5%);

js/modules/Dashboard/Dashboard.js

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,6 @@ class GLPIDashboard {
166166
// see https://github.com/gridstack/gridstack.js/issues/1229
167167
this.grid.setStatic(true);
168168

169-
// generate the css based on the grid width
170-
this.generateCss();
171-
172169
// set the width of the select box to match the selected option
173170
this.resizeSelect();
174171

@@ -295,8 +292,6 @@ class GLPIDashboard {
295292

296293
window.clearTimeout(debounce);
297294
debounce = window.setTimeout(() => {
298-
this.generateCss();
299-
300295
// fit again numbers
301296
this.fitNumbers();
302297
}, 200);
@@ -1177,52 +1172,6 @@ class GLPIDashboard {
11771172
}, 10);
11781173
}
11791174

1180-
generateCss() {
1181-
const dash_width = Math.floor(this.element.width());
1182-
const cell_length = (dash_width - 1) / this.cols;
1183-
let cell_height = cell_length;
1184-
const cell_fullsize = (dash_width / this.cols);
1185-
const width_percent = 100 / this.cols;
1186-
1187-
let style = " \
1188-
"+this.elem_id+" .cell-add { \
1189-
width: "+cell_length+"px; \
1190-
height: "+cell_fullsize+"px; \
1191-
} \
1192-
"+this.elem_id+" .grid-guide { \
1193-
background-size: "+cell_length+"px "+cell_fullsize+"px; \
1194-
bottom: "+cell_fullsize+"px; \
1195-
}";
1196-
1197-
for (let i = 0; i < this.cols; i++) {
1198-
const left = i * width_percent;
1199-
const width = (i+1) * width_percent;
1200-
1201-
style+= this.elem_id+" .grid-stack > .grid-stack-item[gs-x='"+i+"'] { \
1202-
left: "+left+"%; \
1203-
} \
1204-
"+this.elem_id+" .grid-stack > .grid-stack-item[gs-w='"+(i+1)+"'] { \
1205-
min-width: "+width_percent+"%; \
1206-
width: "+width+"%; \
1207-
}";
1208-
}
1209-
1210-
// remove old inline styles
1211-
$("#gs_inline_css_"+this.rand).remove();
1212-
1213-
// add new style
1214-
if (dash_width > 700) {
1215-
$("<style id='gs_inline_css_"+this.rand+"'></style>")
1216-
.prop("type", "text/css")
1217-
.html(style)
1218-
.appendTo("head");
1219-
} else {
1220-
cell_height = 60;
1221-
}
1222-
1223-
// apply new height to gridstack
1224-
this.grid.cellHeight(cell_height);
1225-
}
12261175

12271176
/**
12281177
* init filters of the dashboard

lib/bundles/gridstack.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,4 @@
3434
// Gridstack lib
3535
import { GridStack } from 'gridstack';
3636
window.GridStack = GridStack;
37-
require('gridstack/dist/gridstack.min.css');
38-
require('gridstack/dist/gridstack-extra.min.css');
37+
require('gridstack/dist/gridstack.css');

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"flatpickr": "^4.6.3",
3939
"fuzzy": "^0.1.3",
4040
"gettext.js": "^2.0.3",
41-
"gridstack": "^11.5.1",
41+
"gridstack": "^12.1.1",
4242
"hotkeys-js": "^3.13.9",
4343
"html5sortable": "^0.14.0",
4444
"jquery": "^3.7.1",

src/Glpi/Dashboard/Grid.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
class Grid
5858
{
59-
protected $cell_margin = 6;
59+
protected $cell_margin = 3;
6060
protected $grid_cols = 26;
6161
protected $grid_rows = 24;
6262
protected $current = "";
@@ -462,12 +462,12 @@ public function show(bool $mini = false, ?string $token = null)
462462
<span class='glpi_logo'></span>
463463
{{ toolbars|raw }}
464464
{{ filters|raw }}
465-
{{ grid_guide|raw }}
466465
<div class="grid-stack grid-stack-{{ grid_cols }}"
467-
id="grid-stack-{{ rand }}"
468-
gs-column="{{ grid_cols }}"
469-
gs-min-row="{{ grid_rows }}"
470-
style="width: 100%">
466+
id="grid-stack-{{ rand }}"
467+
gs-column="{{ grid_cols }}"
468+
gs-min-row="{{ grid_rows }}"
469+
style="width: 100%">
470+
{{ grid_guide|raw }}
471471
{{ gridstack_items|raw }}
472472
</div>
473473
</div>

tests/js/modules/Dashboard/Dashboard.test.js

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import {jest} from '@jest/globals';
3838
describe('Dashboard', () => {
3939
beforeAll(() => {
4040
// Make backups of some methods on the prototype we will mock by default because they are called from the constructor
41-
GLPIDashboard.prototype._generateCss = GLPIDashboard.prototype.generateCss;
4241
GLPIDashboard.prototype._refreshDashboard = GLPIDashboard.prototype.refreshDashboard;
4342
});
4443
beforeEach(() => {
@@ -48,7 +47,6 @@ describe('Dashboard', () => {
4847
window.AjaxMock.end();
4948

5049
// Mock some instance methods we don't want to test but are called from the constructor
51-
GLPIDashboard.prototype.generateCss = jest.fn().mockImplementation(() => {});
5250
GLPIDashboard.prototype.refreshDashboard = jest.fn().mockImplementation(() => {});
5351

5452
// Mock GridStack
@@ -1335,51 +1333,6 @@ describe('Dashboard', () => {
13351333
expect($('.grid-stack-item > *:not(.empty-card)').length).toBe(2);
13361334
});
13371335

1338-
test('generateCss', () => {
1339-
let dashboard = new GLPIDashboard({
1340-
'rand': '12345',
1341-
'cols': 10
1342-
});
1343-
// Restore the original function (must be done per-object after constructor)
1344-
dashboard.generateCss = GLPIDashboard.prototype._generateCss;
1345-
$('#dashboard-12345').width('1000px');
1346-
dashboard.grid.cellHeight = jest.fn().mockImplementation(() => {});
1347-
dashboard.generateCss();
1348-
expect(dashboard.grid.cellHeight).toHaveBeenCalledWith(99.9);
1349-
let head_html = $('head').html();
1350-
expect(head_html).toMatch(/^<style id="gs_inline_css_12345"/i);
1351-
expect(head_html).toMatch(/#dashboard-12345 .cell-add\s*{\s*width: 99.9px;\s*height: 100px;\s*}/i);
1352-
expect(head_html).toMatch(/#dashboard-12345 .grid-guide\s*{\s*background-size: 99.9px 100px;\s*bottom: 100px;\s*}/i);
1353-
expect(head_html).toMatch(/#dashboard-12345 .grid-stack > .grid-stack-item\[gs-w='6']\s*{\s*min-width: 10%;\s*width: 60%;\s*}/i);
1354-
expect(head_html).toMatch(/#dashboard-12345 .grid-stack > .grid-stack-item\[gs-x='6']\s*{\s*left: 60%;\s*}/i);
1355-
1356-
dashboard = new GLPIDashboard({
1357-
'rand': '12345',
1358-
'cols': 15
1359-
});
1360-
dashboard.generateCss = GLPIDashboard.prototype._generateCss;
1361-
$('#dashboard-12345').width('750px');
1362-
dashboard.grid.cellHeight = jest.fn().mockImplementation(() => {});
1363-
dashboard.generateCss();
1364-
expect(dashboard.grid.cellHeight).toHaveBeenCalledWith(49.93333333333333);
1365-
head_html = $('head').html();
1366-
expect(head_html).toMatch(/^<style id="gs_inline_css_12345"/i);
1367-
expect(head_html).toMatch(/#dashboard-12345 .cell-add\s*{\s*width: 49.93333333333333px;\s*height: 50px;\s*}/i);
1368-
expect(head_html).toMatch(/#dashboard-12345 .grid-guide\s*{\s*background-size: 49.93333333333333px 50px;\s*bottom: 50px;\s*}/i);
1369-
expect(head_html).toMatch(/#dashboard-12345 .grid-stack > .grid-stack-item\[gs-w='6']\s*{\s*min-width: 6.666666666666667%;\s*width: 40%;\s*}/i);
1370-
expect(head_html).toMatch(/#dashboard-12345 .grid-stack > .grid-stack-item\[gs-x='6']\s*{\s*left: 40%;\s*}/i);
1371-
1372-
dashboard = new GLPIDashboard({
1373-
'rand': '12345',
1374-
'cols': 10
1375-
});
1376-
dashboard.generateCss = GLPIDashboard.prototype._generateCss;
1377-
$('#dashboard-12345').width('500px');
1378-
dashboard.grid.cellHeight = jest.fn().mockImplementation(() => {});
1379-
dashboard.generateCss();
1380-
expect(dashboard.grid.cellHeight).toHaveBeenCalledWith(60);
1381-
});
1382-
13831336
test('initFilters', async () => {
13841337
const dashboard = new GLPIDashboard({'rand': '12345'});
13851338
dashboard.getFiltersFromDB = jest.fn().mockImplementation(() => {
@@ -1818,23 +1771,19 @@ describe('Dashboard', () => {
18181771

18191772
test('Update CSS and Fit Numbers on Resize', () => {
18201773
const dashboard = new GLPIDashboard({'rand': '12345'});
1821-
dashboard.generateCss = jest.fn().mockImplementation(() => {});
18221774
dashboard.fitNumbers = jest.fn().mockImplementation(() => {});
18231775
jest.useFakeTimers();
18241776
$(window).trigger('resize');
18251777
jest.advanceTimersByTime(250);
1826-
expect(dashboard.generateCss).toHaveBeenCalled();
18271778
expect(dashboard.fitNumbers).toHaveBeenCalled();
18281779
});
18291780

18301781
test('Do not Update CSS and Fit Numbers on Propagated Resize', () => {
18311782
const dashboard = new GLPIDashboard({'rand': '12345'});
1832-
dashboard.generateCss = jest.fn().mockImplementation(() => {});
18331783
dashboard.fitNumbers = jest.fn().mockImplementation(() => {});
18341784
jest.useFakeTimers();
18351785
$('body').trigger('resize');
18361786
jest.advanceTimersByTime(250);
1837-
expect(dashboard.generateCss).not.toHaveBeenCalled();
18381787
expect(dashboard.fitNumbers).not.toHaveBeenCalled();
18391788
});
18401789

0 commit comments

Comments
 (0)