1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 'use strict';
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2016, 2019
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *
- * Drag-and-Drop Manager
- */
- define([], function () {
- var DnDHelper = {
- _id: null,
- /** Handles drag'n'drop for when the user drags a widget on to something that isn't the actual target, but rather
- * is another page. Examples where it is used include when dragging a widget on to a frame in the filmstrip (for a story) or
- * a tab in a tabbed dashboard.
- * @param canvas - the canvasAPI
- * @param parentId - The id (string) that the widget is dropped on to.
- * @param dragObject - the widget being dragged.
- */
- handleWidgetDrop: function handleWidgetDrop(canvas, parentId, dragObject) {
- if (canvas) {
- if (dragObject.data.operation === 'new') {
- var widgetContent = this._prepareWidgetContent(parentId, dragObject);
- canvas.addContent(widgetContent);
- } else if (dragObject.data.operation === 'move') {
- var contentIdList = this._getContentIdList(dragObject);
- canvas.moveContent(parentId, contentIdList);
- }
- }
- },
- /** Prepares a drag'n'drop widget for 'blind' drops, such as when we drag a widget on to
- * a frame in the film strip that isn't the currently selected one.
- */
- _prepareWidgetContent: function _prepareWidgetContent(parentId, dragObject) {
- var layoutProperties = dragObject.data.layoutProperties.style || {};
- var widgetContent = {
- containerId: parentId,
- layout: _extends({}, layoutProperties),
- spec: _extends({
- style: layoutProperties
- }, dragObject.widgetSpec.model)
- };
- return widgetContent;
- },
- _getContentIdList: function _getContentIdList(dragObject) {
- var nodesInfoList = dragObject.data && dragObject.data.nodeInfoList;
- var contentIdList = nodesInfoList.map(function (nodesInfo) {
- if (nodesInfo && nodesInfo.node && nodesInfo.node._layout) {
- return nodesInfo.node._layout.model && nodesInfo.node._layout.model.id;
- }
- });
- return contentIdList;
- }
- };
- return DnDHelper;
- });
- //# sourceMappingURL=DnDHelper.js.map
|