zentaomax.ui.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. window.actionItemCreator = function(item, info)
  2. {
  3. if(item.url)
  4. {
  5. if(typeof item.url == 'string') item.url = zui.formatString(item.url, info.row.data);
  6. else item.url.params = zui.formatString(item.url.params, info.row.data);
  7. }
  8. else if(item.disabled)
  9. {
  10. const report = info.row.data;
  11. if(item.icon == 'edit')
  12. {
  13. if(report.weeklyDate != '')
  14. {
  15. item.hint = disabledHint.cannotEditWeekly;
  16. }
  17. else if(report.reportModule == 'milestone')
  18. {
  19. item.hint = disabledHint.cannotEditMilestone;
  20. }
  21. else
  22. {
  23. item.hint = disabledHint.edit;
  24. }
  25. }
  26. if(item.icon == 'trash') item.hint = report.weeklyDate != '' ? disabledHint.cannotDeleteWeekly : disabledHint.cannotDeleteMilestone;
  27. }
  28. return item;
  29. }
  30. window.renderCell = function(result, info)
  31. {
  32. const report = info.row.data;
  33. if(info.col.name == 'title' && result)
  34. {
  35. if(report.status == 'draft')
  36. {
  37. if(typeof result[0] == 'object') result[0].props.className = 'flex-auto clip';
  38. else result[0] = {html: `<div class='flex-auto clip'>${report.title}</div>`, className: 'flex-auto clip'};
  39. result[result.length] = {html: '<div class="label special-pale rounded-full ml-1 flex-none nowrap">' + draftText + '</div>', className: 'flex items-end', style: { flexDirection: "column" }};
  40. }
  41. if(typeof result[0] == 'object' && report.weeklyDate != '')
  42. {
  43. result[0].props.href = $.createLink('weekly', 'index', `projectID=${report.project}&date=${report.weeklyDate}`);
  44. }
  45. if(typeof result[0] == 'object' && report.reportModule == 'milestone')
  46. {
  47. result[0].props.href = $.createLink('milestone', 'index', `projectID=${report.project}`);
  48. }
  49. }
  50. return result;
  51. }
  52. window.confirmDeleteCategory = function(projectID, moduleID)
  53. {
  54. $.get($.createLink('weekly', 'ajaxCheckDeleteCategory', `projectID=${projectID}&moduleID=${moduleID}`), function(result)
  55. {
  56. if(!result) return zui.Modal.alert(errorDeleteCategoryText);
  57. zui.Modal.confirm(confirmDeleteCategoryText).then((res) =>
  58. {
  59. if(res) $.ajaxSubmit({url: $.createLink('weekly', 'deleteCategory', `moduleID=${moduleID}`)});
  60. });
  61. })
  62. }