Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 1113 Rev 1115
Línea 317... Línea 317...
317
        $('span[id="form-title"]').html('LABEL_ADD');
317
        $('span[id="form-title"]').html('LABEL_ADD');
318
        $('#form').attr('action', '$routeAdd');
318
        $('#form').attr('action', '$routeAdd');
319
        $('#form #name').val('');
319
        $('#form #name').val('');
320
        $('#form #competency_type_id').val('').trigger('change');
320
        $('#form #competency_type_id').val('').trigger('change');
321
        $('#form #status').bootstrapToggle('on');
321
        $('#form #status').bootstrapToggle('on');
322
        behaviors=[];
322
        behaviors = [];
323
        CKEDITOR.instances.description.setData('');
323
        CKEDITOR.instances.description.setData('');
324
        validator.resetForm();
324
        validator.resetForm();
325
        $('#row-form').show();
325
        $('#row-form').show();
326
        $('#row-list').hide();
326
        $('#row-list').hide();
327
        $("#rows").html('');
327
        $("#rows").html('');
Línea 342... Línea 342...
342
                $('#form').attr('action', action);
342
                $('#form').attr('action', action);
343
                $('#form #name').val(response['data']['name']);
343
                $('#form #name').val(response['data']['name']);
344
                $('#form #competency_type_id').val(response['data']['competency_type_id']).trigger('change');
344
                $('#form #competency_type_id').val(response['data']['competency_type_id']).trigger('change');
345
                $('#form #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
345
                $('#form #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
346
                CKEDITOR.instances.description.setData(response['data']['description']);
346
                CKEDITOR.instances.description.setData(response['data']['description']);
347
                behaviors=response['data']['behaviors'] || [];
347
                behaviors = response['data']['behaviors'] || [];
348
                renderData(behaviors);
348
                renderData(behaviors);
349
                validator.resetForm();
349
                validator.resetForm();
350
                $('#row-form').show();
350
                $('#row-form').show();
351
                $('#row-list').hide();
351
                $('#row-list').hide();
352
            } else {
352
            } else {
Línea 475... Línea 475...
475
    });
475
    });
476
    /**
476
    /**
477
     * Add Behavior to array
477
     * Add Behavior to array
478
     */
478
     */
479
    const addBehavior = (description) => {
479
    const addBehavior = (description) => {
480
 
-
 
481
        $.ajax({
480
        $.ajax({
482
                    'dataType': 'json',
481
            'dataType': 'json',
483
                    'accept': 'application/json',
482
            'accept': 'application/json',
484
                    'method': 'post',
483
            'method': 'post',
485
                    'url': '$routeAddBehavior',
484
            'url': '$routeAddBehavior',
486
                    'data': {
485
            'data': {
487
                        'description': description
486
                'description': description
488
                    }
487
            }
489
                }).done(function(response) {
488
        }).done(function(response) {
490
                    NProgress.start();
-
 
491
                    if (response['success']) {
489
            if (response['success']) {
492
                        behaviors.push({
490
                behaviors.push({
493
            'id': new Date().getTime(),
491
                    'id': new Date().getTime(),
494
            'description': description
492
                    'description': description
-
 
493
                });
-
 
494
                renderData(behaviors);
-
 
495
            } else {
-
 
496
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
-
 
497
            }
495
        });
498
        });
496
        renderData(behaviors);
-
 
497
                    } else {
-
 
498
 
-
 
499
                        $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
-
 
500
 
-
 
501
                       
-
 
502
                    }
-
 
503
                })
-
 
504
    }
499
    }
505
    /**
500
    /**
506
     * Edit item behavior
501
     * Edit item behavior
507
     */
502
     */
508
    const editBehavior = (id, description) => {
503
    const editBehavior = (id, description) => {
-
 
504
        $.ajax({
-
 
505
            'dataType': 'json',
-
 
506
            'accept': 'application/json',
-
 
507
            'method': 'post',
-
 
508
            'url': '/settings/behaviors/edit/' + id,
-
 
509
            'data': {
-
 
510
                'description': description
-
 
511
            }
-
 
512
        }).done(function(response) {
-
 
513
            if (response['success']) {
509
        behaviors.map((item) => {
514
                behaviors.map((item) => {
510
            if (item.id == id) {
515
                    if (item.id == id) {
511
                item.description = description;
516
                        item.description = description;
-
 
517
                    }
-
 
518
                });
-
 
519
                renderData(behaviors);
-
 
520
            } else {
-
 
521
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
512
            }
522
            }
513
        });
523
        });
514
        renderData(behaviors);
-
 
515
    }
524
    }
516
    /**
525
    /**
517
     * Remove behavior
526
     * Remove behavior
518
     */
527
     */
519
    const removeBehavior = (id) => {
528
    const removeBehavior = (id) => {
Línea 522... Línea 531...
522
    }
531
    }
523
    /**
532
    /**
524
     * Render Sections data
533
     * Render Sections data
525
     */
534
     */
526
    const renderData = (data) => $("#rows").html($("#behaviorTemplate").render(data));
535
    const renderData = (data) => $("#rows").html($("#behaviorTemplate").render(data));
-
 
536
    const getAllBehavios = () => {
-
 
537
        $.get("/settings/behaviors/", function(data) {
-
 
538
            console.log(data);
-
 
539
        });
-
 
540
    }
-
 
541
    getAllBehavios();
527
});
542
});
-
 
543
 
-
 
544
 
-
 
545
 
-
 
546
 
528
JS;
547
JS;
529
$this->inlineScript()->captureEnd();
548
$this->inlineScript()->captureEnd();
530
?>
549
?>
Línea 531... Línea 550...
531
  	
550