qualifications.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. {% extends base %}
  2. {% block head_extra %}
  3. <style>
  4. #tbl_qualifications {
  5. display: none;
  6. }
  7. </style>
  8. {% endblock head_extra %}
  9. {% block content %}
  10. {% import "macros/action_icons_static.html" as icons with context %}
  11. <span class="title" role="main"><h2>{% block title %}Qualifications{% endblock %}</h2></span>
  12. <div class="content-container content">
  13. <article>
  14. <h3>Qualification Types</h3>
  15. <div><a href="#" id="a_add_type">Add qualification type</a></div>
  16. {% if qualification_types %}
  17. <div class="table-container">
  18. <table id="tbl_types" class="data-table">
  19. <thead>
  20. <tr>
  21. <th>Qualification type</th><th style="font-size: smaller;">(actions)</th>
  22. </tr>
  23. </thead>
  24. <tbody>
  25. {% for type in qualification_types %}
  26. <tr>
  27. <td>{{ type.v_qualification_type }}</td><td><a href="#{{ type.id }}" class="a_edit_type">{{ icons.edit_svg(bl_quotes=False, s_label="edit type") }}</a>&nbsp;<a href= "#{{ type.id }}" class="a_remove_type" >&times;</a></td>
  28. </tr>
  29. {% endfor %}{# end of looping through qualification_types #}
  30. </tbody>
  31. </table><!-- end of tbl_types -->
  32. </div><!-- end of div.table-container -->
  33. {% endif %}{# end of checking if qualification_types populated #}
  34. </article>
  35. <article>
  36. <h3>Qualifications</h3>
  37. <div id="div_qualifications">
  38. <div><a href="#" id="a_add_qualification">Add qualification</a></div>
  39. <div><select id="sel_type_filter">
  40. <option value="0" selected>--all types--</option>
  41. {% for type in qualification_types %}
  42. <option value="{{ type.id }}">{{ type.v_qualification_type }}</option>
  43. {% endfor %}{# end of looping through qualification_types #}
  44. </select>
  45. <button type="button" id="btn_type_filter" value="Apply filter" style="background-color: rgb(39, 37, 92); color: white; border: none; padding: 8px 12px; border-radius: 4px; cursor: pointer;">
  46. {{ icons.search_svg(s_label="apply filter") }}
  47. Apply filter
  48. </button>
  49. </div>
  50. <div class="table-container">
  51. <table id="tbl_qualifications" class="data-table">
  52. <thead>
  53. <tr>
  54. <th>Qualification type</th><th>Qualification Name</th><th>Qualification Description</th><th style="font-size: smaller;">(actions)</th>
  55. </tr>
  56. </thead>
  57. <tbody></tbody>
  58. </table><!-- end of tbl_qualifications -->
  59. </div><!-- end of div.table-container -->
  60. </div><!-- end of div_qualifications -->
  61. </article>
  62. </div><!-- end of div.content -->
  63. {% from "macros/dialog.html" import dlg_prep with context %}
  64. {{ dlg_prep(["dlg_type", "dlg_qualification"]) }}
  65. {# dlg divs below #}
  66. <div id="dlg_type" aria-labeledby="spn_type">
  67. <span id="spn_type">Qualification type</span><br>
  68. <form action="{{ url_for("main.qualifications") }}" method="post" id="frm_type">
  69. {{ type_form.csrf_token }}
  70. {{ type_form.hid_qualification_type_id }}
  71. {{ type_form.txt_qualification_type.label}}{{ type_form.txt_qualification_type }}<br>
  72. <input type="submit" name="btn_save_type" value="Save">
  73. </form>
  74. </div><!-- end of dlg_type -->
  75. <div id="dlg_qualification" aria-labeledby="spn_qualification">
  76. <span id="spn_qualification">Qualification details</span><br>
  77. <form action="{{ url_for("main.qualifications") }}" method="post" id="frm_qualification">
  78. {{ form.csrf_token }}
  79. {{ form.hid_qualification_id }}
  80. <ul>
  81. <li>{{ form.sel_qualification_type.label }}{{ form.sel_qualification_type }}<br></li>
  82. <li>{{ form.txt_qualification_name.label }}{{ form.txt_qualification_name }}</li>
  83. <li>{{ form.txt_description.label }}<br>
  84. {{ form.txt_description }}</li>
  85. </ul>
  86. <input type="submit" name="btn_save_qualification" value="Save">
  87. </form>
  88. </div><!-- end of dlg_qualification -->
  89. <script type="text/javascript">
  90. $(document).ready( function() {
  91. try {
  92. var s_dlg_type = $("#dlg_type").html();
  93. var s_dlg_qualification = $("#dlg_qualification").html();
  94. $("#a_add_type").click( function(event) {
  95. event.preventDefault();
  96. $("#dlg_type").html(s_dlg_type);
  97. $("#dlg_type").redraw();
  98. $("#dlg_type").dialog("open");
  99. });// end of a_add_type click event
  100. $(".a_edit_type").click( function(event) {
  101. event.preventDefault();
  102. var s_id = String($(this).attr("href")).replace("#", "");
  103. var s_type = $($($($(this).parent()).parent()).children("td")[0]).text();
  104. $("#dlg_type").html(s_dlg_type);
  105. $("#dlg_type").redraw();
  106. $("#hid_qualification_type_id").val(s_id);
  107. $("#txt_qualification_type").val(s_type);
  108. $("#dlg_type").redraw();
  109. $("#dlg_type").dialog("open");
  110. });// end of .a_edit_type click event
  111. $(".a_remove_type").click( function(event) {
  112. event.preventDefault();
  113. var s_id = String($(this).attr("href")).replace("#", "");
  114. var bl_confirm = confirm("Are you sure - this will also remove all qualifications under this type, including entries under CV records, but uploaded documents will not be removed?");
  115. if (bl_confirm) {
  116. $("#hid_remove_qualification_type_id").val(s_id);
  117. document.getElementById("frm_remove_type").submit();
  118. }// end of checking confirmation
  119. });// end of .a_remove_type click event
  120. function filter_qualifications(s_type_id) {
  121. try {
  122. var i_type_id = Number(s_type_id);
  123. if (isNaN(i_type_id)!=true) {
  124. s_type_id = String(i_type_id);
  125. var s_url = "{{ url_for("main.qualifications_list", i_type_id=99999) }}".replace("99999", s_type_id);
  126. $.get(s_url, function(o_data) {
  127. if (typeof(o_data)=="object") {
  128. var s_html = "";
  129. $("#tbl_qualifications tbody").empty();
  130. if (o_data.length>0) {
  131. $.each(o_data, function(ix, q) {
  132. // v_qualification_type, v_qualification_name, v_description, id
  133. s_html = s_html + "<tr><td>" + q.v_qualification_type + "</td><td>" + q.v_qualification_name + "</td><td>" + q.v_description + "</td>";
  134. s_html = s_html + "<td><a href=\"#" + q.id + "\" class=\"a_edit_qualification\">{{ icons.edit_svg(bl_quotes=False, s_label="edit qualification") }}</a>&nbsp;<a href=\"#" + q.id + "\" class=\"a_remove_qualification\">{{ icons.delete_svg(bl_quotes=False, s_label="remove qualification") }}</a></td></tr>";
  135. });// end of .each loop through qualifications
  136. $("#tbl_qualifications tbody").append(s_html);
  137. $("#tbl_qualifications").show();
  138. do_alert("Qualifications matching this type loaded");
  139. } else {
  140. $("#tbl_qualifications").hide();
  141. var s_extra = (i_type_id==0) ? "" : " matching this type";
  142. do_alert("No qualifications" + s_extra);
  143. }// end of length check against o_data
  144. }// end of typeof check
  145. });// end of .get
  146. }// end of making sure valid numeric value passed
  147. } catch(e) {
  148. var s_err = String(e.name) + "\nmessage:" + String(e.message);
  149. s_err = (typeof(e.lineNumber)!="undefined") ? s_err + "\nline:" + String(e.lineNumber) : s_err;
  150. alert("Error! " + s_err);
  151. }//end of catch
  152. }// end of filter_qualifications function
  153. var s_type_filter = "0";
  154. {% if type_filter>0 %}
  155. s_type_filter = String("{{ type_filter }}");
  156. {% endif %}
  157. var bl_wait = true;
  158. $($("#sel_type_filter").children("option[value='" + s_type_filter + "']")[0]).prop("selected", true);
  159. filter_qualifications(s_type_filter);
  160. $("#btn_type_filter").click( function(event) {
  161. try {
  162. if (bl_wait!=true) {
  163. var s_type_id = String($("#sel_type_filter").val());
  164. filter_qualifications(s_type_id);
  165. }// end of checking if should wait
  166. bl_wait = false;
  167. } catch(e) {
  168. var s_err = String(e.name) + "\nmessage:" + String(e.message);
  169. s_err = (typeof(e.lineNumber)!="undefined") ? s_err + "\nline:" + String(e.lineNumber) : s_err;
  170. alert("Error! " + s_err);
  171. }//end of catch
  172. });// end of btn_type_filter click|sel_type_filter change event
  173. $("#a_add_qualification").click( function(event) {
  174. event.preventDefault();
  175. $("#dlg_qualification").html(s_dlg_qualification);
  176. $("#dlg_qualification").redraw();
  177. $("#dlg_qualification").dialog("open");
  178. });// end of a_add_qualification click event
  179. $("#tbl_qualifications").on("click", ".a_edit_qualification", function(event) {
  180. event.preventDefault();
  181. var s_id = String($(this).attr("href")).replace("#", "");
  182. $("#dlg_qualification").html(s_dlg_qualification);
  183. $("#dlg_qualification").redraw();
  184. var s_url = "{{ url_for("main.qualification_details", i_qualification_id=99999) }}".replace("99999", s_id);
  185. $.get(s_url, function(o_data) {
  186. if (typeof(o_data)=="object") {
  187. $("#hid_qualification_id").val(s_id);
  188. $("#sel_qualification_type").val(o_data.i_qualification_type);
  189. $("#txt_qualification_name").val(o_data.v_qualification_name);
  190. $("#txt_description").val(o_data.v_description);
  191. $("#dlg_qualification").redraw();
  192. $("#dlg_qualification").dialog("open");
  193. }// end of typeof check
  194. });// end of .get
  195. });// end of .a_edit_qualification inside tbl_qualifications click event
  196. $("#tbl_qualifications").on("click", ".a_remove_qualification", function(event) {
  197. event.preventDefault();
  198. var s_id = String($(this).attr("href")).replace("#", "");
  199. var bl_confirm = confirm("Are you sure - this will also remove all qualifications of this type under CV records, but uploaded documents will not be removed?");
  200. if (bl_confirm) {
  201. $("#hid_remove_qualification_id").val(s_id);
  202. document.getElementById("frm_remove_qualification").submit();
  203. }// end of checking confirmation
  204. });// end of .a_remove_qualification inside tbl_qualifications click event
  205. } catch(e) {
  206. var s_err = String(e.name) + "\nmessage:" + String(e.message);
  207. s_err = (typeof(e.lineNumber)!="undefined") ? s_err + "\nline:" + String(e.lineNumber) : s_err;
  208. alert("Error! " + s_err);
  209. }//end of catch
  210. });// end of secondary document ready
  211. </script>
  212. <form action="{{ url_for("main.qualifications") }}" method="post" id="frm_remove_type">
  213. {{ remove_type_form.csrf_token }}
  214. {{ remove_type_form.hid_remove_qualification_type_id}}
  215. </form>
  216. <form action="{{ url_for("main.qualifications") }}" method="post" id="frm_remove_qualification">
  217. {{ remove_form.csrf_token }}
  218. {{ remove_form.hid_remove_qualification_id }}
  219. </form>
  220. {% endblock %}