kanban.ui.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 = delayed;
  14. info.item.suffixClass = 'label danger rounded-xl' + (info.item.status == 'doing' ? ' mr-8' : '');
  15. }
  16. if(info.item.status == 'doing') info.item.prefix = {component: 'ProgressCircle', props: {percent: info.item.progress, size: 24}};
  17. if(info.item.cardType == 'execution' && privs.canViewExecution)
  18. {
  19. info.item.titleUrl = $.createLink('execution', 'task', `id=${info.item.id}`);
  20. }
  21. else if(info.item.cardType == 'project' && privs.canViewProject)
  22. {
  23. info.item.titleUrl = $.createLink('project', 'index', `id=${info.item.id}`);
  24. }
  25. info.item.titleAttrs = {'class': 'text-black clip', 'title' : info.item.title};
  26. }
  27. window.canDrop = function(dragInfo, dropInfo)
  28. {
  29. if(!dragInfo) return false;
  30. const column = this.getCol(dropInfo.col);
  31. const lane = this.getLane(dropInfo.lane);
  32. if(!column || !lane) return false;
  33. if(dropInfo.type == 'item') return false;
  34. if(dragInfo.item.lane != lane.name) return false;
  35. if(dragInfo.item.cardType == 'execution') return false;
  36. if(dragInfo.item.status == 'wait' && dropInfo.col == 'doingProjects') return privs.canStartProject;
  37. if(dragInfo.item.status == 'wait' && dropInfo.col == 'closed') return privs.canCloseProject;
  38. if(dragInfo.item.status == 'doing' && dropInfo.col == 'closed') return privs.canCloseProject;
  39. if(dragInfo.item.status == 'closed' && dropInfo.col == 'doingProjects') return privs.canActivateProject;
  40. return false;
  41. }
  42. window.onDrop = function(changes, dropInfo)
  43. {
  44. const item = dropInfo['drag']['item'];
  45. const toCol = dropInfo['drop']['col'];
  46. if(item.status == 'wait') methodName = toCol == 'doingProjects' ? 'start' : 'close';
  47. if(item.status == 'doing') methodName = 'close';
  48. if(item.status == 'closed') methodName = 'activate';
  49. zui.Modal.open({url: $.createLink('project', methodName, 'projectID=' + item.id), size: 'lg'});
  50. return false;
  51. }