executionkanban.ui.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. window.getCol = function(col)
  2. {
  3. if(col.cards) col.subtitle = {html: "<span class='text-gray ml-1'>" + col.cards + "</span>"};
  4. }
  5. window.itemRender = function(info)
  6. {
  7. info.item.className.push('card-item-' + (info.item.status == 'doing' && info.item.delay ? 'delay' : info.item.status));
  8. }
  9. window.getItem = function(info)
  10. {
  11. if(info.item.delay)
  12. {
  13. info.item.suffix = delayInfo.replace('%s', info.item.delay);
  14. info.item.suffixClass = 'label danger-pale circle size-sm nowrap mr-8';
  15. }
  16. info.item.prefix = {component: 'ProgressCircle', props: {percent: info.item.progress, size: 24}};
  17. info.item.titleAttrs = {'class': 'text-black clip ' + (info.item.delay ? '' : 'mr-8'), 'title' : info.item.title};
  18. if(privs.canViewExecution) info.item.titleUrl = $.createLink('execution', 'task', `id=${info.item.id}`);
  19. }
  20. window.canDrop = function(dragInfo, dropInfo)
  21. {
  22. if(!dragInfo) return false;
  23. const column = this.getCol(dropInfo.col);
  24. const lane = this.getLane(dropInfo.lane);
  25. if(!column || !lane) return false;
  26. if(dropInfo.type == 'item') return false;
  27. if(dragInfo.item.lane != lane.name) return false;
  28. if(dragInfo.item.status == 'wait' && dropInfo.col == 'doing') return privs.canStartExecution;
  29. if(dragInfo.item.status == 'wait' && dropInfo.col == 'suspended') return privs.canSuspendExecution;
  30. if(dragInfo.item.status == 'wait' && dropInfo.col == 'closed') return privs.canCloseExecution;
  31. if(dragInfo.item.status == 'doing' && dropInfo.col == 'closed') return privs.canCloseExecution;
  32. if(dragInfo.item.status == 'doing' && dropInfo.col == 'suspended') return privs.canSuspendExecution;
  33. if(dragInfo.item.status == 'suspended' && dropInfo.col == 'closed') return privs.canCloseExecution;
  34. if(dragInfo.item.status == 'suspended' && dropInfo.col == 'doing') return privs.canActivateExecution;
  35. if(dragInfo.item.status == 'closed' && dropInfo.col == 'doing') return privs.canActivateExecution;
  36. return false;
  37. }
  38. window.onDrop = function(changes, dropInfo)
  39. {
  40. const item = dropInfo['drag']['item'];
  41. const toCol = dropInfo['drop']['col'];
  42. if(item.status == 'wait' && toCol == 'doing') methodName = 'start';
  43. if(item.status == 'wait' && toCol == 'suspended') methodName = 'suspend';
  44. if(item.status == 'wait' && toCol == 'closed') methodName = 'close';
  45. if(item.status == 'doing') methodName = toCol == 'suspended' ? 'suspend' : 'close';
  46. if(item.status == 'suspended') methodName = toCol == 'doing' ? 'activate' : 'close';
  47. if(item.status == 'closed') methodName = 'activate';
  48. zui.Modal.open({url: $.createLink('execution', methodName, 'executionID=' + item.id), size: 'lg'});
  49. return false;
  50. }