importbug.ui.js 995 B

123456789101112131415161718192021222324252627282930313233343536
  1. $(document).off('click', '.import-bug-btn').on('click', '.import-bug-btn', function()
  2. {
  3. const dtable = zui.DTable.query($(this).target);
  4. const checkedList = dtable.$.getChecks();
  5. if(!checkedList.length) return false;
  6. const importDTable = $('#table-execution-importbug').zui('dtable');
  7. const formData = importDTable.$.getFormData();
  8. checkedList.forEach((id) => formData[`id[${id}]`] = id);
  9. $.ajaxSubmit({url: $('#importForm').attr('action'), data: formData, onFail: printError});
  10. return false;
  11. });
  12. /**
  13. * Print error message.
  14. *
  15. * @param error $error
  16. * @access public
  17. * @return void
  18. */
  19. function printError(result)
  20. {
  21. Object.entries(result.message).forEach(([name, msg]) => {
  22. if (Array.isArray(msg)) {
  23. msg = msg.join('');
  24. }
  25. zui.Modal.alert(msg);
  26. })
  27. }
  28. window.onSearchLinks = function(type, result)
  29. {
  30. loadComponent('#table-execution-importbug', {url: result.load, component: 'dtable', partial: true});
  31. };