UNPKG

@metacell/geppetto-meta-client

Version:

Geppetto web frontend. Geppetto is an open-source platform to build web-based tools to visualize and simulate neuroscience data and models.

60 lines (59 loc) 1.98 kB
import { TabsetPosition, WidgetStatus } from "../model"; import * as FlexLayout from 'flexlayout-react'; /** * Create a new tab set. * * @param model * @param {string} tabsetID the id of the tab set * @param position * @param weight * @private */ export function createTabSet(model, tabsetID) { var position = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : TabsetPosition.RIGHT; var weight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 50; var rootNode = model.getRoot(); var tabset = new FlexLayout.TabSetNode(model, { id: tabsetID }); switch (position) { case TabsetPosition.RIGHT: rootNode.getChildren().forEach(function (node) { return node.setWeight(100 - weight); }); rootNode.addChild(tabset); break; case TabsetPosition.LEFT: rootNode.getChildren().forEach(function (node) { return node.setWeight(100 - weight); }); rootNode.addChild(tabset, 0); break; case TabsetPosition.BOTTOM: case TabsetPosition.TOP: { var hrow = new FlexLayout.RowNode(model, rootNode.windowId, {}); if (position === TabsetPosition.BOTTOM) { hrow.addChild(tabset); } else { hrow.addChild(tabset, 0); } rootNode.getChildren().forEach(function (child) { if (child.getWeight) { var newWeight = child.getWeight() / 2; child.setWeight(newWeight); hrow.addChild(child, 0); } }); rootNode.removeAll(); rootNode.addChild(hrow); tabset.setWeight(80); hrow.setWeight(100); } } return tabset; } export function moveWidget(model, widget) { var select = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : widget.status === WidgetStatus.ACTIVE; model.doAction(FlexLayout.Actions.moveNode(widget.id, widget.panelName, FlexLayout.DockLocation.CENTER, widget.pos, select)); }