qualifications.html 9.4 KB

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