@trops/dash-core 0.1.230 → 0.1.231

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6277,7 +6277,7 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6277
6277
 
6278
6278
  // --- Create logic (DASH-191: moved above useEffect so ref captures actual function) ---
6279
6279
  var handleCreate = React.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
6280
- var _state$customization, name, menuId, theme, result, _window$mainApi, installResult, updatedWorkspace, _window$mainApi2, template, layoutObj, widgetOrder, cells, _loop, i, workspace, _t;
6280
+ var _state$customization, name, menuId, theme, result, _window$mainApi, installResult, updatedWorkspace, _window$mainApi2, template, layoutObj, widgetOrder, cells, widgetItems, nextId, _loop, i, fullLayout, workspace, _t;
6281
6281
  return _regeneratorRuntime.wrap(function (_context2) {
6282
6282
  while (1) switch (_context2.prev = _context2.next) {
6283
6283
  case 0:
@@ -6344,13 +6344,15 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6344
6344
  }
6345
6345
  throw new Error("No layout template selected.");
6346
6346
  case 8:
6347
- layoutObj = createLayoutFromTemplate(template, menuId || 1); // Place widgets into grid cells
6347
+ layoutObj = createLayoutFromTemplate(template, menuId || 1); // Place widgets into grid cells as proper layout items
6348
6348
  widgetOrder = state.layout.widgetOrder || [];
6349
6349
  cells = template.cells.filter(function (c) {
6350
6350
  return !c.hide;
6351
6351
  });
6352
+ widgetItems = [];
6353
+ nextId = 2; // grid container is ID 1
6352
6354
  _loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop(i) {
6353
- var widget;
6355
+ var widget, widgetKey;
6354
6356
  return _regeneratorRuntime.wrap(function (_context) {
6355
6357
  while (1) switch (_context.prev = _context.next) {
6356
6358
  case 0:
@@ -6358,7 +6360,18 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6358
6360
  return (w.name || w.key) === widgetOrder[i];
6359
6361
  });
6360
6362
  if (widget && layoutObj.grid[cells[i].key]) {
6361
- layoutObj.grid[cells[i].key].component = widget.component || widget.name || widget.key;
6363
+ widgetKey = widget.component || widget.name || widget.key;
6364
+ widgetItems.push({
6365
+ id: nextId,
6366
+ component: widgetKey,
6367
+ parent: 1,
6368
+ order: i + 1,
6369
+ hasChildren: 0,
6370
+ scrollable: true,
6371
+ workspace: "layout"
6372
+ });
6373
+ layoutObj.grid[cells[i].key].component = nextId;
6374
+ nextId++;
6362
6375
  }
6363
6376
  case 1:
6364
6377
  case "end":
@@ -6378,12 +6391,13 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6378
6391
  _context2.next = 9;
6379
6392
  break;
6380
6393
  case 11:
6394
+ fullLayout = [layoutObj].concat(widgetItems);
6381
6395
  if (!onCreateWorkspace) {
6382
6396
  _context2.next = 13;
6383
6397
  break;
6384
6398
  }
6385
6399
  _context2.next = 12;
6386
- return onCreateWorkspace(layoutObj, theme, name.trim());
6400
+ return onCreateWorkspace(fullLayout, theme, name.trim());
6387
6401
  case 12:
6388
6402
  result = _context2.sent;
6389
6403
  _context2.next = 15;
@@ -6397,7 +6411,7 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6397
6411
  name: name.trim(),
6398
6412
  menuId: menuId || 1,
6399
6413
  themeKey: theme,
6400
- layout: [layoutObj]
6414
+ layout: fullLayout
6401
6415
  };
6402
6416
  _context2.next = 14;
6403
6417
  return window.mainApi.workspace.saveWorkspaceForApplication(appId, workspace);
@@ -48111,14 +48125,15 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
48111
48125
  function handleClickNewFromEmpty() {
48112
48126
  setIsLayoutPickerOpen(true);
48113
48127
  }
48114
- function handleCreateFromTemplate(layoutObj) {
48128
+ function handleCreateFromTemplate(layoutObjOrArray) {
48115
48129
  var themeKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
48116
48130
  var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
48117
48131
  try {
48132
+ var layout = Array.isArray(layoutObjOrArray) ? layoutObjOrArray : [layoutObjOrArray];
48118
48133
  var newWorkspace = WorkspaceModel({
48119
- layout: [layoutObj],
48134
+ layout: layout,
48120
48135
  themeKey: themeKey,
48121
- menuId: layoutObj.menuId,
48136
+ menuId: layout[0].menuId,
48122
48137
  name: name || undefined
48123
48138
  });
48124
48139
  handleOpenTab(newWorkspace);