Skip to content

Commit

Permalink
Merge pull request #2659 from adumesny/master
Browse files Browse the repository at this point in the history
tweak to gsCreateNgComponents deserialize
  • Loading branch information
adumesny authored Apr 13, 2024
2 parents d53dfe1 + 1a6fd4b commit e144046
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions angular/projects/lib/src/lib/gridstack.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,16 @@ export function gsCreateNgComponents(host: GridCompHTMLElement | HTMLElement, w:
gridItem.ref = gridItemRef

// IFF we're not a subGrid, define what type of component to create as child, OR you can do it GridstackItemComponent template, but this is more generic
const selector = (w as NgGridStackWidget).selector;
const type = selector ? GridstackComponent.selectorToType[selector] : undefined;
if (!w.subGridOpts && type) {
const childWidget = gridItem.container?.createComponent(type)?.instance as BaseWidget;
if (typeof childWidget?.serialize === 'function' && typeof childWidget?.deserialize === 'function') {
// proper BaseWidget subclass, save it and load additional data
gridItem.childWidget = childWidget;
childWidget.deserialize(w);
if (!w.subGridOpts) {
const selector = (w as NgGridStackWidget).selector;
const type = selector ? GridstackComponent.selectorToType[selector] : undefined;
if (type) {
const childWidget = gridItem.container?.createComponent(type)?.instance as BaseWidget;
// if proper BaseWidget subclass, save it and load additional data
if (childWidget && typeof childWidget.serialize === 'function' && typeof childWidget.deserialize === 'function') {
gridItem.childWidget = childWidget;
childWidget.deserialize(w);
}
}
}

Expand Down

0 comments on commit e144046

Please sign in to comment.