all.ui.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. window.footerGenerator = function()
  2. {
  3. const count = this.layout.allRows.filter((x) => x.data.type === "product").length;
  4. const statistic = langSummary.replace('%s', ' ' + count + ' ');
  5. return [{children: statistic, className: "text-dark"}, "flex", "pager"];
  6. };
  7. window.renderReleaseCountCell = function(result, {col, row})
  8. {
  9. if(!col || !row || col.name !== 'releases') return result;
  10. var changed = row.data.releases - row.data.releasesOld;
  11. if(changed === 0) result[0] = 0;
  12. if(changed > 0) result[0] = {html: row.data.releases + ' <span class="label size-sm circle primary-pale bd-primary">+' + changed + '</span>'};
  13. if(changed < 0) result[0] = {html: row.data.releases + ' <span class="label size-sm circle warning-pale bd-warning">' + changed + '</span>'};
  14. return result;
  15. };
  16. window.programMenuOnClick = function(data, url)
  17. {
  18. loadPage(url.replace('%d', data.item.key));
  19. };
  20. /**
  21. * Get checked items.
  22. *
  23. * @access public
  24. * @return array
  25. */
  26. function getCheckedItems()
  27. {
  28. var checkedItems = [];
  29. $('#productListForm [name^=productIDList]:checked').each(function(index, ele)
  30. {
  31. checkedItems.push($(ele).val());
  32. });
  33. return checkedItems;
  34. };
  35. /**
  36. * 拖拽的产品是否允许放下。
  37. * Is it allowed to drop the dragged product.
  38. *
  39. * @param from 被拿起的元素
  40. * @param to 放下时的目标元素
  41. * @access public
  42. * @return bool
  43. */
  44. window.canSortTo = function(from, to)
  45. {
  46. if(!from || !to) return false;
  47. return true;
  48. }
  49. /**
  50. * 拖拽产品。
  51. * Drag product.
  52. *
  53. * @param from 被拿起的元素
  54. * @param to 放下时的目标元素
  55. * @param type 放在目标元素的上方还是下方
  56. * @access public
  57. * @return bool
  58. */
  59. window.onSortEnd = function(from, to, type)
  60. {
  61. if(!from || !to) return false;
  62. const url = $.createLink('product', 'updateOrder');
  63. const form = new FormData();
  64. form.append('orderBy', orderBy);
  65. form.append('products', JSON.stringify(this.state.rowOrders));
  66. $.ajaxSubmit({url, data: form});
  67. return true;
  68. }