Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 892 Rev 893
Línea 261... Línea 261...
261
            'status': {
261
            'status': {
262
                required: false,
262
                required: false,
263
            },
263
            },
264
        },
264
        },
265
        submitHandler: function(form) {
265
        submitHandler: function(form) {
266
            if(behaviors.length==0){
266
            if (behaviors.length == 0) {
267
 
-
 
268
                $.fn.showError('Debe ingresar al menos una conducta deseable');
267
                $.fn.showError('Debe ingresar al menos una conducta deseable');
269
            }else{
268
            } else {
270
 
-
 
271
                $.ajax({
269
                $.ajax({
272
                'dataType': 'json',
270
                    'dataType': 'json',
273
                'accept': 'application/json',
271
                    'accept': 'application/json',
274
                'method': 'post',
272
                    'method': 'post',
275
                'url': $('#form').attr('action'),
273
                    'url': $('#form').attr('action'),
276
                'data': {
274
                    'data': {
277
         
-
 
278
         'name': $('#name').val(),
275
                        'name': $('#name').val(),
279
         'description': $('#description').val(),
276
                        'description': $('#description').val(),
280
         'competency_type_id': $('#competency_type_id').val(),
277
                        'competency_type_id': $('#competency_type_id').val(),
281
         'status': $('#status').val(),
278
                        'status': $('#status').val(),
282
         'behaviors': JSON.stringify(behaviors)
279
                        'behaviors': JSON.stringify(behaviors)
283
     }
280
                    }
284
            }).done(function(response) {
281
                }).done(function(response) {
285
                NProgress.start();
282
                    NProgress.start();
286
                if (response['success']) {
283
                    if (response['success']) {
287
                    $.fn.showSuccess(response['data']);
284
                        $.fn.showSuccess(response['data']);
288
                    $('#row-form').hide();
285
                        $('#row-form').hide();
289
                    $('#row-list').show();
286
                        $('#row-list').show();
290
                    gridTable.api().ajax.reload(null, false);
287
                        gridTable.api().ajax.reload(null, false);
291
                } else {
-
 
292
                    validator.resetForm();
-
 
293
                    if (jQuery.type(response['data']) == 'string') {
-
 
294
                        $.fn.showError(response['data']);
-
 
295
                    } else {
288
                    } else {
-
 
289
                        validator.resetForm();
-
 
290
                        if (jQuery.type(response['data']) == 'string') {
-
 
291
                            $.fn.showError(response['data']);
-
 
292
                        } else {
296
                        $.each(response['data'], function(fieldname, errors) {
293
                            $.each(response['data'], function(fieldname, errors) {
297
                            $.fn.showFormErrorValidator('#form #' + fieldname, errors);
294
                                $.fn.showFormErrorValidator('#form #' + fieldname, errors);
-
 
295
                            });
298
                        });
296
                        }
299
                    }
297
                    }
300
                }
-
 
301
            }).fail(function(jqXHR, textStatus, errorThrown) {
298
                }).fail(function(jqXHR, textStatus, errorThrown) {
302
                $.fn.showError(textStatus);
299
                    $.fn.showError(textStatus);
303
            }).always(function() {
300
                }).always(function() {
304
                NProgress.done();
301
                    NProgress.done();
305
            });
302
                });
306
 
-
 
307
            }
303
            }
308
           
-
 
309
            return false;
304
            return false;
310
        },
305
        },
311
        invalidHandler: function(form, validator) {}
306
        invalidHandler: function(form, validator) {}
312
    });
307
    });
313
    $('body').on('click', 'button.btn-add', function(e) {
308
    $('body').on('click', 'button.btn-add', function(e) {
Línea 447... Línea 442...
447
    });
442
    });
448
    /**
443
    /**
449
     * Clicked cancel new/edit Form
444
     * Clicked cancel new/edit Form
450
     */
445
     */
451
    $('button.btn-conduct-submit').click(function(e) {
446
    $('button.btn-conduct-submit').click(function(e) {
452
        
-
 
453
        if($("#conduct-description").val()==""){
447
        if ($("#conduct-description").val() == "") {
454
            $.fn.showError('Ingrese una descripción');
448
            $.fn.showError('Ingrese una descripción');
455
            return;
449
            return;
456
 
-
 
457
        }else{
450
        } else {
458
 
-
 
459
          $("#conduct-id").val()=="" ?
451
            $("#conduct-id").val() == "" ?
460
 
-
 
461
                addBehavior($("#conduct-description").val(), $("#conduct-level").val()) :
452
                addBehavior($("#conduct-description").val(), $("#conduct-level").val()) :
462
                editBehavior($("#conduct-id").val(),$("#conduct-description").val(), $("#conduct-level").val())
453
                editBehavior($("#conduct-id").val(), $("#conduct-description").val(), $("#conduct-level").val())
463
        
-
 
464
                $('#modal-conduct').modal('hide');
454
            $('#modal-conduct').modal('hide');
465
                return;
455
            return;
466
        }
456
        }
467
    });
457
    });
468
    /**
458
    /**
469
     * Clicked cancel new/edit Form
459
     * Clicked cancel new/edit Form
470
     */
460
     */