Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions demo/nested.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ <h1>Nested grids demo</h1>
<p>Note: initial v3 HTML5 release doesn't support 'dragOut:false' constrain so use jq version if you need that.</p>
<a class="btn btn-primary" onClick="addNewWidget('.nested1')" href="#">Add Widget Grid1</a>
<a class="btn btn-primary" onClick="addNewWidget('.nested2')" href="#">Add Widget Grid2</a>
<a class="btn btn-primary" onClick="save()" href="#">Save</a>
<a class="btn btn-primary" onClick="destroy()" href="#">Clear</a>
<a class="btn btn-primary" onClick="load()" href="#">Load</a>
<br><br>
<!-- grid will be added here -->
</div>
Expand All @@ -41,17 +44,16 @@ <h1>Nested grids demo</h1>
minWidth: 300, // min to go 1 column mode
margin: 1
};
let opts = {cellHeight: 70, children: [
let json = {cellHeight: 70, children: [
{y:0, content: 'regular item'},
{x:1, w:4, h:4, content: 'nested 1 - can drag items out', subGrid: {children: sub1, dragOut: true, class: 'nested1', ...subOptions}},
{x:5, w:4, h:4, content: 'nested 2 - constrained to parent (default)', subGrid: {children: sub2, class: 'nested2', ...subOptions}},
]};

// create and load it all from JSON above
GridStack.addGrid(document.querySelector('.container-fluid'), opts);
let grid = GridStack.addGrid(document.querySelector('.container-fluid'), json);

addNewWidget = function(selector) {
grid = document.querySelector(selector).gridstack;
let node = {
x: Math.round(12 * Math.random()),
y: Math.round(5 * Math.random()),
Expand All @@ -62,6 +64,18 @@ <h1>Nested grids demo</h1>
grid.addWidget(node);
return false;
};

save = function() {
json = grid.save(true, true);
}
destroy = function() {
grid.destroy();
grid = undefined;
}
load = function() {
grid = GridStack.addGrid(document.querySelector('.container-fluid'), json);
}

</script>
</body>
</html>
5 changes: 5 additions & 0 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Change log
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*

- [4.0.0-dev](#400-dev)
- [4.0.0 (2021-3-19)](#400-2021-3-19)
- [3.3.0 (2021-2-2)](#330-2021-2-2)
- [3.2.0 (2021-1-25)](#320-2021-1-25)
Expand Down Expand Up @@ -48,6 +49,10 @@ Change log
- [v0.1.0 (2014-11-18)](#v010-2014-11-18)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## 4.0.0-dev

- fix [#1661](https://github.com/gridstack/gridstack.js/issues/1661) serialization of nested grid

## 4.0.0 (2021-3-19)

- fix [#149](https://github.com/gridstack/gridstack.js/issues/149) [#1094](https://github.com/gridstack/gridstack.js/issues/1094) [#1605](https://github.com/gridstack/gridstack.js/issues/1605) [#1534](https://github.com/gridstack/gridstack.js/issues/1534) re-write of the **collision code - fixing 6 years old most requested request**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gridstack",
"version": "4.0.0",
"version": "4.0.0-dev",
"description": "TypeScript/JS lib for dashboard layout and creation, no external dependencies, with many wrappers (React, Angular, Vue, Ember, knockout...)",
"main": "./dist/gridstack.js",
"types": "./dist/gridstack.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/gridstack-dd.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// gridstack-GridStackDD.get().ts 4.0.0
// gridstack-GridStackDD.get().ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license
/* eslint-disable @typescript-eslint/no-unused-vars */
import { GridStackDDI } from './gridstack-ddi';
Expand Down
2 changes: 1 addition & 1 deletion src/gridstack-ddi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// gridstack-ddi.ts 4.0.0
// gridstack-ddi.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license
import { GridItemHTMLElement } from './types';

Expand Down
2 changes: 1 addition & 1 deletion src/gridstack-engine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// gridstack-engine.ts 4.0.0
// gridstack-engine.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license
import { Utils } from './utils';
import { GridStackNode, ColumnOptions, GridStackPosition, GridStackMoveOpts } from './types';
Expand Down
8 changes: 5 additions & 3 deletions src/gridstack.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// gridstack.ts 4.0.0
// gridstack.ts 4.0.0-dev
/*!
* (c) 2021 Alain Dumesny - see root license
*/
Expand Down Expand Up @@ -164,8 +164,10 @@ export class GridStack {

// create grid class and load any children
let grid = GridStack.init(opt, el);
if (opt.children) {
grid.load(opt.children);
if (grid.opts.children) {
let children = grid.opts.children;
delete grid.opts.children;
grid.load(children);
}
return grid;
}
Expand Down
2 changes: 1 addition & 1 deletion src/h5/dd-base-impl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dd-base-impl.ts 4.0.0
// dd-base-impl.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license
export type EventCallback = (event: Event) => boolean|void;
export abstract class DDBaseImplement {
Expand Down
2 changes: 1 addition & 1 deletion src/h5/dd-draggable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dd-draggable.ts 4.0.0
// dd-draggable.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license
import { DDManager } from './dd-manager';
import { DDUtils } from './dd-utils';
Expand Down
2 changes: 1 addition & 1 deletion src/h5/dd-droppable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dd-droppable.ts 4.0.0
// dd-droppable.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license
import { DDDraggable } from './dd-draggable';
import { DDManager } from './dd-manager';
Expand Down
2 changes: 1 addition & 1 deletion src/h5/dd-element.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dd-elements.ts 4.0.0
// dd-elements.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license
import { DDResizable, DDResizableOpt } from './dd-resizable';
import { GridItemHTMLElement } from './../types';
Expand Down
2 changes: 1 addition & 1 deletion src/h5/dd-manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dd-manager.ts 4.0.0
// dd-manager.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license
import { DDDraggable } from './dd-draggable';

Expand Down
2 changes: 1 addition & 1 deletion src/h5/dd-resizable-handle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dd-resizable-handle.ts 4.0.0
// dd-resizable-handle.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license
export interface DDResizableHandleOpt {
start?: (event) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/h5/dd-resizable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dd-resizable.ts 4.0.0
// dd-resizable.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license
import { DDResizableHandle } from './dd-resizable-handle';
import { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';
Expand Down
2 changes: 1 addition & 1 deletion src/h5/dd-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// dd-utils.ts 4.0.0
// dd-utils.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license
export class DDUtils {

Expand Down
2 changes: 1 addition & 1 deletion src/h5/gridstack-dd-native.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// gridstack-dd-native.ts 4.0.0
// gridstack-dd-native.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license
import { DDManager } from './dd-manager';
import { DDElement, DDElementHost } from './dd-element';
Expand Down
2 changes: 1 addition & 1 deletion src/index-h5.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// index.html5.ts 4.0.0 - everything you need for a Grid that uses HTML5 native drag&drop (work in progress)
// index.html5.ts 4.0.0-dev - everything you need for a Grid that uses HTML5 native drag&drop (work in progress)
// (c) 2021 Alain Dumesny - see root license
export * from './types';
export * from './utils';
Expand Down
2 changes: 1 addition & 1 deletion src/index-jq.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// index.jq.ts 4.0.0 - everything you need for a Grid that uses Jquery-ui drag&drop (original, full feature)
// index.jq.ts 4.0.0-dev - everything you need for a Grid that uses Jquery-ui drag&drop (original, full feature)
// (c) 2021 Alain Dumesny - see root license

export * from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/index-static.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// index.static.ts 4.0.0 - everything you need for a static Grid (non draggable)
// index.static.ts 4.0.0-dev - everything you need for a static Grid (non draggable)
// (c) 2021 Alain Dumesny - see root license

export * from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/jq/gridstack-dd-jqueryui.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// gridstack-dd-jqueryui.ts 4.0.0
// gridstack-dd-jqueryui.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license
import { GridStackElement } from '../gridstack';
import { GridStackDD, DDOpts, DDKey, DDDropOpt, DDCallback, DDValue } from '../gridstack-dd';
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// types.ts 4.0.0
// types.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license

import { GridStack } from './gridstack';
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// utils.ts 4.0.0
// utils.ts 4.0.0-dev
// (c) 2021 Alain Dumesny - see root license

import { GridStackElement, GridStackNode, GridStackOptions, numberOrString, GridStackPosition } from './types';
Expand Down Expand Up @@ -236,7 +236,7 @@ export class Utils {
if (typeof a !== 'object' || typeof b !== 'object') return;
for (let key in a) {
let val = a[key];
if (val && typeof val === 'object') {
if (val && typeof val === 'object' && b[key] !== undefined) {
for (let i in val) {
if (val[i] === b[key][i] || i[0] === '_') { delete val[i] }
}
Expand Down