browse.ui.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. window.renderCell = function(result, {col, row})
  2. {
  3. if(col.name == 'system' && row.data.releases)
  4. {
  5. result[0] = {className: 'overflow-hidden', html: result[0]};
  6. result[result.length] = {html:'<span class="label gray-pale rounded-xl clip">' + integratedLabel + '</span>', className:'flex items-end', style:{flexDirection:"column"}};
  7. }
  8. if(col.name == 'name')
  9. {
  10. if(row.data.marker == 1)
  11. {
  12. result[result.length] = {html: "<icon class='icon icon-flag text-danger' title='" + markerTitle + "'></icon>"};
  13. return result;
  14. }
  15. }
  16. if(col.name == 'build')
  17. {
  18. if(!row.data.buildInfos) row.data.buildInfos = row.data.builds;
  19. let result = [];
  20. for(key in row.data.buildInfos)
  21. {
  22. let buildName = canViewProjectbuild ? "<a href='" + $.createLink('projectbuild', 'view', 'buildID=' + row.data.buildInfos[key].id) + "' title='" + row.data.buildInfos[key].name + "'>" + row.data.buildInfos[key].name + '</a>' : row.data.buildInfos[key].name;
  23. result.push({html: buildName})
  24. }
  25. return result;
  26. }
  27. return result;
  28. }
  29. window.checkedChange = function(changes)
  30. {
  31. if(!this._checkedRows) this._checkedRows = {};
  32. Object.keys(changes).forEach((rowID) =>
  33. {
  34. const row = this.getRowInfo(rowID);
  35. if(row !== undefined) this._checkedRows[rowID] = row.data;
  36. });
  37. }
  38. window.insertListToDoc = function()
  39. {
  40. const dtable = zui.DTable.query($('#projectreleases'));
  41. const myTable = dtable.$;
  42. const checkedList = Object.keys(myTable.state.checkedRows);
  43. if(!checkedList.length) return;
  44. let {cols} = dtable.options;
  45. const data = checkedList.map(rowID => myTable._checkedRows[rowID]);
  46. const docID = getDocApp()?.docID;
  47. const blockType = 'projectRelease';
  48. const url = $.createLink('doc', 'buildZentaoList', `docID=${docID}&type=${blockType}&blockID=${blockID}`);
  49. const formData = new FormData();
  50. formData.append('cols', JSON.stringify(cols));
  51. formData.append('data', JSON.stringify(data));
  52. formData.append('idList', checkedList.join(','));
  53. formData.append('url', insertListLink);
  54. $.post(url, formData, function(resp)
  55. {
  56. resp = JSON.parse(resp);
  57. if(resp.result == 'success')
  58. {
  59. const oldBlockID = resp.oldBlockID;
  60. const newBlockID = resp.newBlockID;
  61. zui.Modal.hide();
  62. window.insertZentaoList && window.insertZentaoList(blockType, newBlockID, null, oldBlockID);
  63. }
  64. });
  65. }
  66. window.firstRendered = false;
  67. window.toggleCheckRows = function(idList)
  68. {
  69. if(!idList?.length || firstRendered) return;
  70. firstRendered = true;
  71. const dtable = zui.DTable.query($('#projectreleases'));
  72. dtable.$.toggleCheckRows(idList.split(','), true);
  73. }