Sin descripción

transformativeAction.blade.php 29KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  1. @extends('layouts.master')
  2. @section('navigation')
  3. @if($role==2)
  4. @include('local.managers.sCoords._navigation')
  5. @elseif($role==3)
  6. @include('local.managers.pCoords._navigation')
  7. @else
  8. @include('local.professors._navigation')
  9. @endif
  10. @stop
  11. @section('main')
  12. <div class="row">
  13. <div class="col-md-6">
  14. <!-- Form to add a new criterion -->
  15. <div class="panel panel-default panel-button">
  16. <div class="panel-heading">
  17. Create a TA
  18. </div>
  19. <div class="panel-body" id="createPanel">
  20. {{ Form::open(array('action' => 'TransformativeActionsController@createTA')) }}
  21. <div class="form-group">
  22. {{ Form::label('text', 'Name') }}
  23. {{ Form::text('text', '', array('class' => 'form-control')) }}
  24. </div>
  25. <div class="form-group">
  26. {{ Form::label('description', 'Description') }}
  27. {{ Form::textarea('description', '', array('class' => 'form-control')) }}
  28. </div>
  29. <div class="form-group"> </div>
  30. <div class="form-group" id='dummyApproval'>
  31. <label>Availability</label>
  32. <select name="approval" class="form-control">
  33. <option value="1">Recommended</option>
  34. <option value="0">To be implemented</option>
  35. </select>
  36. </div>
  37. <label>Courses being Transformed by the Action</label>
  38. <div class="" id="">
  39. <div class="form-group col-md-11">
  40. <select name="courseid[]" class="form-control createCourses selectpicker">
  41. @foreach ($courses_create as $course)
  42. <option value="{{$course->id}}">{{$course->name}} [{{$course->code}}]</option>
  43. @endforeach
  44. </select>
  45. </div>
  46. <button type="button" class='btn btn-md btn-primary col-md-1 remove-course'>
  47. X
  48. </button>
  49. </div>
  50. <button type="button" class='btn btn-md btn-secondary add-course'>
  51. <span class='glyphicon glyphicon-plus'>
  52. </span>
  53. Add another Course
  54. </button>
  55. <div class="form-group"> </div>
  56. <div class="form-group" id='createOutcome'>
  57. <label>Outcome perteneciente</label>
  58. <select name="outcome" class="form-control selectpicker">
  59. @foreach ($outcomes as $outcome)
  60. <option value="{{$outcome->id}}">{{$outcome->name}}</option>
  61. @endforeach
  62. </select>
  63. </div>
  64. <label>Associated Objectives</label>
  65. <div class="" id="">
  66. <div class="form-group col-md-11">
  67. <select name="objectiveid[]" class="form-control createObjectives">
  68. <option value="">First, select an Outcome</option>
  69. </select>
  70. </div>
  71. <button type="button" class='btn btn-md btn-primary col-md-1 remove-objective'>
  72. X
  73. </button>
  74. </div>
  75. <button type="button" class='btn btn-md btn-secondary add-objective'>
  76. <span class='glyphicon glyphicon-plus'>
  77. </span>
  78. Add another Objective
  79. </button>
  80. <div class="form-group"> </div>
  81. {{ Form::submit('Create', array('class' => 'btn btn-primary btn-block')) }}
  82. {{ Form::close() }}
  83. </div>
  84. </div>
  85. <div class="panel panel-default panel-button">
  86. <div class="panel-heading">
  87. Approve a Recommended TA
  88. </div>
  89. <div class="panel-body" id="approvePanel">
  90. <div class="">
  91. <button class="btn btn-md btn-secondary filterButton">
  92. <span class="glyphicon glyphicon-plus">
  93. </span>
  94. Filters
  95. </button>
  96. </div>
  97. <div class="filterSection">
  98. <br>
  99. <div class="">
  100. <div class="">
  101. <label>Professor that created the TA</label>
  102. <select class="form-control filterProfessor selectpicker">
  103. <option value="0">Show All</option>
  104. @foreach ($professor_filter_approvePanel as $ta)
  105. <option value="{{$ta->id}}">Prof. {{$ta->first_name}} {{$ta->surnames}}</option>
  106. @endforeach
  107. </select>
  108. </div>
  109. <br>
  110. <div class="">
  111. <label>Course evaluated by an Objective of the TA</label>
  112. <select class="form-control filterCourse selectpicker">
  113. <option value="0">Show All</option>
  114. @foreach ($course_filter_approvePanel as $course)
  115. <option value="{{$course->id}}">{{$course->name}}[{{$course->code}}]</option>
  116. @endforeach
  117. </select>
  118. </div>
  119. <br>
  120. <div class="">
  121. <label>Outcome of the TA</label>
  122. <select class="form-control filterOutcome selectpicker">
  123. <option value="0">Show All</option>
  124. @foreach ($outcome_filter_approvePanel as $outcome)
  125. <option value="{{$outcome->id}}">{{$outcome->name}}</option>
  126. @endforeach
  127. </select>
  128. </div>
  129. </div>
  130. </div>
  131. <hr>
  132. {{ Form::open(array('action' => 'TransformativeActionsController@approveTA')) }}
  133. <div>
  134. <div class="form-group col-md-11">
  135. <label>Select Transformative Action</label>
  136. <select name="ta" class="form-control SelectTA selectpicker" id='approvalSelectTA'>
  137. @if (count($ta_approval_panel) == 0)
  138. <option value="0">No TAs available</option>
  139. @else
  140. @endif
  141. @foreach ($ta_approval_panel as $ta)
  142. <option value="{{$ta->id}}">{{$ta->at_text}}</option>
  143. @endforeach
  144. </select>
  145. </div>
  146. </div>
  147. <div class="form-group">
  148. {{ Form::label('approvalDescription', 'Description') }}
  149. {{ Form::textarea('approvalDescription', '', array('class' => 'form-control')) }}
  150. </div>
  151. <label>Associated Courses</label>
  152. <div class="approveCourses">
  153. <div class="form-group col-md-11 approveCourse">
  154. <select name="courseid[]" class="form-control selectpicker">
  155. <option value="">option</option>
  156. </select>
  157. </div>
  158. <button type="button" class='btn btn-md btn-primary col-md-1 remove-course'>
  159. X
  160. </button>
  161. </div>
  162. <button type="button" class='btn btn-md btn-secondary add-course'>
  163. <span class='glyphicon glyphicon-plus'>
  164. </span>
  165. Add another Course
  166. </button>
  167. <label>Associated Objectives</label>
  168. <div class="approveObjectives">
  169. <div class="form-group col-md-11">
  170. <select name="objectiveid[]" class="form-control">
  171. @foreach ($objectives as $id => $text)
  172. <option value="{{$id}}">{{$text}}</option>
  173. @endforeach
  174. </select>
  175. </div>
  176. <button type="button" class='btn btn-md btn-primary col-md-1 remove-objective'>
  177. X
  178. </button>
  179. </div>
  180. <button type="button" class='btn btn-md btn-secondary add-objective'>
  181. <span class='glyphicon glyphicon-plus'>
  182. </span>
  183. Add another Objective
  184. </button>
  185. <input type='hidden' name='at_text' class="approvalText">
  186. <input type='hidden' name='ta_id' class='updateTA'>
  187. {{ Form::submit('Approve', array('class' => 'btn btn-primary btn-block')) }}
  188. {{ Form::close() }}
  189. </div>
  190. </div>
  191. </div>
  192. <div class="col-md-6">
  193. <div class="panel panel-default panel-button">
  194. <div class="panel-heading">
  195. Edit a TA
  196. </div>
  197. <div class="panel-body" id="editPanel">
  198. <div class="">
  199. <button class="btn btn-md btn-secondary filterButton">
  200. <span class="glyphicon glyphicon-plus">
  201. </span>
  202. Filters
  203. </button>
  204. </div>
  205. <div class="filterSection">
  206. <br>
  207. <div class="">
  208. <div class="">
  209. <label>Professor that created the TA</label>
  210. <select class="form-control filterProfessor selectpicker">
  211. <option value="0">Show All</option>
  212. @foreach ($professor_filter_editPanel as $user)
  213. <option value="{{$user->id}}">Prof. {{$user->first_name}} {{$user->surnames}}</option>
  214. @endforeach
  215. </select>
  216. </div>
  217. <br>
  218. <div class="">
  219. <label>Course evaluated by an Objective of the TA</label>
  220. <select class="form-control filterCourse selectpicker">
  221. <option value="0">Show All</option>
  222. @foreach ($course_filter_editPanel as $course)
  223. <option value="{{$course->id}}">{{$course->name}}[{{$course->code}}]</option>
  224. @endforeach
  225. </select>
  226. </div>
  227. <br>
  228. <div class="">
  229. <label>Outcome of the TA</label>
  230. <select class="form-control filterOutcome selectpicker">
  231. <option value="0">Show All</option>
  232. @foreach ($outcome_filter_editPanel as $outcome)
  233. <option value="{{$outcome->id}}">{{$outcome->name}}</option>
  234. @endforeach
  235. </select>
  236. </div>
  237. </div>
  238. </div>
  239. <hr>
  240. {{ Form::open(array('action' => 'TransformativeActionsController@updateTA')) }}
  241. <div>
  242. <div class="form-group col-md-12">
  243. <label>Select Transformative Action</label>
  244. <select name="ta" class="form-control SelectTA selectpicker" id='editSelectTA'>
  245. @if (count($ta_edit_panel) == 0)
  246. <option value="0">No TAs available</option>
  247. @else
  248. @endif
  249. @foreach ($ta_edit_panel as $ta)
  250. <option value="{{$ta->id}}">{{$ta->at_text}}</option>
  251. @endforeach
  252. </select>
  253. </div>
  254. </div>
  255. <div class="form-group" id="editName">
  256. {{ Form::label('text', 'Name') }}
  257. {{ Form::text('text', '', array('class' => 'form-control')) }}
  258. </div>
  259. <input type='hidden' name='ta_id' class='updateTA' value="0">
  260. <div class="form-group">
  261. {{ Form::label('description', 'Description') }}
  262. {{ Form::textarea('description', '', array('class' => 'form-control')) }}
  263. </div>
  264. <div class="form-group"> </div>
  265. <div class="form-group" id='editApproval'>
  266. <label>Availability</label>
  267. <select name="approval" class="form-control selectpicker">
  268. <option value="1">Recommended</option>
  269. <option value="0">To be implemented</option>
  270. </select>
  271. </div>
  272. <label>Associated Courses</label>
  273. <div class="editCourses">
  274. <div class="form-group col-md-11 editCourse">
  275. <select name="courseid[]" class="form-control selectpicker">
  276. @foreach ($courses_create as $course)
  277. <option value="{{$course->id}}">{{$course->name}}[{{$course->code}}]</option>
  278. @endforeach
  279. </select>
  280. </div>
  281. <button type="button" class='btn btn-md btn-primary col-md-1 remove-course'>
  282. X
  283. </button>
  284. </div>
  285. <button type="button" class='btn btn-md btn-secondary add-course'>
  286. <span class='glyphicon glyphicon-plus'>
  287. </span>
  288. Add another Course
  289. </button>
  290. <div class="form-group"> </div>
  291. <label>Associated Objectives</label>
  292. <div class="editObjectives">
  293. <div class="form-group col-md-11">
  294. {{-- <select class="form-control selectpicker"> --}}
  295. <select name="objectiveid[]" class="form-control">
  296. @foreach ($objectives as $id => $text)
  297. <option value="{{$id}}">{{$text}}</option>
  298. @endforeach
  299. </select>
  300. </div>
  301. <button type="button" class='btn btn-md btn-primary col-md-1 remove-objective'>
  302. X
  303. </button>
  304. </div>
  305. <button type="button" class='btn btn-md btn-secondary add-objective'>
  306. <span class='glyphicon glyphicon-plus'>
  307. </span>
  308. Add another Objective
  309. </button>
  310. <div class="form-group"> </div>
  311. {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
  312. {{ Form::close() }}
  313. {{ Form::open(array('action' => 'TransformativeActionsController@deleteTA')) }}
  314. <input type='hidden' name='ta_id' id='deleteTA'>
  315. {{Form::submit("Delete", array('class'=> 'btn btn-primary btn-block', 'id'=>"DeleteButton"))}}
  316. </div>
  317. </div>
  318. </div>
  319. </div>
  320. @stop
  321. @section('javascript')
  322. // --------------------------------------------------------------------------
  323. // Page load
  324. // --------------------------------------------------------------------------
  325. // Hide accordion panel contents by default
  326. $('.panel-group .panel-body').hide();
  327. $('#outcome-display').parent().hide();
  328. $('.remove-objective').hide();
  329. $('.remove-course').hide();
  330. ////createPanel
  331. // remove TA approval section if the user isnt a program coordinator
  332. var dummyApproval = $('#dummyApproval');
  333. dummyApproval.find('select').prop('disabled', 'disabled');
  334. dummyApproval.find('option').remove();
  335. var role = {{Auth::user()['role']}};
  336. if (role == 3){
  337. dummyApproval.find('select').append('<option value="0">To be implemented</option>');
  338. $('#approvePanel .add-course').hide();
  339. } else if (role == 4){
  340. dummyApproval.find('select').append('<option value="1">Recommended</option>');
  341. $('#approvePanel').parent().hide();
  342. //hide the select for changin Availability
  343. $('#editApproval').find('select').prop('disabled', 'disabled');
  344. //add an input since disabled the form wont recognize it
  345. $('#editApproval').append('<input type="text" name="approval" value="1" hidden />')
  346. // in edit panel, hide the professor filter
  347. $('.filterProfessor').parent().hide();
  348. $('.filterProfessor').parent().next().hide(); // hide <br>
  349. }
  350. $('.createObjectives').prop('disabled', 'disabled');
  351. $('#createPanel .add-objective').prop('disabled', 'disabled');
  352. ////editPanel
  353. // disable the buttons of the edit section if there are no TA for selection
  354. if(($('#editSelectTA').val() === "")){
  355. $('#editPanel').find('select').prop('disabled', 'disabled');
  356. $('#editPanel').find('button').prop('disabled', 'disabled');
  357. $('#editPanel').find('input').prop('disabled', 'disabled');
  358. }else{
  359. var ta_id = $('#editSelectTA').val();
  360. if(ta_id != 0){
  361. load_ta_info_for_edit(ta_id);
  362. }
  363. }
  364. ////approvePanel
  365. $('#approvePanel .add-objective').hide();
  366. // disable the buttons of the approval section if there are no TA for selection
  367. if(($('#approvalSelectTA').val() === "")){
  368. $('#approvePanel').find('select').prop('disabled', 'disabled');
  369. $('#approvePanel').find('button').prop('disabled', 'disabled');
  370. $('#approvePanel').find('input').prop('disabled', 'disabled');
  371. $('#approvalDescription').prop('disabled', 'disabled');
  372. }else{
  373. var ta_id = $('#approvalSelectTA').val();
  374. if(ta_id != 0){
  375. load_ta_info_for_approval(ta_id);
  376. }
  377. }
  378. //
  379. $('.filterSection').hide();
  380. // --------------------------------------------------------------------------
  381. // Functions
  382. // --------------------------------------------------------------------------
  383. function load_objectives_from_outcome(outcome_id) {
  384. $.post(
  385. "{{ URL::action('TransformativeActionsController@objectivesFromOutcome') }}",
  386. {
  387. outcome_id: (outcome_id),
  388. },
  389. function(data)
  390. {
  391. var panel = $('#createPanel');
  392. //
  393. var objectives = data.objectives;
  394. //delete al current select
  395. panel.find('.remove-objective').parent().remove();
  396. //create select
  397. var new_div = $('<div/>',{
  398. 'class': 'createObjectives'
  399. });
  400. var new_inner_div = $('<div/>',{
  401. 'class': 'form-group col-md-11'
  402. });
  403. var new_select = $('<select/>',{
  404. 'class': 'form-control createObjectives selectpicker',
  405. 'data-live-search': 'true',
  406. 'name': 'objectiveid[]'
  407. });
  408. var new_button = $('<button/>',{
  409. 'class': 'btn btn-md btn-primary col-md-1 remove-objective',
  410. 'type': 'button',
  411. 'html': 'X'
  412. });
  413. new_button.hide();
  414. $.each(objectives, function(index, objective)
  415. {
  416. new_select.append('<option value="'+ objective.id +'">'+ objective.text +'</option>');
  417. });
  418. panel.find('.add-objective').before(new_div);
  419. new_div.append(new_button);
  420. new_div.append(new_inner_div);
  421. new_inner_div.append(new_select);
  422. new_select.selectpicker('refresh');
  423. //activate the button for adding more objectives
  424. $('#createPanel .add-objective').prop('disabled', false);
  425. }
  426. );
  427. }
  428. function load_ta_info_for_edit(ta_id) {
  429. $.post(
  430. "{{ URL::action('TransformativeActionsController@selectTA') }}",
  431. {
  432. ta_id: (ta_id),
  433. },
  434. function(data)
  435. {
  436. //
  437. var selected_courses = data.selected_courses;
  438. var objectives = data.objectives;
  439. var objectives_from_outcome = data.objectives_from_outcome;
  440. var status = data.status;
  441. var name = data.name[0];
  442. var description = data.description[0];
  443. var can_be_deleted = data.can_be_deleted;
  444. //add objectives button
  445. var add_button = $('#editPanel .add-objective');
  446. //set if the TA is approved or not
  447. $('#editApproval select').val(status);
  448. //delete objectives select
  449. $('.editObjectives').remove();
  450. //create one objective select and populate it
  451. var panel = $('#editPanel');
  452. //
  453. var objectives = data.objectives;
  454. //delete al current select
  455. panel.find('.remove-objective').parent().remove();
  456. //create select
  457. var new_div = $('<div/>',{
  458. 'class': 'editObjectives'
  459. });
  460. var new_inner_div = $('<div/>',{
  461. 'class': 'form-group col-md-11'
  462. });
  463. var new_select = $('<select/>',{
  464. 'class': 'form-control editObjectives selectpicker',
  465. 'data-live-search': 'true',
  466. 'name': 'objectiveid[]'
  467. });
  468. var new_button = $('<button/>',{
  469. 'class': 'btn btn-md btn-primary col-md-1 remove-objective',
  470. 'type': 'button',
  471. 'html': 'X'
  472. });
  473. new_button.hide();
  474. $.each(objectives_from_outcome, function(index, objective)
  475. {
  476. new_select.append('<option value="'+ objective.id +'">'+ objective.text +'</option>');
  477. });
  478. panel.find('.add-objective').before(new_div);
  479. new_div.append(new_button);
  480. new_div.append(new_inner_div);
  481. new_inner_div.append(new_select);
  482. new_select.selectpicker('refresh');
  483. //change de value of the select
  484. //add the other selects
  485. var prev_select = new_div;
  486. $.each(objectives, function(index, objective)
  487. {
  488. prev_select.find('select').val(objective.id);
  489. add_objective_select(add_button);
  490. {{-- add_button; --}}
  491. prev_select = add_button.prev();
  492. });
  493. add_button.prev().remove();
  494. //set the text box
  495. $('#editName').find('input').val(name);
  496. $('#editPanel #description').val(description);
  497. //
  498. $('#deleteTA').val(ta_id);
  499. $('#editPanel .updateTA').val(ta_id);
  500. if(can_be_deleted == false){
  501. $('#DeleteButton').prop('disabled', 'disabled');
  502. }else{
  503. $('#DeleteButton').prop('disabled', false);
  504. }
  505. //locate de "add course" button on edit panel
  506. var add_course_button = $('#editPanel .add-course')
  507. //save current course selectpickers, add a new one, and delete old ones
  508. var current_course_selects = $('#editPanel .editCourse');
  509. add_course_button.click();
  510. current_course_selects.remove();
  511. //populate edit panel with courses previusly selected
  512. var prev_select = add_course_button.prev();
  513. prev_select.find('.remove-course').hide();
  514. $.each(selected_courses, function(index, course)
  515. {
  516. prev_select.find('select').val(course.id);
  517. add_course_button.click();
  518. prev_select = add_course_button.prev();
  519. });
  520. prev_select.remove();
  521. }
  522. );
  523. }
  524. function load_ta_info_for_approval(ta_id) {
  525. $.post(
  526. "{{ URL::action('TransformativeActionsController@selectTA') }}",
  527. {
  528. ta_id: (ta_id),
  529. },
  530. function(data)
  531. {
  532. //
  533. var selected_courses = data.selected_courses;
  534. var objectives = data.objectives;
  535. var status = data.status[0];
  536. var name = data.name[0];
  537. var description = data.description[0];
  538. //clear the objectives of ony prevoius TA selected for approve
  539. var add_button = $('#approvePanel .add-objective');
  540. var select = add_button.prev().clone(true);
  541. var first_select = select.clone(true);
  542. first_select.find('button').hide();
  543. $('.approveObjectives').remove();
  544. add_button.before(first_select);
  545. var prev_select = first_select;
  546. $.each(objectives, function(index, objective)
  547. {
  548. // save the new select in a var
  549. var new_select = select.clone(true);
  550. // set only one option on the select
  551. prev_select.find('option').remove();
  552. prev_select.find('select').append('<option value="'+ objective.id +'">'+objective.text +'</option>');
  553. prev_select = new_select;
  554. // add the copy of the select
  555. add_button.before(new_select);
  556. });
  557. // remove the last objective select, since it isnt one of the saved objectives
  558. add_button.prev().remove();
  559. //
  560. $('#approvalDescription').val(description);
  561. $('.approvalText').val(name);
  562. $('#approvePanel .updateTA').val(ta_id);
  563. //locate de "add course" button on approve panel
  564. var add_course_button = $('#approvePanel .add-course')
  565. //save current course selectpickers, add a new one, and delete old ones
  566. var current_course_selects = $('#approvePanel .approveCourse');
  567. add_course_button.click();
  568. current_course_selects.remove();
  569. //populate approve panel with courses previusly selected
  570. var prev_select = add_course_button.prev();
  571. prev_select.find('.remove-course').hide();
  572. $.each(selected_courses, function(index, course)
  573. {
  574. var new_option = $('<option/>',{
  575. 'value': course.id,
  576. 'type': 'button',
  577. 'html': course.name+' ['+course.code+']'
  578. });
  579. prev_select.find('select option').remove();
  580. prev_select.find('select').append(new_option);
  581. prev_select.find('.remove-course').hide();
  582. add_course_button.click();
  583. prev_select = add_course_button.prev();
  584. });
  585. prev_select.remove();
  586. }
  587. );
  588. }
  589. function add_objective_select(element) {
  590. var prev_select = $(element).prev();
  591. var parent_panel = $(element).parent().parent().attr('id');
  592. var select_class = '';
  593. if(parent_panel == 'editPanel'){
  594. select_class = 'editObjectives';
  595. }else{
  596. select_class = 'createObjectives';
  597. }
  598. //create select
  599. var new_div = $('<div/>',{
  600. 'class': select_class
  601. });
  602. var new_inner_div = $('<div/>',{
  603. 'class': 'form-group col-md-11'
  604. });
  605. var new_select = $('<select/>',{
  606. 'class': 'form-control createObjectives selectpicker',
  607. 'data-live-search': 'true',
  608. 'name': 'objectiveid[]'
  609. });
  610. var new_button = $('<button/>',{
  611. 'class': 'btn btn-md btn-primary col-md-1 remove-objective',
  612. 'type': 'button',
  613. 'html': 'X'
  614. });
  615. $.each(prev_select.find('option'), function(index, option)
  616. {
  617. var new_option = $('<option/>',{
  618. 'value': $(option).val(),
  619. 'html': $(option).html()
  620. });
  621. new_select.append(new_option);
  622. });
  623. $(element).before(new_div);
  624. new_div.append(new_inner_div);
  625. new_div.append(new_button);
  626. new_inner_div.append(new_select);
  627. $(element).parent().find('.selectpicker').selectpicker('refresh');
  628. new_select.selectpicker('refresh');
  629. }
  630. function add_course_select(element) {
  631. var prev_select = $(element).prev();
  632. var parent_panel = $(element).parent().parent().attr('id');
  633. var select_class = '';
  634. if(parent_panel == 'editPanel'){
  635. select_class = 'editCourse';
  636. }else{
  637. select_class = 'createCourse';
  638. }
  639. //create select
  640. var new_div = $('<div/>',{
  641. 'class': select_class+' approveCourse'
  642. });
  643. var new_inner_div = $('<div/>',{
  644. 'class': 'form-group col-md-11'
  645. });
  646. var new_select = $('<select/>',{
  647. 'class': 'form-control createCourses selectpicker',
  648. 'data-live-search': 'true',
  649. 'name': 'courseid[]'
  650. });
  651. var new_button = $('<button/>',{
  652. 'class': 'btn btn-md btn-primary col-md-1 remove-course',
  653. 'type': 'button',
  654. 'html': 'X'
  655. });
  656. $.each(prev_select.find('option'), function(index, option)
  657. {
  658. var new_option = $('<option/>',{
  659. 'value': $(option).val(),
  660. 'html': $(option).html()
  661. });
  662. new_select.append(new_option);
  663. });
  664. $(element).before(new_div);
  665. new_div.append(new_inner_div);
  666. new_div.append(new_button);
  667. new_inner_div.append(new_select);
  668. $(element).parent().find('.selectpicker').selectpicker('refresh');
  669. new_select.selectpicker('refresh');
  670. }
  671. // --------------------------------------------------------------------------
  672. // Events
  673. // --------------------------------------------------------------------------
  674. // When a TA is selected for edit, load the TA info
  675. $('#createOutcome').on('change', function()
  676. {
  677. var outcome_id = $(this).find('select').val();
  678. load_objectives_from_outcome(outcome_id);
  679. });
  680. // When a TA is selected for edit, load the TA info
  681. $('#editSelectTA').parent().on('change', function()
  682. {
  683. var ta_id = $(this).find('select').val();
  684. if(ta_id != 0){
  685. load_ta_info_for_edit(ta_id);
  686. }
  687. });
  688. // When a TA is selected for approval, load the TA info
  689. $('#approvalSelectTA').parent().on('change', function()
  690. {
  691. var ta_id = $(this).find('select').val();
  692. if(ta_id != 0){
  693. load_ta_info_for_approval(ta_id);
  694. }
  695. });
  696. // Add an objective Select picker
  697. $('.add-objective').on('click', function()
  698. {
  699. add_objective_select(this);
  700. });
  701. // Add an course Select picker
  702. $('.add-course').on('click', function()
  703. {
  704. add_course_select(this);
  705. });
  706. // Remove an objective Select picker
  707. $('.panel').on('click', '.remove-objective', function()
  708. {
  709. $(this).parent().remove();
  710. });
  711. // Remove an course Select picker
  712. $('.panel').on('click', '.remove-course', function()
  713. {
  714. $(this).parent().remove();
  715. });
  716. // Remove an objective Select picker
  717. $('.filterButton').on('click', function()
  718. {
  719. var span = $(this).find('span');
  720. if(span.attr('class') == 'glyphicon glyphicon-plus'){
  721. span.attr('class','glyphicon glyphicon-minus');
  722. } else{
  723. span.attr('class','glyphicon glyphicon-plus');
  724. }
  725. $(this).parent().next().toggle(533);
  726. });
  727. //
  728. $('.filterSection').on('change', function()
  729. {
  730. var professor_id = $(this).find('.filterProfessor select').val();
  731. var course_id = $(this).find('.filterCourse select').val();
  732. var outcome_id = $(this).find('.filterOutcome select').val();
  733. var panel_id = $(this).parent().attr('id');
  734. var select = $('#'+panel_id+' .SelectTA select');
  735. $.post(
  736. "{{ URL::action('TransformativeActionsController@filterTA') }}",
  737. {
  738. professor_id: (professor_id),
  739. course_id: (course_id),
  740. outcome_id: (outcome_id),
  741. panel_id: (panel_id),
  742. },
  743. function(data)
  744. {
  745. //
  746. select.find('option').remove();
  747. $.each(data, function(index, ta)
  748. {
  749. var ta_id = ta.id;
  750. var ta_text = ta.at_text;
  751. var new_option = '<option value="'+ ta_id +'">'+ ta_text +'</option>';
  752. select.append(new_option);
  753. });
  754. select.selectpicker('refresh');
  755. if(data.length != 0){
  756. var ta_id = data[0].id;
  757. if(panel_id=='editPanel'){
  758. load_ta_info_for_edit(ta_id);
  759. }
  760. if(panel_id=='approvePanel'){
  761. load_ta_info_for_approval(ta_id);
  762. }
  763. }
  764. }
  765. );
  766. });
  767. @stop