MoveGroupContent.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2013, 2019
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. define(['./Move', 'jquery'], function (BaseMoveClass, $) {
  8. var Move = null;
  9. Move = BaseMoveClass.extend({
  10. init: function init() {
  11. Move.inherited('init', this, arguments);
  12. },
  13. getDragDataType: function getDragDataType() {
  14. return 'groupContent';
  15. },
  16. handleDrop: function handleDrop() /*dropContext*/{
  17. var $n, nodeInfo;
  18. var positionUpdateArray = [];
  19. for (var i = 0, iLen = this.dropInfo.nodeInfoList.length; i < iLen; i++) {
  20. // get node from info list
  21. nodeInfo = this.dropInfo.nodeInfoList[i];
  22. $n = $(nodeInfo.node);
  23. // if layout then update model
  24. if (nodeInfo.node._layout) {
  25. nodeInfo.dropPosition = {
  26. x: parseInt($n.css('left'), 10),
  27. y: parseInt($n.css('top'), 10)
  28. };
  29. var positionUpdate = nodeInfo.node._layout.parentLayout.getWidgetPositionUpdate(nodeInfo);
  30. // setup position info array to pass to model
  31. positionUpdateArray.push(positionUpdate);
  32. }
  33. }
  34. var transactionApi = this.dashboardApi.getFeature('Transaction');
  35. var transactionToken = transactionApi.startTransaction();
  36. this.updateModel(positionUpdateArray, transactionToken);
  37. this.emit('moveGroupContent:done', { 'currentSelection': this.selectedNodes, undoRedoTransactionId: transactionToken.transactionId, transactionToken: transactionToken });
  38. transactionApi.endTransaction(transactionToken);
  39. }
  40. });
  41. return Move;
  42. });
  43. //# sourceMappingURL=MoveGroupContent.js.map