qualifications.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 %}
  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><input type="button" id="btn_type_filter" value="Apply filter">
  45. </div>
  46. <div class="table-container">
  47. <table id="tbl_qualifications" class="data-table">
  48. <thead>
  49. <tr>
  50. <th>Qualification type</th><th>Qualification Name</th><th>Qualification Description</th><th style="font-size: smaller;">(actions)</th>
  51. </tr>
  52. </thead>
  53. <tbody></tbody>
  54. </table><!-- end of tbl_qualifications -->
  55. </div><!-- end of div.table-container -->
  56. </div><!-- end of div_qualifications -->
  57. </article>
  58. </div><!-- end of div.content -->
  59. {% from "macros/dialog.html" import dlg_prep with context %}
  60. {{ dlg_prep(["dlg_type", "dlg_qualification"]) }}
  61. {# dlg divs below #}
  62. <div id="dlg_type" aria-labeledby="spn_type">
  63. <span id="spn_type">Qualification type</span><br>
  64. <form action="{{ url_for("main.qualifications") }}" method="post" id="frm_type">
  65. {{ type_form.csrf_token }}
  66. {{ type_form.hid_qualification_type_id }}
  67. {{ type_form.txt_qualification_type.label}}{{ type_form.txt_qualification_type }}<br>
  68. <input type="submit" name="btn_save_type" value="Save">
  69. </form>
  70. </div><!-- end of dlg_type -->
  71. <div id="dlg_qualification" aria-labeledby="spn_qualification">
  72. <span id="spn_qualification">Qualification details</span><br>
  73. <form action="{{ url_for("main.qualifications") }}" method="post" id="frm_qualification">
  74. {{ form.csrf_token }}
  75. {{ form.hid_qualification_id }}
  76. <ul>
  77. <li>{{ form.sel_qualification_type.label }}{{ form.sel_qualification_type }}<br></li>
  78. <li>{{ form.txt_qualification_name.label }}{{ form.txt_qualification_name }}</li>
  79. <li>{{ form.txt_description.label }}<br>
  80. {{ form.txt_description }}</li>
  81. </ul>
  82. <input type="submit" name="btn_save_qualification" value="Save">
  83. </form>
  84. </div><!-- end of dlg_qualification -->
  85. <script type="text/javascript">
  86. $(document).ready( function() {
  87. try {
  88. var s_dlg_type = $("#dlg_type").html();
  89. var s_dlg_qualification = $("#dlg_qualification").html();
  90. $("#a_add_type").click( function(event) {
  91. event.preventDefault();
  92. $("#dlg_type").html(s_dlg_type);
  93. $("#dlg_type").redraw();
  94. $("#dlg_type").dialog("open");
  95. });// end of a_add_type click event
  96. $(".a_edit_type").click( function(event) {
  97. event.preventDefault();
  98. var s_id = String($(this).attr("href")).replace("#", "");
  99. var s_type = $($($($(this).parent()).parent()).children("td")[0]).text();
  100. $("#dlg_type").html(s_dlg_type);
  101. $("#dlg_type").redraw();
  102. $("#hid_qualification_type_id").val(s_id);
  103. $("#txt_qualification_type").val(s_type);
  104. $("#dlg_type").redraw();
  105. $("#dlg_type").dialog("open");
  106. });// end of .a_edit_type click event
  107. $(".a_remove_type").click( function(event) {
  108. event.preventDefault();
  109. var s_id = String($(this).attr("href")).replace("#", "");
  110. 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?");
  111. if (bl_confirm) {
  112. $("#hid_remove_qualification_type_id").val(s_id);
  113. document.getElementById("frm_remove_type").submit();
  114. }// end of checking confirmation
  115. });// end of .a_remove_type click event
  116. function filter_qualifications(s_type_id) {
  117. try {
  118. var i_type_id = Number(s_type_id);
  119. if (isNaN(i_type_id)!=true) {
  120. s_type_id = String(i_type_id);
  121. var s_url = "{{ url_for("main.qualifications_list", i_type_id=99999) }}".replace("99999", s_type_id);
  122. $.get(s_url, function(o_data) {
  123. if (typeof(o_data)=="object") {
  124. var s_html = "";
  125. $("#tbl_qualifications tbody").empty();
  126. if (o_data.length>0) {
  127. $.each(o_data, function(ix, q) {
  128. // v_qualification_type, v_qualification_name, v_description, id
  129. s_html = s_html + "<tr><td>" + q.v_qualification_type + "</td><td>" + q.v_qualification_name + "</td><td>" + q.v_description + "</td>";
  130. 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>";
  131. });// end of .each loop through qualifications
  132. $("#tbl_qualifications tbody").append(s_html);
  133. $("#tbl_qualifications").show();
  134. do_alert("Qualifications matching this type loaded");
  135. } else {
  136. $("#tbl_qualifications").hide();
  137. var s_extra = (i_type_id==0) ? "" : " matching this type";
  138. do_alert("No qualifications" + s_extra);
  139. }// end of length check against o_data
  140. }// end of typeof check
  141. });// end of .get
  142. }// end of making sure valid numeric value passed
  143. } catch(e) {
  144. var s_err = String(e.name) + "\nmessage:" + String(e.message);
  145. s_err = (typeof(e.lineNumber)!="undefined") ? s_err + "\nline:" + String(e.lineNumber) : s_err;
  146. alert("Error! " + s_err);
  147. }//end of catch
  148. }// end of filter_qualifications function
  149. var s_type_filter = "0";
  150. {% if type_filter>0 %}
  151. s_type_filter = String("{{ type_filter }}");
  152. {% endif %}
  153. var bl_wait = true;
  154. $($("#sel_type_filter").children("option[value='" + s_type_filter + "']")[0]).prop("selected", true);
  155. filter_qualifications(s_type_filter);
  156. $("#btn_type_filter").click( function(event) {
  157. try {
  158. if (bl_wait!=true) {
  159. var s_type_id = String($("#sel_type_filter").val());
  160. filter_qualifications(s_type_id);
  161. }// end of checking if should wait
  162. bl_wait = false;
  163. } catch(e) {
  164. var s_err = String(e.name) + "\nmessage:" + String(e.message);
  165. s_err = (typeof(e.lineNumber)!="undefined") ? s_err + "\nline:" + String(e.lineNumber) : s_err;
  166. alert("Error! " + s_err);
  167. }//end of catch
  168. });// end of btn_type_filter click|sel_type_filter change event
  169. $("#a_add_qualification").click( function(event) {
  170. event.preventDefault();
  171. $("#dlg_qualification").html(s_dlg_qualification);
  172. $("#dlg_qualification").redraw();
  173. $("#dlg_qualification").dialog("open");
  174. });// end of a_add_qualification click event
  175. $("#tbl_qualifications").on("click", ".a_edit_qualification", function(event) {
  176. event.preventDefault();
  177. var s_id = String($(this).attr("href")).replace("#", "");
  178. $("#dlg_qualification").html(s_dlg_qualification);
  179. $("#dlg_qualification").redraw();
  180. var s_url = "{{ url_for("main.qualification_details", i_qualification_id=99999) }}".replace("99999", s_id);
  181. $.get(s_url, function(o_data) {
  182. if (typeof(o_data)=="object") {
  183. $("#hid_qualification_id").val(s_id);
  184. $("#sel_qualification_type").val(o_data.i_qualification_type);
  185. $("#txt_qualification_name").val(o_data.v_qualification_name);
  186. $("#txt_description").val(o_data.v_description);
  187. $("#dlg_qualification").redraw();
  188. $("#dlg_qualification").dialog("open");
  189. }// end of typeof check
  190. });// end of .get
  191. });// end of .a_edit_qualification inside tbl_qualifications click event
  192. $("#tbl_qualifications").on("click", ".a_remove_qualification", function(event) {
  193. event.preventDefault();
  194. var s_id = String($(this).attr("href")).replace("#", "");
  195. 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?");
  196. if (bl_confirm) {
  197. $("#hid_remove_qualification_id").val(s_id);
  198. document.getElementById("frm_remove_qualification").submit();
  199. }// end of checking confirmation
  200. });// end of .a_remove_qualification inside tbl_qualifications click event
  201. } catch(e) {
  202. var s_err = String(e.name) + "\nmessage:" + String(e.message);
  203. s_err = (typeof(e.lineNumber)!="undefined") ? s_err + "\nline:" + String(e.lineNumber) : s_err;
  204. alert("Error! " + s_err);
  205. }//end of catch
  206. });// end of secondary document ready
  207. </script>
  208. <form action="{{ url_for("main.qualifications") }}" method="post" id="frm_remove_type">
  209. {{ remove_type_form.csrf_token }}
  210. {{ remove_type_form.hid_remove_qualification_type_id}}
  211. </form>
  212. <form action="{{ url_for("main.qualifications") }}" method="post" id="frm_remove_qualification">
  213. {{ remove_form.csrf_token }}
  214. {{ remove_form.hid_remove_qualification_id }}
  215. </form>
  216. {% endblock %}