|
@@ -85,6 +85,8 @@
|
85
|
85
|
|
86
|
86
|
</div>
|
87
|
87
|
|
|
88
|
+
|
|
89
|
+
|
88
|
90
|
<div id="match_criteria" class="modal fade" tabindex="-1" data-objective-id="0">
|
89
|
91
|
<div class="modal-dialog">
|
90
|
92
|
<div class="modal-content">
|
|
@@ -96,13 +98,14 @@
|
96
|
98
|
<p>The following criteria appear based on objective's programs and your available programs</p>
|
97
|
99
|
|
98
|
100
|
<div class ='form-group col-md-12'>
|
|
101
|
+ <label for="match_criteria_program">Program</label>
|
99
|
102
|
<select id="match_criteria_program" class ='form-control selectpicker select_program' onchange="changeCriteriaDisplayed('#match_criteria_program')">
|
100
|
103
|
|
101
|
104
|
</select>
|
102
|
105
|
</div>
|
103
|
106
|
<hr>
|
104
|
|
-
|
105
|
|
- <div id="program_objectives">
|
|
107
|
+ <label>Criteria associated to program</label>
|
|
108
|
+ <div id="program_objectives" class ='form-group col-md-12' >
|
106
|
109
|
|
107
|
110
|
</div>
|
108
|
111
|
|
|
@@ -113,12 +116,42 @@
|
113
|
116
|
|
114
|
117
|
</div>
|
115
|
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>
|
116
|
146
|
<button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="$('#match_criteria').data('objective-id', '0');">Cancel</button>
|
117
|
|
- <button type="button" class="btn btn-primary" onclick = 'matchCriteriaToObjective("#match_criteria")'>Save</button>
|
|
147
|
+ <button id='warning_delete' type="button" class="btn btn-primary" onclick = ''>Delete</button>
|
118
|
148
|
</div>
|
119
|
149
|
</div>
|
120
|
150
|
</div>
|
121
|
151
|
</div>
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
122
|
155
|
<script>
|
123
|
156
|
$(document).ready(function() {
|
124
|
157
|
// --------------------------------------------------------------------------
|
|
@@ -222,6 +255,31 @@
|
222
|
255
|
})
|
223
|
256
|
});
|
224
|
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
|
+
|
225
|
283
|
|
226
|
284
|
function createSelectForModal(options){
|
227
|
285
|
|
|
@@ -234,7 +292,8 @@
|
234
|
292
|
})
|
235
|
293
|
select = $('<select>',{
|
236
|
294
|
'class':'selectpicker form-control criteria_select',
|
237
|
|
- 'name':'criteria[]'
|
|
295
|
+ 'name':'criteria[]',
|
|
296
|
+ 'onchange':'saveChanges(this)'
|
238
|
297
|
|
239
|
298
|
}).html(options);
|
240
|
299
|
div_rem_button = $('<div>',
|
|
@@ -245,7 +304,7 @@
|
245
|
304
|
rem_button = $('<button>',{
|
246
|
305
|
'type':'button',
|
247
|
306
|
'class':'btn btn-primary',
|
248
|
|
- 'onclick':'$(this).parent().parent().remove()'
|
|
307
|
+ 'onclick':'deleteCriterion(this);'
|
249
|
308
|
}).html("<span class='glyphicon glyphicon-remove'></span>")
|
250
|
309
|
|
251
|
310
|
div_select.append(select);
|
|
@@ -257,6 +316,97 @@
|
257
|
316
|
|
258
|
317
|
}
|
259
|
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
|
+
|
260
|
410
|
function fetchCriteria(a){
|
261
|
411
|
objective_id = $(a).data('objective-id');
|
262
|
412
|
objective_text = $("#objective-"+objective_id).html()
|
|
@@ -307,16 +457,28 @@
|
307
|
457
|
$.each(criteria, function(ind, cri){
|
308
|
458
|
|
309
|
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
|
+ }
|
310
|
469
|
option = $("<option>",{
|
311
|
470
|
'value':cri.criterion_id,
|
312
|
471
|
'data-program-id':program.id,
|
313
|
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
|
314
|
476
|
|
315
|
477
|
}).html(cri.name)
|
316
|
478
|
// option.prop('selected', true);
|
317
|
479
|
|
318
|
480
|
|
319
|
|
- selected_options.push(cri.criterion_id);
|
|
481
|
+ selected_options.push(dictionary_to_keep);
|
320
|
482
|
|
321
|
483
|
|
322
|
484
|
|
|
@@ -328,9 +490,14 @@
|
328
|
490
|
'value':cri.criterion_id,
|
329
|
491
|
'data-program-id':program.id,
|
330
|
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
|
+
|
331
|
497
|
|
332
|
498
|
}).html(cri.name)
|
333
|
499
|
}
|
|
500
|
+
|
334
|
501
|
|
335
|
502
|
|
336
|
503
|
options_html += option.prop('outerHTML');
|
|
@@ -353,20 +520,27 @@
|
353
|
520
|
$('#program_objectives').append(prog_div);
|
354
|
521
|
select = createSelectForModal(options_html)
|
355
|
522
|
|
356
|
|
- select.find('.remove_btn').hide()
|
|
523
|
+ select.find('div.remove-btn').hide()
|
357
|
524
|
prog_div.append(select);
|
358
|
525
|
$('select.criteria_select').selectpicker('refresh');
|
359
|
|
-
|
360
|
|
- $.each(selected_options, function(ind, cri_id){
|
361
|
|
-
|
362
|
|
- the_picker = select.find('select.criteria_select').first();
|
363
|
|
- the_picker.val(cri_id);
|
364
|
|
-
|
365
|
|
- select = createSelectForModal(options_html)
|
366
|
|
- prog_div.append(select)
|
367
|
|
- // $('.criteria_select').selectpicker('refresh');
|
368
|
|
- })
|
369
|
|
-
|
|
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
|
+ }
|
370
|
544
|
//prog_div.append(select)
|
371
|
545
|
|
372
|
546
|
// $('#program_objectives').append(prog_div);
|
|
@@ -374,6 +548,7 @@
|
374
|
548
|
$('select.criteria_select').selectpicker('refresh');
|
375
|
549
|
|
376
|
550
|
prog_div.append(createAddCriteriaButton("program-"+program.id))
|
|
551
|
+
|
377
|
552
|
|
378
|
553
|
|
379
|
554
|
})
|
|
@@ -393,17 +568,54 @@
|
393
|
568
|
}
|
394
|
569
|
)
|
395
|
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
|
+ }
|
396
|
597
|
|
397
|
598
|
function createAddCriteriaButton(program_div_id){
|
398
|
599
|
|
399
|
|
-
|
|
600
|
+ div= $("<div>",{
|
|
601
|
+ 'class':'col-md-12'
|
|
602
|
+ });
|
|
603
|
+
|
400
|
604
|
button = $("<button>", {
|
401
|
605
|
'class':'add_criteria btn btn-secondary',
|
402
|
606
|
'type':'button',
|
403
|
|
- 'onclick':'addSelect('+program_div_id+')'
|
404
|
|
-
|
405
|
|
- }).html("+ Add Criteria");
|
|
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
|
+ }
|
406
|
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');
|
407
|
619
|
}
|
408
|
620
|
|
409
|
621
|
$('.view-scales').on('click', function() {
|