swimlanes.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. Meteor.methods({
  2. moveSwimlane(swimlaneId, toBoardId) {
  3. check(swimlaneId, String);
  4. check(toBoardId, String);
  5. const swimlane = Swimlanes.findOne(swimlaneId);
  6. const fromBoard = Boards.findOne(swimlane.boardId);
  7. const toBoard = Boards.findOne(toBoardId);
  8. if (swimlane && toBoard) {
  9. swimlane.lists().forEach(list => {
  10. const toList = Lists.findOne({
  11. boardId: toBoardId,
  12. title: list.title,
  13. archived: false,
  14. });
  15. let toListId;
  16. if (toList) {
  17. toListId = toList._id;
  18. } else {
  19. toListId = Lists.insert({
  20. title: list.title,
  21. boardId: toBoardId,
  22. type: list.type,
  23. archived: false,
  24. wipLimit: list.wipLimit,
  25. });
  26. }
  27. Cards.find({
  28. listId: list._id,
  29. swimlaneId,
  30. }).forEach(card => {
  31. card.move(toBoardId, swimlaneId, toListId);
  32. });
  33. });
  34. Swimlanes.update(swimlaneId, {
  35. $set: {
  36. boardId: toBoardId,
  37. },
  38. });
  39. // make sure there is a default swimlane
  40. fromBoard.getDefaultSwimline();
  41. return true;
  42. }
  43. return false;
  44. },
  45. });