qualifications.html 10 KB

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