Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 1094 Rev 1095
Línea 412... Línea 412...
412
     */
412
     */
413
    $('button.btn-form-save-continue').click(function(e) {
413
    $('button.btn-form-save-continue').click(function(e) {
414
        for (var instanceName in CKEDITOR.instances) {
414
        for (var instanceName in CKEDITOR.instances) {
415
            CKEDITOR.instances[instanceName].updateElement();
415
            CKEDITOR.instances[instanceName].updateElement();
416
        }
416
        }
417
        if ($('#form-name').val() == '') {
-
 
418
            $.fn.showError('ERROR_ENTER_NAME');
-
 
419
        } else if ($('#form-description').val() == '') {
-
 
420
            $.fn.showError('ERROR_ENTER_DESCRIPTION');
-
 
421
        } else if ($('#form-text').val() == '') {
-
 
422
            $.fn.showError('ERROR_ENTER_TEXT');
-
 
423
        } else if ($('#form-status').val() == '') {
-
 
424
            $.fn.showError('ERROR_SELECT_STATUS');
-
 
425
        } else if ($('#job_description_id').val() == '') {
-
 
426
            $.fn.showError('ERROR_SELECT_JOB_DESCRIPTION');
-
 
427
        } else if (sections.length == 0) {
-
 
428
            $.fn.showError('ERROR_NOT_SECTIONS');
-
 
429
        } else {
-
 
430
            $.ajax({
417
        saveData(1);
431
                'dataType': 'json',
-
 
432
                'method': 'post',
-
 
433
                'url': $('#form-main').attr('action'),
-
 
434
                'data': {
-
 
435
                    'name': $('#form-main #form-name').val(),
-
 
436
                    'job_description_id': $('#form-main #job_description_id').val(),
-
 
437
                    'status': $('#form-main #form-status').val(),
-
 
438
                    'description': $('#form-main #form-description').val(),
-
 
439
                    'text': $('#form-main #form-text').val(),
-
 
440
                    'content': JSON.stringify(sections)
-
 
441
                },
-
 
442
            }).done(function(response) {
-
 
443
                if (response['success']) {
-
 
444
                    $.fn.showSuccess(response['data']);
-
 
445
                    $('#form-main').attr('action', response['action_edit']);
-
 
446
                    $('#form-main #form-id').val(response['id']);
-
 
447
                    return;
-
 
448
                } else {
-
 
449
                    $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
-
 
450
                    return;
-
 
451
                }
-
 
452
            });
-
 
453
        }
-
 
454
    });
418
    });
455
    /**
419
    /**
456
     * Clicked save and close new/edit Form
420
     * Clicked save and close new/edit Form
457
     */
421
     */
458
    $('button.btn-form-save-close').click(function(e) {
422
    $('button.btn-form-save-close').click(function(e) {
459
        for (var instanceName in CKEDITOR.instances) {
423
        for (var instanceName in CKEDITOR.instances) {
460
            CKEDITOR.instances[instanceName].updateElement();
424
            CKEDITOR.instances[instanceName].updateElement();
461
        }
425
        }
-
 
426
        saveData(0);
-
 
427
    });
-
 
428
    const saveData = (
-
 
429
        continue) => {
462
        if ($('#form-name').val() == '') {
430
        if ($('#form-name').val() == '') {
463
            $.fn.showError('ERROR_ENTER_NAME');
431
            $.fn.showError('ERROR_ENTER_NAME');
464
        } else if ($('#form-description').val() == '') {
432
        } else if ($('#form-description').val() == '') {
465
            $.fn.showError('ERROR_ENTER_DESCRIPTION');
433
            $.fn.showError('ERROR_ENTER_DESCRIPTION');
466
        } else if ($('#form-text').val() == '') {
434
        } else if ($('#form-text').val() == '') {
Línea 485... Línea 453...
485
                    'content': JSON.stringify(sections)
453
                    'content': JSON.stringify(sections)
486
                },
454
                },
487
            }).done(function(response) {
455
            }).done(function(response) {
488
                if (response['success']) {
456
                if (response['success']) {
489
                    $.fn.showSuccess(response['data']);
457
                    $.fn.showSuccess(response['data']);
-
 
458
                    if (
-
 
459
                        continue ==1) {
-
 
460
                        $('#form-main').attr('action', response['action_edit']);
-
 
461
                    } else {
490
                    $('#row-form').hide();
462
                        $('#row-form').hide();
491
                    $('#row-lists').show();
463
                        $('#row-lists').show();
492
                    /*---------- Reset Form -------- */
464
                        /*---------- Reset Form -------- */
493
                    $('#form-main')[0].reset();
465
                        $('#form-main')[0].reset();
494
                    /*--------Reset Sections ----------*/
466
                        /*--------Reset Sections ----------*/
495
                    sections = [];
467
                        sections = [];
496
                    tableForm.fnDraw();
468
                        tableForm.fnDraw();
-
 
469
                    }
497
                    return;
470
                    return;
498
                } else {
471
                } else {
499
                    $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
472
                    $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
500
                    return;
473
                    return;
501
                }
474
                }
502
            });
475
            });
503
        }
476
        }
504
    });
477
    }
505
    /**
478
    /**
506
     * Remove Html Tags
479
     * Remove Html Tags
507
     */
480
     */
508
    const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
481
    const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
509
    /**
482
    /**