assigntomeblock.ui.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. window.handleAssignToMeTabShow = function()
  2. {
  3. let activeMore = false;
  4. $(this).find('.menu-item a[data-toggle=tab]').each(function()
  5. {
  6. if($(this).hasClass('active'))
  7. {
  8. $(this).closest('.nav-item.nav-switch').find('a[data-toggle=dropdown] span').html($(this).html());
  9. $(this).closest('.nav-item.nav-switch').find('a[data-toggle=dropdown]').addClass('active');
  10. activeMore = true;
  11. }
  12. });
  13. if(!activeMore)
  14. {
  15. $(this).find('.nav-item a[data-toggle=dropdown] span').html(moreLabel);
  16. $(this).find('.nav-item a[data-toggle=dropdown]').removeClass('active');
  17. }
  18. };
  19. window.clickItems = function(event)
  20. {
  21. $(event.target).closest('ul').find('a[data-toggle=dropdown]').toggleClass('active', $(event.target).closest('menu').length);
  22. }
  23. /**
  24. * 对部分列进行重定义。
  25. * Redefine the partial column.
  26. *
  27. * @param array result
  28. * @param array info
  29. * @access public
  30. * @return string|array
  31. */
  32. window.renderCell = function(result, info)
  33. {
  34. if(info.col.name == 'deadline' && result[0])
  35. {
  36. const current = zui.createDate();
  37. const year = zui.formatDate(current, 'yyyy');
  38. const today = zui.formatDate(current, 'yyyy-MM-dd');
  39. const yesterday = zui.formatDate(convertStringToDate(today) - 24 * 60 * 60 * 1000, 'yyyy-MM-dd');
  40. let deadline = result[0];
  41. if(deadline.split('-').length == 2) deadline = year + '-' + deadline;
  42. if(deadline == today)
  43. {
  44. result[0] = {html: '<span class="label warning-pale rounded-full size-sm">' + todayLabel + '</span>'};
  45. }
  46. else if(deadline == yesterday)
  47. {
  48. result[0] = {html: '<span class="label danger-pale rounded-full size-sm">' + yesterdayLabel + '</span>'};
  49. }
  50. else if(deadline < yesterday)
  51. {
  52. result[0] = {html: '<span class="label danger-pale rounded-full size-sm">' + result + '</span>'};
  53. }
  54. }
  55. if(info.col.name == 'confirmed' && info.row.data.confirmed == 0) result[0] = {html: '<span class="text-gray">' + result[0] + '</span>'};
  56. if(info.col.name == 'title' && info.row.data.isShadowProduct !== undefined)
  57. {
  58. const openTab = info.row.data.isShadowProduct == '1' ? 'project' : 'product';
  59. result[0] = {html: '<a href="' + $.createLink(info.row.data.storyType, 'view', `id=${info.row.data.id}`) + '" data-app="' + openTab + '">' + info.row.data.title + '</a>'};
  60. }
  61. if(info.col.name == 'title' && info.row.data.module == 'attend') result[0] = {html: '<span>' + result[0].props.children + '</span>'};
  62. if(info.col.name == 'name' && typeof info.row.data.delay != 'undefined' && info.row.data.delay > 0) result[result.length] = {html:'<span class="label danger-pale ml-1 flex-none nowrap">' + delayWarning.replace('%s', info.row.data.delay) + '</span>', className: 'flex items-end', style: {flexDirection:"column"}};
  63. return result;
  64. }
  65. function convertStringToDate(dateString)
  66. {
  67. dateString = dateString.split('-');
  68. dateString = dateString[1] + '/' + dateString[2] + '/' + dateString[0];
  69. return Date.parse(dateString);
  70. }