zentaoipd.ui.js 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. window.deleteGrade = function()
  2. {
  3. $(this).closest('tr').remove();
  4. $('#gradeList tbody').find('tr').last().find('.btn-add-grade').removeClass('hidden');
  5. /* compute grade. */
  6. let index = 1;
  7. $('#gradeList tbody').find('.gradeTr').each(function()
  8. {
  9. $(this).find('td.index').text(index);
  10. $(this).find('input[type=hidden]').val(index);
  11. index ++;
  12. });
  13. }
  14. window.addGrade = function()
  15. {
  16. let newRow = $(this).closest('tr').clone();
  17. let maxIndex = $(this).closest('tbody').find('tr').length;
  18. newIndex = parseInt(maxIndex);
  19. newRow.find('input').val('');
  20. newRow.find('.btn-delete-grade').attr('href', 'javascript:void').removeClass('ajax-submit hidden').on('click', deleteGrade);
  21. newRow.find('.btn-close, .btn-active').remove();
  22. newRow.find("input[type=hidden]").val(newIndex);
  23. newRow.find('td.index').text(newIndex);
  24. newRow.find('td.grade-status').text(enableLang);
  25. $(this).closest('tbody').append(newRow);
  26. $(this).addClass('hidden');
  27. };