@trops/dash-core 0.1.230 → 0.1.232

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.esm.js CHANGED
@@ -6259,7 +6259,7 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6259
6259
 
6260
6260
  // --- Create logic (DASH-191: moved above useEffect so ref captures actual function) ---
6261
6261
  var handleCreate = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
6262
- var _state$customization, name, menuId, theme, result, _window$mainApi, installResult, updatedWorkspace, _window$mainApi2, template, layoutObj, widgetOrder, cells, _loop, i, workspace, _t;
6262
+ var _state$customization, name, menuId, theme, result, _window$mainApi, installResult, updatedWorkspace, _window$mainApi2, template, layoutObj, widgetOrder, cells, widgetItems, nextId, _loop, i, fullLayout, workspace, _t;
6263
6263
  return _regeneratorRuntime.wrap(function (_context2) {
6264
6264
  while (1) switch (_context2.prev = _context2.next) {
6265
6265
  case 0:
@@ -6326,13 +6326,15 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6326
6326
  }
6327
6327
  throw new Error("No layout template selected.");
6328
6328
  case 8:
6329
- layoutObj = createLayoutFromTemplate(template, menuId || 1); // Place widgets into grid cells
6329
+ layoutObj = createLayoutFromTemplate(template, menuId || 1); // Place widgets into grid cells as proper layout items
6330
6330
  widgetOrder = state.layout.widgetOrder || [];
6331
6331
  cells = template.cells.filter(function (c) {
6332
6332
  return !c.hide;
6333
6333
  });
6334
+ widgetItems = [];
6335
+ nextId = 2; // grid container is ID 1
6334
6336
  _loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop(i) {
6335
- var widget;
6337
+ var widget, widgetKey;
6336
6338
  return _regeneratorRuntime.wrap(function (_context) {
6337
6339
  while (1) switch (_context.prev = _context.next) {
6338
6340
  case 0:
@@ -6340,7 +6342,18 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6340
6342
  return (w.name || w.key) === widgetOrder[i];
6341
6343
  });
6342
6344
  if (widget && layoutObj.grid[cells[i].key]) {
6343
- layoutObj.grid[cells[i].key].component = widget.component || widget.name || widget.key;
6345
+ widgetKey = widget.component || widget.name || widget.key;
6346
+ widgetItems.push({
6347
+ id: nextId,
6348
+ component: widgetKey,
6349
+ parent: 1,
6350
+ order: i + 1,
6351
+ hasChildren: 0,
6352
+ scrollable: true,
6353
+ workspace: "layout"
6354
+ });
6355
+ layoutObj.grid[cells[i].key].component = nextId;
6356
+ nextId++;
6344
6357
  }
6345
6358
  case 1:
6346
6359
  case "end":
@@ -6360,12 +6373,13 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6360
6373
  _context2.next = 9;
6361
6374
  break;
6362
6375
  case 11:
6376
+ fullLayout = [layoutObj].concat(widgetItems);
6363
6377
  if (!onCreateWorkspace) {
6364
6378
  _context2.next = 13;
6365
6379
  break;
6366
6380
  }
6367
6381
  _context2.next = 12;
6368
- return onCreateWorkspace(layoutObj, theme, name.trim());
6382
+ return onCreateWorkspace(fullLayout, theme, name.trim());
6369
6383
  case 12:
6370
6384
  result = _context2.sent;
6371
6385
  _context2.next = 15;
@@ -6379,7 +6393,7 @@ var WizardCustomizeStep = function WizardCustomizeStep(_ref) {
6379
6393
  name: name.trim(),
6380
6394
  menuId: menuId || 1,
6381
6395
  themeKey: theme,
6382
- layout: [layoutObj]
6396
+ layout: fullLayout
6383
6397
  };
6384
6398
  _context2.next = 14;
6385
6399
  return window.mainApi.workspace.saveWorkspaceForApplication(appId, workspace);
@@ -48093,14 +48107,15 @@ var DashboardStageInner = function DashboardStageInner(_ref2) {
48093
48107
  function handleClickNewFromEmpty() {
48094
48108
  setIsLayoutPickerOpen(true);
48095
48109
  }
48096
- function handleCreateFromTemplate(layoutObj) {
48110
+ function handleCreateFromTemplate(layoutObjOrArray) {
48097
48111
  var themeKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
48098
48112
  var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
48099
48113
  try {
48114
+ var layout = Array.isArray(layoutObjOrArray) ? layoutObjOrArray : [layoutObjOrArray];
48100
48115
  var newWorkspace = WorkspaceModel({
48101
- layout: [layoutObj],
48116
+ layout: layout,
48102
48117
  themeKey: themeKey,
48103
- menuId: layoutObj.menuId,
48118
+ menuId: layout[0].menuId,
48104
48119
  name: name || undefined
48105
48120
  });
48106
48121
  handleOpenTab(newWorkspace);