Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 1128 Rev 1129
Línea 312... Línea 312...
312
        },
312
        },
313
        invalidHandler: function(form, validator) {}
313
        invalidHandler: function(form, validator) {}
314
    });
314
    });
315
    $('body').on('click', 'button.btn-add', function(e) {
315
    $('body').on('click', 'button.btn-add', function(e) {
316
        e.preventDefault();
316
        e.preventDefault();
317
        getAllBehavios();
-
 
318
        $('span[id="form-title"]').html('LABEL_ADD');
317
        $('span[id="form-title"]').html('LABEL_ADD');
319
        $('#form').attr('action', '$routeAdd');
318
        $('#form').attr('action', '$routeAdd');
320
        $('#form #name').val('');
319
        $('#form #name').val('');
321
        $('#form #competency_type_id').val('').trigger('change');
320
        $('#form #competency_type_id').val('').trigger('change');
322
        $('#form #status').bootstrapToggle('on');
321
        $('#form #status').bootstrapToggle('on');
Línea 329... Línea 328...
329
        return false;
328
        return false;
330
    });
329
    });
331
    $('body').on('click', 'button.btn-edit', function(e) {
330
    $('body').on('click', 'button.btn-edit', function(e) {
332
        e.preventDefault();
331
        e.preventDefault();
333
        NProgress.start();
332
        NProgress.start();
334
        getAllBehavios();
-
 
335
        var action = $(this).data('href');
333
        var action = $(this).data('href');
336
        $("#rows").html('');
334
        $("#rows").html('');
337
        $.ajax({
335
        $.ajax({
338
            'dataType': 'json',
336
            'dataType': 'json',
339
            'method': 'get',
337
            'method': 'get',
Línea 492... Línea 490...
492
                behaviors.push({
490
                behaviors.push({
493
                    'id': new Date().getTime(),
491
                    'id': new Date().getTime(),
494
                    'description': description
492
                    'description': description
495
                });
493
                });
496
                renderData(behaviors);
494
                renderData(behaviors);
497
                getAllBehavios();
-
 
498
            } else {
495
            } else {
499
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
496
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
500
            }
497
            }
501
        });
498
        });
502
    }
499
    }
Línea 518... Línea 515...
518
                    if (item.id == id) {
515
                    if (item.id == id) {
519
                        item.description = description;
516
                        item.description = description;
520
                    }
517
                    }
521
                });
518
                });
522
                renderData(behaviors);
519
                renderData(behaviors);
523
                getAllBehavios();
-
 
524
            } else {
520
            } else {
525
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
521
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
526
            }
522
            }
527
        });
523
        });
528
    }
524
    }
Línea 534... Línea 530...
534
        renderData(behaviors);
530
        renderData(behaviors);
535
    }
531
    }
536
    /**
532
    /**
537
     * Render Sections data
533
     * Render Sections data
538
     */
534
     */
-
 
535
    const renderData = (data) => {
-
 
536
        getAllBehaviors();
539
    const renderData = (data) => $("#rows").html($("#behaviorTemplate").render(data));
537
        $("#rows").html($("#behaviorTemplate").render(data));
-
 
538
    }
540
    /**
539
    /**
541
     * get alls Behavios
540
     * get alls Behavios
542
     */
541
     */
543
    const getAllBehavios = () => {
542
    const getAllBehaviors = () => {
544
        $.getJSON("/settings/behaviors", function(data) {
543
        $.getJSON("/settings/behaviors", function(data) {
545
            $('#select-conduct').children().remove();
544
            $('#select-conduct').children().remove();
546
            $('#select-conduct').append($('<option>', {
545
            $('#select-conduct').append($('<option>', {
547
                value: '',
546
                value: '',
548
                text: 'LABEL_SELECT'
547
                text: 'LABEL_SELECT'
549
            }));
548
            }));
550
            $.each(data.data, function(i, item) {
549
            $.each(data.data, function(i, item) {
-
 
550
 
-
 
551
                if(!behaviors.filter(i)=>i.id ==item.uiid)){
551
                $('#select-conduct').append($('<option>', {
552
                    $('#select-conduct').append($('<option>', {
552
                    value: item.uuid,
553
                    value: item.uuid,
553
                    text: item.description
554
                    text: item.description
554
                }));
555
                }));
-
 
556
                }
-
 
557
 
555
            });
558
            });
556
        });
559
        });
557
    }
560
    }
558
    /**
561
    /**
559
     * Clicked cancel new/edit Form
562
     * Clicked cancel new/edit Form
Línea 566... Línea 569...
566
            behaviors.push({
569
            behaviors.push({
567
                'id': $("#select-conduct").val(),
570
                'id': $("#select-conduct").val(),
568
                'description': $('select[name="select-conduct"] option:selected').text()
571
                'description': $('select[name="select-conduct"] option:selected').text()
569
            });
572
            });
570
            renderData(behaviors);
573
            renderData(behaviors);
571
            getAllBehavios();
-
 
572
        }
574
        }
573
    });
575
    });
574
});
576
});
Línea 575... Línea 577...
575
 
577