|
@@ -63,6 +63,7 @@
|
63
|
63
|
<thead id="theHead">
|
64
|
64
|
<th>Objective</th>
|
65
|
65
|
<th>Program</th>
|
|
66
|
+ <th>Match to Criteria</th>
|
66
|
67
|
</thead>
|
67
|
68
|
<tfoot>
|
68
|
69
|
|
|
@@ -83,6 +84,74 @@
|
83
|
84
|
</div>
|
84
|
85
|
|
85
|
86
|
</div>
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+ <div id="match_criteria" class="modal fade" tabindex="-1" data-objective-id="0">
|
|
91
|
+ <div class="modal-dialog">
|
|
92
|
+ <div class="modal-content">
|
|
93
|
+ <div class="modal-header">
|
|
94
|
+ <h5 class="modal-title" id = 'match_criteria_title'></h5>
|
|
95
|
+ <button type="button" class="close" data-dismiss="modal">×</button>
|
|
96
|
+ </div>
|
|
97
|
+ <div class="modal-body" id = "match_criteria_body">
|
|
98
|
+ <p>The following criteria appear based on objective's programs and your available programs</p>
|
|
99
|
+
|
|
100
|
+ <div class ='form-group col-md-12'>
|
|
101
|
+ <label for="match_criteria_program">Program</label>
|
|
102
|
+ <select id="match_criteria_program" class ='form-control selectpicker select_program' onchange="changeCriteriaDisplayed('#match_criteria_program')">
|
|
103
|
+
|
|
104
|
+ </select>
|
|
105
|
+ </div>
|
|
106
|
+ <hr>
|
|
107
|
+ <label>Criteria associated to program</label>
|
|
108
|
+ <div id="program_objectives" class ='form-group col-md-12' >
|
|
109
|
+
|
|
110
|
+ </div>
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+ </div>
|
|
118
|
+ <div class="modal-footer">
|
|
119
|
+ <hr>
|
|
120
|
+ <button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="">Close</button>
|
|
121
|
+
|
|
122
|
+ </div>
|
|
123
|
+ </div>
|
|
124
|
+ </div>
|
|
125
|
+ </div>
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+ <div id="warning" class="modal fade" tabindex="-1" data-objective-id="0">
|
|
129
|
+ <div class="modal-dialog">
|
|
130
|
+ <div class="modal-content">
|
|
131
|
+ <div class="modal-header">
|
|
132
|
+ <h5 class="modal-title" id = 'warning_title'></h5>
|
|
133
|
+ <button type="button" class="close" data-dismiss="modal">×</button>
|
|
134
|
+ </div>
|
|
135
|
+ <div class="modal-body" id = "warning_body">
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+ </div>
|
|
144
|
+ <div class="modal-footer">
|
|
145
|
+ <hr>
|
|
146
|
+ <button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="$('#match_criteria').data('objective-id', '0');">Cancel</button>
|
|
147
|
+ <button id='warning_delete' type="button" class="btn btn-primary" onclick = ''>Delete</button>
|
|
148
|
+ </div>
|
|
149
|
+ </div>
|
|
150
|
+ </div>
|
|
151
|
+ </div>
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
86
|
155
|
<script>
|
87
|
156
|
$(document).ready(function() {
|
88
|
157
|
// --------------------------------------------------------------------------
|
|
@@ -100,6 +169,8 @@
|
100
|
169
|
/*
|
101
|
170
|
|
102
|
171
|
*/
|
|
172
|
+
|
|
173
|
+
|
103
|
174
|
function fetchObjectives(li) {
|
104
|
175
|
{
|
105
|
176
|
|
|
@@ -130,8 +201,12 @@
|
130
|
201
|
|
131
|
202
|
$.each(json, function(ind2, objective) {
|
132
|
203
|
tr = $("<tr>");
|
133
|
|
- td_text = $("<td>").html(objective.text);
|
134
|
204
|
|
|
205
|
+ //objectives
|
|
206
|
+ td_text = $("<td>",{
|
|
207
|
+ 'id':"objective-"+objective.id
|
|
208
|
+ }).html(objective.text);
|
|
209
|
+ //programs
|
135
|
210
|
td_programs = $("<td>");
|
136
|
211
|
ol = $("<ol>");
|
137
|
212
|
|
|
@@ -140,10 +215,29 @@
|
140
|
215
|
li.appendTo(ol);
|
141
|
216
|
})
|
142
|
217
|
ol.appendTo(td_programs);
|
|
218
|
+
|
|
219
|
+ //link to criteria matching
|
|
220
|
+ link_td = $("<td>");
|
|
221
|
+
|
|
222
|
+ a = $('<a>',{
|
|
223
|
+ 'onclick':'fetchCriteria(this)',
|
|
224
|
+ 'data-objective-id': objective.id,
|
|
225
|
+ 'data-outcome-id':id
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+ }).html("Change Associated Criteria");
|
|
229
|
+
|
|
230
|
+ link_td.append(a)
|
|
231
|
+
|
|
232
|
+
|
143
|
233
|
tr.append(td_text);
|
144
|
234
|
tr.append(td_programs);
|
|
235
|
+ tr.append(link_td)
|
145
|
236
|
tr.appendTo($('#table_objectives'))
|
146
|
237
|
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
147
|
241
|
})
|
148
|
242
|
},
|
149
|
243
|
'json'
|
|
@@ -161,6 +255,369 @@
|
161
|
255
|
})
|
162
|
256
|
});
|
163
|
257
|
|
|
258
|
+ function postDeleteCrit(criterion_id ,program_id ,outcome_id ,objective_id ,cobo_id ,pcobo_id){
|
|
259
|
+
|
|
260
|
+ $.post(
|
|
261
|
+ "{{URL::action('Objective2Controller@deletePCOBO')}}",
|
|
262
|
+ {
|
|
263
|
+ criterion_id:criterion_id,
|
|
264
|
+ program_id:program_id,
|
|
265
|
+ outcome_id:outcome_id,
|
|
266
|
+ objective_id:objective_id,
|
|
267
|
+ cobo_id:cobo_id,
|
|
268
|
+ pcobo_id:pcobo_id
|
|
269
|
+ },
|
|
270
|
+ function (status){
|
|
271
|
+
|
|
272
|
+ if(status == 200){
|
|
273
|
+ $('.selected_criteria_to_delete').parent().parent().remove();
|
|
274
|
+ }
|
|
275
|
+ else{
|
|
276
|
+ alert("something went wrong, try again later.");
|
|
277
|
+ }
|
|
278
|
+
|
|
279
|
+ }
|
|
280
|
+ )
|
|
281
|
+ }
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+ function createSelectForModal(options){
|
|
285
|
+
|
|
286
|
+ div_master = $('<div>',{
|
|
287
|
+ 'class':'removable_div'
|
|
288
|
+ })
|
|
289
|
+ div_select = $("<div>",{
|
|
290
|
+ 'class':'form-group col-md-11',
|
|
291
|
+
|
|
292
|
+ })
|
|
293
|
+ select = $('<select>',{
|
|
294
|
+ 'class':'selectpicker form-control criteria_select',
|
|
295
|
+ 'name':'criteria[]',
|
|
296
|
+ 'onchange':'saveChanges(this)'
|
|
297
|
+
|
|
298
|
+ }).html(options);
|
|
299
|
+ div_rem_button = $('<div>',
|
|
300
|
+ {
|
|
301
|
+ 'class':'col-md-1 remove-btn'
|
|
302
|
+
|
|
303
|
+ })
|
|
304
|
+ rem_button = $('<button>',{
|
|
305
|
+ 'type':'button',
|
|
306
|
+ 'class':'btn btn-primary',
|
|
307
|
+ 'onclick':'deleteCriterion(this);'
|
|
308
|
+ }).html("<span class='glyphicon glyphicon-remove'></span>")
|
|
309
|
+
|
|
310
|
+ div_select.append(select);
|
|
311
|
+ div_rem_button.append(rem_button);
|
|
312
|
+ div_master.append(div_select);
|
|
313
|
+ div_master.append(div_rem_button);
|
|
314
|
+
|
|
315
|
+ return div_master;
|
|
316
|
+
|
|
317
|
+ }
|
|
318
|
+
|
|
319
|
+ function saveChanges(select){
|
|
320
|
+
|
|
321
|
+ //Create if old-cobo doesnt exist
|
|
322
|
+
|
|
323
|
+ option = $(select).find(':selected');
|
|
324
|
+
|
|
325
|
+ criterion_id = option.val()
|
|
326
|
+ if(criterion_id ==0){
|
|
327
|
+ return;
|
|
328
|
+ }
|
|
329
|
+ pcobo_id = option.data('pcobo-id')
|
|
330
|
+ cobo_id = option.data('cobo-id');
|
|
331
|
+ objective_id = option.data('objective-id')
|
|
332
|
+ outcome_id = option.data('outcome-id');
|
|
333
|
+ program_id = option.data('program-id')
|
|
334
|
+
|
|
335
|
+ dict_to_send = {};
|
|
336
|
+
|
|
337
|
+ if($(select).data('old-pcobo') ===undefined){
|
|
338
|
+ dict_to_send= {
|
|
339
|
+ criterion_id:criterion_id,
|
|
340
|
+ pcobo_id:pcobo_id,
|
|
341
|
+ cobo_id:cobo_id,
|
|
342
|
+ objective_id:objective_id,
|
|
343
|
+ outcome_id:outcome_id,
|
|
344
|
+ program_id:program_id
|
|
345
|
+ }
|
|
346
|
+ url = "{{URL::action('Objective2Controller@insertPCOBO')}}";
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+ }
|
|
350
|
+ else{
|
|
351
|
+
|
|
352
|
+ url= "{{URL::action('Objective2Controller@updatePCOBO')}}";
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+ old_crit = $(select).data('old-criterion')
|
|
356
|
+ old_outcome= $(select).data('old-outcome')
|
|
357
|
+ old_cobo = $(select).data('old-cobo')
|
|
358
|
+ old_pcobo = $(select).data('old-pcobo')
|
|
359
|
+ dict_to_send ={
|
|
360
|
+ criterion_id:criterion_id,
|
|
361
|
+ pcobo_id:pcobo_id,
|
|
362
|
+ cobo_id:cobo_id,
|
|
363
|
+ objective_id:objective_id,
|
|
364
|
+ outcome_id:outcome_id,
|
|
365
|
+ program_id:program_id,
|
|
366
|
+ old_crit:old_crit,
|
|
367
|
+ old_outcome:old_outcome,
|
|
368
|
+ old_cobo:old_cobo,
|
|
369
|
+ old_pcobo:old_pcobo
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+ }
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+ }
|
|
378
|
+
|
|
379
|
+ $.post(
|
|
380
|
+ url,
|
|
381
|
+ dict_to_send,
|
|
382
|
+ function(code){
|
|
383
|
+ if(code == "DUPLICATE"){
|
|
384
|
+ alert("This criteria is already paired to this objective")
|
|
385
|
+ $(select).val(0)
|
|
386
|
+ $(select).selectpicker('refresh');
|
|
387
|
+ }
|
|
388
|
+ else if (code==200){
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+ $(select).attr('data-old-pcobo', pcobo_id)
|
|
392
|
+ $(select).attr('data-old-cobo', cobo_id)
|
|
393
|
+ $(select).attr('data-old-criterion', criterion_id)
|
|
394
|
+ $(select).attr('data-old-outcome', outcome_id)
|
|
395
|
+ $(select).attr('data-old-objective', objective_id)
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+ }
|
|
399
|
+ }
|
|
400
|
+ )
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+ }
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+ function fetchCriteria(a){
|
|
411
|
+ objective_id = $(a).data('objective-id');
|
|
412
|
+ objective_text = $("#objective-"+objective_id).html()
|
|
413
|
+ outcome_id = $(a).data('outcome-id')
|
|
414
|
+
|
|
415
|
+ $.post(
|
|
416
|
+ "{{URL::action('Objective2Controller@fetchProgramCriteria')}}",
|
|
417
|
+ {
|
|
418
|
+ objective_id:objective_id,
|
|
419
|
+ outcome_id:outcome_id
|
|
420
|
+ },
|
|
421
|
+ function(programs){
|
|
422
|
+ //modal, and its subvariants
|
|
423
|
+ mc = "#match_criteria";
|
|
424
|
+
|
|
425
|
+ $(mc).data('objective-id', objective_id)
|
|
426
|
+
|
|
427
|
+ title_h = $('<h5>',{
|
|
428
|
+ 'class':'modal-title'
|
|
429
|
+ }).html("Match "+ objective_text +" to Criteria")
|
|
430
|
+ $(mc+"_title").html(title_h)
|
|
431
|
+
|
|
432
|
+ $('.removable_div').remove();
|
|
433
|
+
|
|
434
|
+ //select= $(".select_criteria").html(" ");
|
|
435
|
+ program_select = $("#match_criteria_program").html(" ");
|
|
436
|
+
|
|
437
|
+ $.each(programs, function(ind, program){
|
|
438
|
+
|
|
439
|
+ prog_div = $("<div>",{
|
|
440
|
+ "id":"program-"+program.id,
|
|
441
|
+ "class": "program_divs removable_div",
|
|
442
|
+ "style":"display: none"
|
|
443
|
+ })
|
|
444
|
+ program_option = $('<option>',{
|
|
445
|
+ "value":program.id
|
|
446
|
+ }).html(program.name)
|
|
447
|
+
|
|
448
|
+ program_select.append(program_option);
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+ criteria = program.criteria
|
|
452
|
+ options_html = '<option value="0">Nothing Selected</option>';
|
|
453
|
+
|
|
454
|
+ more_than_one = false;
|
|
455
|
+ selected_options = [];
|
|
456
|
+
|
|
457
|
+ $.each(criteria, function(ind, cri){
|
|
458
|
+
|
|
459
|
+ if(cri.objective_id == objective_id && cri.outcome_id == outcome_id){
|
|
460
|
+ dictionary_to_keep = {
|
|
461
|
+ 'value':cri.criterion_id,
|
|
462
|
+ 'data-program-id':program.id,
|
|
463
|
+ 'data-outcome-id':outcome_id,
|
|
464
|
+ 'data-objective-id':objective_id,
|
|
465
|
+ 'data-cobo-id':cri.cobo_id,
|
|
466
|
+ 'data-pcobo-id':cri.pcobo_id
|
|
467
|
+
|
|
468
|
+ }
|
|
469
|
+ option = $("<option>",{
|
|
470
|
+ 'value':cri.criterion_id,
|
|
471
|
+ 'data-program-id':program.id,
|
|
472
|
+ 'data-outcome-id':outcome_id,
|
|
473
|
+ 'data-objective-id':objective_id,
|
|
474
|
+ 'data-cobo-id':cri.cobo_id,
|
|
475
|
+ 'data-pcobo-id':cri.pcobo_id
|
|
476
|
+
|
|
477
|
+ }).html(cri.name)
|
|
478
|
+ // option.prop('selected', true);
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+ selected_options.push(dictionary_to_keep);
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+ }
|
|
488
|
+ else if (cri.outcome_id == outcome_id){
|
|
489
|
+ option = $("<option>",{
|
|
490
|
+ 'value':cri.criterion_id,
|
|
491
|
+ 'data-program-id':program.id,
|
|
492
|
+ 'data-outcome-id':outcome_id,
|
|
493
|
+ 'data-objective-id':objective_id,
|
|
494
|
+ 'data-cobo-id':cri.cobo_id,
|
|
495
|
+ 'data-pcobo-id':cri.pcobo_id
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+ }).html(cri.name)
|
|
499
|
+ }
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+ options_html += option.prop('outerHTML');
|
|
504
|
+ //$(select).selectpicker('refresh');
|
|
505
|
+
|
|
506
|
+ //if(criteria)
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+ })
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+ //create multiple selects.
|
|
513
|
+
|
|
514
|
+ // el query es , Si no esta en program id, objetivo es 0.
|
|
515
|
+ //Si program id
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+ $('#program_objectives').append(prog_div);
|
|
521
|
+ select = createSelectForModal(options_html)
|
|
522
|
+
|
|
523
|
+ select.find('div.remove-btn').hide()
|
|
524
|
+ prog_div.append(select);
|
|
525
|
+ $('select.criteria_select').selectpicker('refresh');
|
|
526
|
+ if(selected_options){
|
|
527
|
+ $.each(selected_options, function(ind, cri){
|
|
528
|
+
|
|
529
|
+ the_picker = select.find('select.criteria_select').first();
|
|
530
|
+ the_picker.val(cri['value']);
|
|
531
|
+ the_picker.attr('data-old-pcobo', cri['data-pcobo-id'])
|
|
532
|
+ the_picker.attr('data-old-cobo', cri['data-cobo-id'])
|
|
533
|
+ the_picker.attr('data-old-criterion', cri['value'])
|
|
534
|
+ the_picker.attr('data-old-outcome', cri['data-outcome-id'])
|
|
535
|
+ the_picker.attr('data-old-objective', cri['data-objective-id'])
|
|
536
|
+
|
|
537
|
+ select = createSelectForModal(options_html)
|
|
538
|
+ prog_div.append(select)
|
|
539
|
+ // $('.criteria_select').selectpicker('refresh');
|
|
540
|
+ })
|
|
541
|
+ // to remove the last one
|
|
542
|
+ select.remove();
|
|
543
|
+ }
|
|
544
|
+ //prog_div.append(select)
|
|
545
|
+
|
|
546
|
+ // $('#program_objectives').append(prog_div);
|
|
547
|
+
|
|
548
|
+ $('select.criteria_select').selectpicker('refresh');
|
|
549
|
+
|
|
550
|
+ prog_div.append(createAddCriteriaButton("program-"+program.id))
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+ })
|
|
555
|
+
|
|
556
|
+ program_select.selectpicker('refresh');
|
|
557
|
+ program_select.trigger('change');
|
|
558
|
+
|
|
559
|
+ $(mc).modal('show');
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+ }
|
|
569
|
+ )
|
|
570
|
+ }
|
|
571
|
+
|
|
572
|
+ wr = "#warning"
|
|
573
|
+ function deleteCriterion(button){
|
|
574
|
+ select = $(button).parent().parent().find('select.criteria_select');
|
|
575
|
+
|
|
576
|
+ $('.selected_criteria_to_delete').removeClass('selected_criteria_to_delete');
|
|
577
|
+
|
|
578
|
+ $(button).addClass('selected_criteria_to_delete');
|
|
579
|
+
|
|
580
|
+ criterion_id = $(select).val()
|
|
581
|
+ if(criterion_id ==0){
|
|
582
|
+ $(button).parent().parent().remove()
|
|
583
|
+ return
|
|
584
|
+ }
|
|
585
|
+ option = $(select).find(':selected');
|
|
586
|
+ name = $(select).find(':selected').html();
|
|
587
|
+ program_id = $(option).data('program-id')
|
|
588
|
+ outcome_id = $(option).data('outcome-id')
|
|
589
|
+ objective_id = $(option).data('objective-id')
|
|
590
|
+ cobo_id = $(option).data('cobo-id')
|
|
591
|
+ pcobo_id = $(option).data('pcobo-id')
|
|
592
|
+ $(wr+'_title').html("Are you sure you want to remove this Criterion?")
|
|
593
|
+ $(wr+"_delete").attr('onclick', 'postDeleteCrit('+criterion_id+' ,'+program_id+' ,'+outcome_id+' ,'+objective_id+' ,'+cobo_id+' ,'+pcobo_id+'); $("'+wr+'").modal("hide") ');
|
|
594
|
+ $(wr+'_body').html("<p>You are about to detach <strong>"+ name+"</strong> </p>")
|
|
595
|
+ $(wr).modal('show');
|
|
596
|
+ }
|
|
597
|
+
|
|
598
|
+ function createAddCriteriaButton(program_div_id){
|
|
599
|
+
|
|
600
|
+ div= $("<div>",{
|
|
601
|
+ 'class':'col-md-12'
|
|
602
|
+ });
|
|
603
|
+
|
|
604
|
+ button = $("<button>", {
|
|
605
|
+ 'class':'add_criteria btn btn-secondary',
|
|
606
|
+ 'type':'button',
|
|
607
|
+ 'onclick':'addSelect("#'+program_div_id+'")',
|
|
608
|
+ 'style':'float: right'
|
|
609
|
+ }).html(" <span class = 'glyphicon glyphicon-plus'></span> Add Criteria");
|
|
610
|
+ div.append(button)
|
|
611
|
+ div.append('<br><br>')
|
|
612
|
+ return div;
|
|
613
|
+ }
|
|
614
|
+
|
|
615
|
+ function addSelect(program_div_id){
|
|
616
|
+ options = $(program_div_id).children('.removable_div').first().find('select.criteria_select').html();
|
|
617
|
+ $(program_div_id).children(".removable_div").last().after(createSelectForModal(options));
|
|
618
|
+ $('select.criteria_select').selectpicker('refresh');
|
|
619
|
+ }
|
|
620
|
+
|
164
|
621
|
$('.view-scales').on('click', function() {
|
165
|
622
|
var number_of_scales = this.value;
|
166
|
623
|
|
|
@@ -168,6 +625,17 @@
|
168
|
625
|
$('.table-responsive-0').show();
|
169
|
626
|
$('.table-' + number_of_scales).show();
|
170
|
627
|
})
|
|
628
|
+
|
|
629
|
+ function changeCriteriaDisplayed(select){
|
|
630
|
+
|
|
631
|
+ select = $(select)
|
|
632
|
+
|
|
633
|
+ program_id = select.val();
|
|
634
|
+
|
|
635
|
+ $('.program_divs').hide();
|
|
636
|
+ $("#program-"+program_id).show();
|
|
637
|
+ }
|
|
638
|
+
|
171
|
639
|
</script>
|
172
|
640
|
@stop
|
173
|
641
|
|