binduser.ui.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. window.setUserEmail = function()
  2. {
  3. let email = '';
  4. const account = $(this).val();
  5. if(account && zentaoUsers[account]) email = zentaoUsers[account].email;
  6. $(this).closest('.dtable-cell').prev().find('.dtable-cell-content').text(email);
  7. }
  8. window.renderGitlabUser = function(result, {row})
  9. {
  10. const gitlabID = row.data.gitlabID;
  11. result.push({html: `<input type="hidden" name='gitlabUserNames[]' value='${gitlabID}'>`});
  12. return result;
  13. }
  14. window.bindUser = function(e)
  15. {
  16. const myDTable = $('#table-gitlab-binduser').zui('dtable');
  17. const formData = myDTable.$.getFormData();
  18. var bindData = $('#table-gitlab-binduser').zui('dtable').$.props.data;
  19. var postData = {};
  20. postData['gitlabUserNames[]'] = [];
  21. for(i in bindData)
  22. {
  23. postData['gitlabUserNames[' + bindData[i].gitlabID + ']'] = bindData[i].gitlabUser;
  24. postData['zentaoUsers[' + bindData[i].gitlabID + ']'] = formData['zentaoUsers[' + bindData[i].gitlabID + ']'];
  25. }
  26. e.preventDefault();
  27. e.stopPropagation();
  28. $.ajaxSubmit({
  29. url: $.createLink('gitlab', 'bindUser', 'gitlabID=' + gitlabID + '&type=' + type),
  30. data: postData
  31. });
  32. }
  33. window.afterPageUpdate = function($target, info)
  34. {
  35. if(info.name === 'dtable')
  36. {
  37. const dtable = zui.DTable.query('#table-gitlab-binduser');
  38. /* Clear saved formData. */
  39. if(dtable) dtable.$.resetFormData();
  40. }
  41. };