Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 876 Rev 877
Línea 53... Línea 53...
53
 
53
 
Línea 54... Línea 54...
54
$status_active = \LeadersLinked\Model\Competency::STATUS_ACTIVE;
54
$status_active = \LeadersLinked\Model\Competency::STATUS_ACTIVE;
55
 
55
 
56
$this->inlineScript()->captureStart();
-
 
57
echo <<<JS
56
$this->inlineScript()->captureStart();
58
 
57
echo <<<JS
59
    let behaviors = [];
58
let behaviors = [];
60
    jQuery(document).ready(function($) {
59
jQuery(document).ready(function($) {
61
    $.validator.setDefaults({
60
    $.validator.setDefaults({
62
        debug: true,
61
        debug: true,
63
        highlight: function(element) {
62
        highlight: function(element) {
Línea 270... Línea 269...
270
            }).done(function(response) {
269
            }).done(function(response) {
271
                NProgress.start();
270
                NProgress.start();
272
                if (response['success']) {
271
                if (response['success']) {
273
                    $.fn.showSuccess(response['data']);
272
                    $.fn.showSuccess(response['data']);
274
                    $('#row-form').hide();
273
                    $('#row-form').hide();
275
        $('#row-list').show();
274
                    $('#row-list').show();
276
                    gridTable.api().ajax.reload(null, false);
275
                    gridTable.api().ajax.reload(null, false);
277
                } else {
276
                } else {
278
                    validator.resetForm();
277
                    validator.resetForm();
279
                    if (jQuery.type(response['data']) == 'string') {
278
                    if (jQuery.type(response['data']) == 'string') {
280
                        $.fn.showError(response['data']);
279
                        $.fn.showError(response['data']);
Línea 391... Línea 390...
391
    /**
390
    /**
392
     * Clicked on edit conduct
391
     * Clicked on edit conduct
393
     */
392
     */
394
    $('body').on('click', 'button.btn-edit-conduct', function(e) {
393
    $('body').on('click', 'button.btn-edit-conduct', function(e) {
395
        e.preventDefault();
394
        e.preventDefault();
396
        var slug = $(this).data('conduct');
395
        var id = $(this).data('conduct');
397
        var conduct;
396
        validatorFormConduct.resetForm();
398
        var showForm = false;
397
        behaviors.map((item) => {
399
        for (i = 0; i < objFormGenerator.conducts.length; i++) {
-
 
400
            conduct = objFormGenerator.conducts[i];
-
 
401
            if (slug == conduct.slug_conduct) {
398
            if (item.id == id) {
402
                validatorFormConduct.resetForm();
-
 
403
                $('#form-conduct #conduct-id').val(conduct.slug_conduct);
399
                $('#form-conduct #conduct-id').val(conduct.id);
404
                $('#form-conduct #conduct-description').val(conduct.description);
400
                $('#form-conduct #conduct-description').val(conduct.description);
405
                $('#form-conduct #conduct-level').val(conduct.level);
401
                $('#form-conduct #conduct-level').val(conduct.level);
-
 
402
                $('#modal-conduct h4[class="modal-title"]').html('LABEL_EDIT LABEL_CONDUCT');
-
 
403
                $('#modal-conduct').modal('show');
406
                return;
404
                return;
407
            }
405
            }
408
        }
406
        });
409
        if (showForm) {
-
 
410
            $('#modal-conduct h4[class="modal-title"]').html('LABEL_EDIT LABEL_CONDUCT');
-
 
411
            $('#modal-conduct').modal('show');
-
 
412
        }
-
 
413
    });
407
    });
414
    /**
408
    /**
415
     * Clicked on remove conduct
409
     * Clicked on remove conduct
416
     */
410
     */
417
    $('body').on('click', 'button.btn-delete-conduct', function(e) {
411
    $('body').on('click', 'button.btn-delete-conduct', function(e) {
Línea 473... Línea 467...
473
            if (id) {} else {}
467
            if (id) {} else {}
474
            $('#modal-conduct').modal('hide');
468
            $('#modal-conduct').modal('hide');
475
            return false;
469
            return false;
476
        }
470
        }
477
    });
471
    });
478
 
-
 
479
    /**
472
    /**
480
     * Clicked cancel new/edit Form
473
     * Clicked cancel new/edit Form
481
     */
474
     */
482
    $('button.btn-edit-cancel').click(function(e) {
475
    $('button.btn-edit-cancel').click(function(e) {
483
        e.preventDefault();
476
        e.preventDefault();
484
        $('#row-form').hide();
477
        $('#row-form').hide();
485
        $('#row-list').show();
478
        $('#row-list').show();
486
    });
479
    });
487
 
-
 
488
    /**
480
    /**
489
     * Add Behavior to array
481
     * Add Behavior to array
490
     */
482
     */
491
    const addBehavior = (description, level) =>{
483
    const addBehavior = (description, level) => {
-
 
484
        var d = new Date();
492
        behaviors.push(
485
        behaviors.push(
493
            'id' : new Date().getTime(),
486
            'id': d.getTime(),
494
            'description' : description,
487
            'description': description,
495
            'level': level
488
            'level': level
496
        );
489
        );
497
        renderData(behaviors);
490
        renderData(behaviors);
498
    }
491
    }
499
    
-
 
500
    /**
492
    /**
501
     * Edit item behavior
493
     * Edit item behavior
502
     */
494
     */
503
    const editBehavior = (id, description, level ) =>{
495
    const editBehavior = (id, description, level) => {
504
 
-
 
505
        behaviors.map((item)=>{
496
        behaviors.map((item) => {
506
 
-
 
507
            if(item.id == id){
497
            if (item.id == id) {
508
 
-
 
509
                item.description = description;
498
                item.description = description;
510
                item.level = level
499
                item.level = level
511
            }
500
            }
512
 
-
 
513
        });
501
        });
514
 
-
 
515
        renderData(behaviors);
502
        renderData(behaviors);
516
 
-
 
517
        
-
 
518
    }
503
    }
519
    /**
504
    /**
520
     * Remove behavior
505
     * Remove behavior
521
     */
506
     */
522
    const removeBehavior = (id) =>{
507
    const removeBehavior = (id) => {
523
        behaviors = behaviors.filter((item)=>item.id != id);
508
        behaviors = behaviors.filter((item) => item.id != id);
524
        renderData(behaviors);
509
        renderData(behaviors);
525
    }
510
    }
526
 
-
 
527
     /**
511
    /**
528
     * Render Sections data
512
     * Render Sections data
529
     */
513
     */
530
    const renderData = (data) => $("#rows").html($("#behaviorTemplate").render(data));
514
    const renderData = (data) => $("#rows").html($("#behaviorTemplate").render(data));
531
 
-
 
532
 
-
 
533
});
515
});
534
JS;
516
JS;
535
$this->inlineScript()->captureEnd();
517
$this->inlineScript()->captureEnd();
536
?>
518
?>