uploads.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. {% extends base %}
  2. {% block content %}
  3. {% import "macros/action_icons_static.html" as icons with context %}
  4. <span class="title"><h2>{% block title %}Capture Record Uploads{% endblock %}</h2></span>
  5. <div>Manage documents for <span style="font-weight: bold;">{{ names }}</span>.</div>
  6. <div class="content-container content">
  7. {% if record_qualifications %}
  8. <article>
  9. <h3>Current Qualifications on Record - for reference</h3>
  10. <ul>
  11. {% for qualification in record_qualifications %}
  12. <li>{{ qualification.v_qualification_name }}&nbsp;{{ qualification.d_acquired|date_format }}</li>
  13. {% endfor %}
  14. </ul>
  15. </article>
  16. {% endif %}{# end of checking for existing qualification records #}
  17. <article>
  18. <h3>Upload Documents</h3>
  19. <div><a href="#" id="a_upload_document">Upload Document</a></div>
  20. {% if document_uploads %}
  21. <div class="table-container">
  22. <table class="data-table" id="tbl_uploads">
  23. <thead>
  24. <tr>
  25. <th>File Name</th><th>Type</th><th>Matching Qualification></th><th>Description</th><th style="font-size: smaller;">[Actions]</th>
  26. </tr>
  27. </thead>
  28. <tbody>
  29. {% for upload in document_uploads %}
  30. <tr>
  31. <td><a href="{{ url_for("main.download_upload", i_upload=upload.id, bl_download=False) }}" class="a_view_upload" target="_blank">{{ icons.view_svg(s_label="view upload") }}</a>&nbsp;{{ upload.v_filename }}</td><td>{{ upload.si_upload_type }}</td><td>{{ upload.v_qualification_name }}</td><td>{{ upload.v_description }}</td><td><a href="#{{ upload.id }}" class="a_remove_upload">{{ icons.delete_svg(s_label="remove upload") }}</a></td>
  32. </tr>
  33. {% endfor %}{# end of looping through existing document uploads #}
  34. </tbody>
  35. </table><!-- end of tbl_uploads -->
  36. </div><!-- end of div.table-container -->
  37. {% endif %}{# end of checking for existing document uploads #}
  38. </article>
  39. </div><!-- end of div.content -->
  40. {% from "macros/dialog.html" import dlg_prep with context %}
  41. {{ dlg_prep(["dlg_upload"]) }}
  42. {# dlg divs below #}
  43. <div id="dlg_upload" aria-labeledby="spn_upload">
  44. <span id="spn_upload">Upload document</span><br>
  45. <form action="{{ url_for("main.uploads", i_record=record_id) }}" method="post" enctype="multipart/form-data" id="frm_upload">
  46. {{ upload_form.csrf_token }}
  47. <ul>
  48. <li>{{ upload_form.sel_upload_type.label }}&nbsp;{{ upload_form.sel_upload_type }}</li>
  49. <li>{{ upload_form.sel_match.label }}&nbsp;{{ upload_form.sel_match }}</li>
  50. <li>{{ upload_form.fil_upload_document.label }}&nbsp;{{ upload_form.fil_upload_document }}<br></li>
  51. <li>{{ upload_form.txt_description.label }}<br>
  52. {{ upload_form.txt_description }}</li>
  53. </ul>
  54. <input type="submit" name="btn_upload" value="Upload document">
  55. </form>
  56. </div><!-- end of dlg_upload -->
  57. <script type="text/javascript">
  58. $(document).ready( function() {
  59. try {
  60. var s_dlg_upload = $("#dlg_upload").html();
  61. $("#a_upload_document").click( function(event) {
  62. event.preventDefault();
  63. $("#dlg_upload").html(s_dlg_upload);
  64. $("#dlg_upload").redraw();
  65. $("#dlg_upload").dialog("open");
  66. });// end of #a_upload_document click event
  67. $("#tbl_uploads").on("click", ".a_remove_upload", function(event) {
  68. event.preventDefault();
  69. var s_id = String($(this).attr("href")).replace("#", "");
  70. var bl_confirm = confirm("Are you sure?");
  71. if (bl_confirm) {
  72. $("#hid_remove_upload_id").val(s_id);
  73. document.getElementById("frm_remove_upload").submit();
  74. }// end of confirmation check
  75. });// end of click event on .a_remove_upload inside tbl_uploads
  76. do_alert("waiting...");
  77. } catch(e) {
  78. var s_err = String(e.name) + "\nmessage:" + String(e.message);
  79. s_err = (typeof(e.lineNumber)!="undefined") ? s_err + "\nline:" + String(e.lineNumber) : s_err;
  80. alert("Error! " + s_err);
  81. }//end of catch
  82. });// end of additional document ready
  83. </script>
  84. <form action="{{ url_for("main.uploads", i_record=record_id) }}" method="post" id="frm_remove_upload">
  85. {{ remove_upload_form.csrf_token }}
  86. {{remove_upload_form.hid_remove_upload_id }}
  87. </form>
  88. {% endblock %}