No Description

transformativeAction.blade.php 32KB

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