zentaobiz.ui.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. window.onRenderCell = function(result, {col, row})
  2. {
  3. const {name} = col;
  4. const {data} = row;
  5. const draftLabel = `<span class='label secondary-pale'>${draftIcon}</span>`;
  6. const labelClass = 'w-full flex items-center justify-end';
  7. if(name == 'name')
  8. {
  9. if(data.type == 'table')
  10. {
  11. result[0] = data.name;
  12. return result;
  13. }
  14. if(data.stage != 'published') return [...result, {html: draftLabel, className: labelClass}];
  15. }
  16. if(name == 'version')
  17. {
  18. if(data.type == 'table') return [];
  19. const disabled = data.stage == 'draft' ? 'disabled title="' + disableVersionTip + '"' : 'data-hover="' + viewVersion + '" data-version="#' + data.version + '" data-pivot="' + row.id + '" data-size="lg"';
  20. return [{html: `<button class="btn ghost size-sm btn-version text-primary-600 ${data.stage == 'draft' ? 'disabled' : ''}" ${disabled}>#${data.version}</button>`}];
  21. }
  22. return result;
  23. }
  24. $(function()
  25. {
  26. $(document).on('mouseover', '.btn-version', function()
  27. {
  28. if($(this).hasClass('disabled')) return;
  29. $(this).removeClass('ghost').addClass('rounded-full').text($(this).data('hover'));
  30. });
  31. $(document).on('mouseout', '.btn-version', function()
  32. {
  33. if($(this).hasClass('disabled')) return;
  34. $(this).addClass('ghost').removeClass('rounded-full').text($(this).data('version'));
  35. });
  36. });
  37. $(document).off('click','.btn-version').on('click', '.btn-version', function(e)
  38. {
  39. const version = $(e.target).attr('data-version').replace(/#/g, '');;
  40. const pivotID = $(e.target).attr('data-pivot');
  41. loadModal($.createLink('pivot', 'versions', `groupID=${groupID}&pivotID=${pivotID}&version=${version}`), null, {size: 'lg'});
  42. })