From 0ab56afbe098ef1df55685bf0984e55414d05804 Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Sat, 1 Jul 2023 20:29:25 -0700 Subject: [PATCH] ng two.html demo added two grid demo to angular demo. showing issue with component not being created/deleted when dragged. --- .../projects/demo/src/app/app.component.html | 32 ++++++++++++++++ .../projects/demo/src/app/app.component.ts | 25 ++++++++++--- angular/projects/demo/src/styles.css | 37 +++++++++++++++++++ 3 files changed, 89 insertions(+), 5 deletions(-) diff --git a/angular/projects/demo/src/app/app.component.html b/angular/projects/demo/src/app/app.component.html index d76695e4a..50d2eea1b 100644 --- a/angular/projects/demo/src/app/app.component.html +++ b/angular/projects/demo/src/app/app.component.html @@ -8,6 +8,7 @@ +
@@ -68,6 +69,37 @@
+
+

two.html: shows multiple grids and outside drag&drop

+
+
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+ +
diff --git a/angular/projects/demo/src/app/app.component.ts b/angular/projects/demo/src/app/app.component.ts index 21c7f24a1..f12c6d059 100644 --- a/angular/projects/demo/src/app/app.component.ts +++ b/angular/projects/demo/src/app/app.component.ts @@ -66,6 +66,23 @@ export class AppComponent implements OnInit { acceptWidgets: true, children: this.subChildren }; + public twoGridOpt1: NgGridStackOptions = { + column: 6, + cellHeight: 50, + margin: 5, + minRow: 1, // don't collapse when empty + disableOneColumnMode: true, + removable: '.trash', + acceptWidgets: true, + float: true, + children: [ + {x: 0, y: 0, w: 2, h: 2}, + {x: 3, y: 1, h: 2}, + {x: 4, y: 1}, + {x: 2, y: 3, w: 3, maxW: 3, id: 'special', content: 'has maxW=3'}, + ] + }; + public twoGridOpt2: NgGridStackOptions = { ...this.twoGridOpt1, float: false } private serializedData?: NgGridStackOptions; constructor() { @@ -110,15 +127,13 @@ export class AppComponent implements OnInit { case 4: data = this.items; break; case 5: data = this.gridOptionsFull; break; case 6: data = this.nestedGridOptions; break; + case 7: data = this.twoGridOpt1; + GridStack.setupDragIn('.sidebar .grid-stack-item', { appendTo: 'body', helper: 'clone' }); + break; } if (this.origTextEl) this.origTextEl.nativeElement.value = JSON.stringify(data, null, ' '); }); if (this.textEl) this.textEl.nativeElement.value = ''; - - // if (val === 6 && !this.gridComp) { - // const cont: HTMLElement | null = document.querySelector('.grid-container'); - // if (cont) GridStack.addGrid(cont, this.serializedData); - // } } /** called whenever items change size/position/etc.. */ diff --git a/angular/projects/demo/src/styles.css b/angular/projects/demo/src/styles.css index 3ab2894f3..261eeebed 100644 --- a/angular/projects/demo/src/styles.css +++ b/angular/projects/demo/src/styles.css @@ -2,3 +2,40 @@ @import "../../../../demo/demo.css"; /* required file for gridstack 2-11 column */ @import "../../../../dist/gridstack-extra.css"; + +/* for two.html example from bootstrap.min.css */ +.row { + display: -ms-flexbox; + display: flex; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + margin-right: -15px; + margin-left: -15px; + box-sizing: border-box; +} +.col-md-3 { + -ms-flex: 0 0 25%; + flex: 0 0 25%; + max-width: 25%; + box-sizing: border-box; +} +.col-md-9 { + -ms-flex: 0 0 75%; + flex: 0 0 75%; + max-width: 75%; + box-sizing: border-box; +} +.col-md-6 { + -ms-flex: 0 0 50%; + flex: 0 0 50%; + max-width: 50%; + box-sizing: border-box; +} +.col, .col-1, .col-10, .col-11, .col-12, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-auto, .col-lg, .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-auto, .col-md, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-auto, .col-sm, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-auto { + position: relative; + width: 100%; + padding-right: 15px; + padding-left: 15px; + box-sizing: border-box; +} +