doc.ui.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * 对标题列进行重定义。
  3. * Redefine the title column.
  4. *
  5. * @param array result
  6. * @param array info
  7. * @access public
  8. * @return string|array
  9. */
  10. window.renderCell = function(result, info)
  11. {
  12. if(info.col.name == 'title' && result[0])
  13. {
  14. const doc = info.row.data;
  15. const docIcon = doc.type == 'text' ? 'wiki-file' : doc.type;
  16. const starIcon = doc.collector.includes(account) ? 'star' : 'star-empty';
  17. let html = "<img src='static/svg/" + docIcon + ".svg' class='file-icon'/>";
  18. result.unshift({html});
  19. if(doc.status == 'draft')
  20. {
  21. html = "<span class='label special-pale rounded-full draft'>" + draftLabel + '</span>';
  22. result.push({html});
  23. }
  24. if(canCollect)
  25. {
  26. html = "<a href='" + $.createLink('doc', 'collect', 'objectID=' + doc.id + '&objectType=doc') + "' class='btn btn-link ajax-submit star'><img src='static/svg/" + starIcon + ".svg'/></a>";
  27. result.push({html});
  28. }
  29. if(result[1]['props']) result[1]['props']['class'] = 'text-ellipsis';
  30. }
  31. if(info.col.name == 'objectName' && result[0])
  32. {
  33. const doc = info.row.data;
  34. const icon = objectIconList[doc.objectType];
  35. const html = "<i class='icon " + icon + "'></i>";
  36. result.unshift({html});
  37. }
  38. if(info.col.name == 'actions')
  39. {
  40. if(info.col.setting.list.edit && info.row.data.type != 'text' && typeof result[0]['props'] != 'undefined' && typeof result[0]['props']['items'] != 'undefined')
  41. {
  42. result[0]['props']['items'][0]['data-toggle'] = 'modal';
  43. return result;
  44. }
  45. }
  46. return result;
  47. }