Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 1179 | Rev 1181 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1179 Rev 1180
Línea 59... Línea 59...
59
 
59
 
60
$this->inlineScript()->captureStart();
60
$this->inlineScript()->captureStart();
Línea 61... Línea 61...
61
echo <<<JS
61
echo <<<JS
62
 
62
 
63
var competencies = [];
63
var competencies = [];
64
var  competencies_type = [];
64
var competencies_type = [];
65
var subordinates = [];
65
var subordinates = [];
66
var competencies_selected = [];
-
 
67
var subordinates_selected = [];
66
var competencies_selected = [];
68
 
67
var subordinates_selected = [];
69
jQuery(document).ready(function($) {
68
jQuery(document).ready(function($) {
70
    $.validator.setDefaults({
69
    $.validator.setDefaults({
71
        debug: true,
70
        debug: true,
Línea 480... Línea 479...
480
        'width': '160px',
479
        'width': '160px',
481
        'height': '40px'
480
        'height': '40px'
482
    });
481
    });
483
    CKEDITOR.replace('functions');
482
    CKEDITOR.replace('functions');
484
    CKEDITOR.replace('objectives');
483
    CKEDITOR.replace('objectives');
485
 
-
 
486
 
-
 
487
    /**
484
    /**
488
     * Clicked cancel new/edit Form
485
     * Clicked cancel new/edit Form
489
     */
486
     */
490
    $('body').on('click', 'button[id="btn-select-competency"]', function(e) {
487
    $('body').on('click', 'button[id="btn-select-competency"]', function(e) {
491
        console.log('ee')
488
        console.log('ee')
Línea 495... Línea 492...
495
            competencies_selected.push(competencies.filter((item) => item.competency_id == $("#select-competency").val() ? item : false)[0]);
492
            competencies_selected.push(competencies.filter((item) => item.competency_id == $("#select-competency").val() ? item : false)[0]);
496
            renderData(competencies_selected);
493
            renderData(competencies_selected);
497
            setCompetencySelect();
494
            setCompetencySelect();
498
        }
495
        }
499
    });
496
    });
500
 
-
 
501
    const setCompetencySelect = () => {
497
    const setCompetencySelect = () => {
502
        $('#select-competency').children().remove();
498
        $('#select-competency').children().remove();
503
        $('#select-competency').append($('<option>', {
499
        $('#select-competency').append($('<option>', {
504
            value: '',
500
            value: '',
505
            text: 'LABEL_SELECT'
501
            text: 'LABEL_SELECT'
Línea 507... Línea 503...
507
        $.each(competencies, function(i, item) {
503
        $.each(competencies, function(i, item) {
508
            if (!filterItemById(item.competency_id)) {
504
            if (!filterItemById(item.competency_id)) {
509
                var type = filterTypeById(item.competency_type_id);
505
                var type = filterTypeById(item.competency_type_id);
510
                $('#select-competency').append($('<option>', {
506
                $('#select-competency').append($('<option>', {
511
                    value: item.competency_id,
507
                    value: item.competency_id,
512
                    text: type.name+' - '+item.name
508
                    text: type.name + ' - ' + item.name
513
                }));
509
                }));
514
            }
510
            }
515
        });
511
        });
516
    }
512
    }
517
 
-
 
518
    /**
513
    /**
519
     * Render Competencies data
514
     * Render Competencies data
520
     */
515
     */
521
    const renderData = (data) => {
516
    const renderData = (data) => {
522
        $("#competencies-job").html($("#sectionTemplate").render(data, {
517
        $("#competencies-job").html($("#sectionTemplate").render(data, {
523
        getType: filterTypeById
518
            getType: filterTypeById
524
    }));
519
        }));
525
    }
520
    }
526
   
-
 
527
 
-
 
528
    /**
521
    /**
529
     * Filter competencies selected
522
     * Filter competencies selected
530
     */
523
     */
531
    const filterItemById = (id) => competencies_selected.filter((item) => item.competency_id == id ? item : false)[0];
524
    const filterItemById = (id) => competencies_selected.filter((item) => item.competency_id == id ? item : false)[0];
532
    
-
 
533
    /**
525
    /**
534
     * Filter competencie type
526
     * Filter competencie type
535
     */
527
     */
536
    const filterTypeById = (id) => competencies_type.filter((item) => item.competency_type_id == id ? item : false)[0];
528
    const filterTypeById = (id) => competencies_type.filter((item) => item.competency_type_id == id ? item : false)[0];
-
 
529
    
-
 
530
    /**
-
 
531
     * Clicked remove competency
-
 
532
     */
-
 
533
    $('body').on('click', 'button.btn-delete-competency', function(e) {
-
 
534
        var id_competency = $(this).data('competency');
-
 
535
        bootbox.confirm({
-
 
536
            title: "LABEL_DELETE LABEL_COMPETENCY",
-
 
537
            message: "LABEL_QUESTION_DELETE",
-
 
538
            buttons: {
-
 
539
                cancel: {
-
 
540
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
-
 
541
                },
-
 
542
                confirm: {
-
 
543
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
-
 
544
                }
-
 
545
            },
-
 
546
            callback: function(result) {
-
 
547
                if (result) {
-
 
548
                    removeCompetency(id_competency);
-
 
549
                }
-
 
550
            }
-
 
551
        });
-
 
552
    });
-
 
553
    /**
-
 
554
     * Clicked on edit behavior
-
 
555
     */
-
 
556
    $('body').on('click', 'button.btn-edit-behavior', function(e) {
-
 
557
        e.preventDefault();
-
 
558
        var competency_id = $(this).data('competency');
-
 
559
        var behavior_id = $(this).data('behavior');
-
 
560
        behaviors.map((item) => {
-
 
561
            if (item.competency_id == competency_id) {
-
 
562
                item.behaviors.map((b) => {
-
 
563
                    if (b.behavior_id == behavior_id) {
-
 
564
                        $('#form-behavior #behavior-id').val(item.behavior_id);
-
 
565
                        $('#form-behavior #behavior-competency').val(item.competency_id);
-
 
566
                        $('#form-behavior #behavior-level').val(item.level);
-
 
567
                        $('#modal-behavior h4[class="modal-title"]').html('LABEL_EDIT LABEL_CONDUCT');
-
 
568
                        $('#modal-behavior').modal('show');
-
 
569
                        return;
-
 
570
                    }
-
 
571
                });
-
 
572
            }
-
 
573
        });
-
 
574
    });
-
 
575
 
-
 
576
    
-
 
577
    /**
-
 
578
     * Remove Competency
-
 
579
     */
-
 
580
    const removeCompetency = (competency_id) => {
-
 
581
        competencies_selected = competencies_selected.filter((item) => item.competency_id != competency_id);
-
 
582
        return renderData(competencies_selected);
-
 
583
    }
-
 
584
    /**
-
 
585
     * Edit item Behavior
-
 
586
     */
-
 
587
    const editBehavior = (competency_id, behavior_id, level) => {
-
 
588
        competencies_selected.map((item) => {
-
 
589
            if (item.competency_id == competency_id) {
-
 
590
                item.behaviors.map((opt) => {
-
 
591
                    if (opt.behavior_id == behavior_id) {
-
 
592
                        opt.level = level
-
 
593
                    }
-
 
594
                });
-
 
595
            }
-
 
596
        });
-
 
597
        return renderData(competencies_selected);
-
 
598
    }
-
 
599
 
-
 
600
    /**
-
 
601
     * Clicked cancel new/edit Form
-
 
602
     */
-
 
603
    $('button.btn-behavior-submit').click(function(e) {
-
 
604
        if ($("#behavior-description").val() == "") {
-
 
605
            $.fn.showError('ERROR_ENTER_DESCRIPTION');
-
 
606
            return;
-
 
607
        } else {
-
 
608
          
-
 
609
                editBehavior($("#behavior-competency").val(), $("#behavior-id").val(), $("#behavior-level").val())
-
 
610
            $('#modal-behavior').modal('hide');
-
 
611
            return;
-
 
612
        }
-
 
613
    });
537
});
614
});
Línea 538... Línea 615...
538
 
615
 
539
JS;
616
JS;
540
$this->inlineScript()->captureEnd();
617
$this->inlineScript()->captureEnd();
Línea 724... Línea 801...
724
         </div>
801
         </div>
725
      </div>
802
      </div>
726
   </div>
803
   </div>
727
</div>	
804
</div>	
Línea -... Línea 805...
-
 
805
 
-
 
806
<!--start modal behavior-->
-
 
807
<div  id="modal-behavior" class="modal" tabindex="-1" role="dialog">
-
 
808
   <div class="modal-dialog modal-lg" role="document">
-
 
809
      <form action="#" name="form-behavior" id="form-behavior">
-
 
810
         <input type="hidden" name="behavior-id" id="behavior-id" value="" />
-
 
811
         <input type="hidden" name="behavior-competency" id="behavior-competency" value="" />
-
 
812
         <div class="modal-content">
-
 
813
            <div class="modal-header">
-
 
814
               <h4 class="modal-title">LABEL_EDIT LABEL_CONDUCT</h4>
-
 
815
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-
 
816
               <span aria-hidden="true">&times;</span>
-
 
817
               </button>
-
 
818
            </div>
-
 
819
            <div class="modal-body">
-
 
820
               <div class="form-group">
-
 
821
                  <label for="behavior-value">LABEL_LEVEL</label>
-
 
822
                  <select class="form-control" id="behavior-level" name="behavior-level">
-
 
823
                     <option value="0">LABEL_NA</option>
-
 
824
                     <option value="1">LABEL_LEVEL_ONE</option>
-
 
825
                     <option value="2">LABEL_LEVEL_TWO</option>
-
 
826
                     <option value="3">LABEL_LEVEL_THREE</option>
-
 
827
                     <option value="4">LABEL_LEVEL_FOUR</option>
-
 
828
                  </select>
-
 
829
               </div>
-
 
830
            </div>
-
 
831
            <div class="modal-footer">
-
 
832
               <button type="button" class="btn btn-primary btn-behavior-submit">LABEL_SAVE</button>
-
 
833
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
-
 
834
            </div>
-
 
835
         </div>
-
 
836
      </form>
-
 
837
   </div>
-
 
838
</div>
-
 
839
<!---end modal behavior --->
728
 
840
 
729
 <!---Template Competencies --->
841
 <!---Template Competencies --->
730
 <script id="sectionTemplate" type="text/x-jsrender">
842
 <script id="sectionTemplate" type="text/x-jsrender">
731
   <div class="panel panel-default" id="panel-{{:competency_id}}">
843
   <div class="panel panel-default" id="panel-{{:competency_id}}">
732
   <div class="panel-heading">
844
   <div class="panel-heading">
Línea 758... Línea 870...
758
                        {{if type == 'simple'}} Simple {{/if}}
870
                        {{if type == 'simple'}} Simple {{/if}}
759
                        {{if type == 'multiple'}} Multiple {{/if}}
871
                        {{if type == 'multiple'}} Multiple {{/if}}
760
                     </td>
872
                     </td>
761
                     <td>
873
                     <td>
Línea 762... Línea 874...
762
              
874
              
Línea 763... Línea 875...
763
                        <button  type="button" class="btn btn-default btn-delete-section" data-section="{{:competency_id}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_COMPETENCY"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_COMPETENCY </button> 
875
                        <button  type="button" class="btn btn-default btn-delete-competency" data-competency="{{:competency_id}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_COMPETENCY"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_COMPETENCY </button> 
764
            
876
            
765
                     </td>
877
                     </td>
766
                  </tr>
878
                  </tr>
767
                  {{for behaviors}}
879
                  {{for behaviors}}
768
                  <tr >
880
                  <tr >
769
                     <td class="text-left">--LABEL_CONDUCT</td>
881
                     <td class="text-left">--LABEL_CONDUCT</td>
770
                     <td class="text-left">
882
                     <td class="text-left">
771
                        {{:description}}
883
                        {{:description}}
-
 
884
                     </td>
-
 
885
                     <td>
-
 
886
          {{if level == '0'}} LABEL_NA {{/if}} 
-
 
887
          {{if level == '1' }} LABEL_LEVEL_ONE {{/if}} 
-
 
888
          {{if level == '2' }} LABEL_LEVEL_TWO {{/if}} 
772
                     </td>
889
          {{if level == '3' }} LABEL_LEVEL_THREE {{/if}} 
773
                     <td>
890
          {{if level == '4' }} LABEL_LEVEL_FOUR {{/if}} 
774
                     </td>
891
       </td>
Línea 775... Línea 892...
775
                     <td>
892
                     <td>
776
                        <button type="button"  class="btn btn-default btn-edit-option" data-section="{{:competency_id}}" data-option="{{:conduct_id}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_CONDUCT"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_CONDUCT</button> 
893
                        <button type="button"  class="btn btn-default btn-edit-behavior" data-competency="{{:competency_id}}" data-behavior="{{:behavior_id}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_LEVEL"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_LEVEL</button> 
777
           
894
           
778
                     </td>
895
                     </td>