Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 194 Rev 196
Línea 460... Línea 460...
460
                        'method': 'post',
460
                        'method': 'post',
461
                        'url': action,
461
                        'url': action,
462
                    }).done(function(response) {
462
                    }).done(function(response) {
463
                        if (response['success']) {
463
                        if (response['success']) {
464
                            $.fn.showSuccess(response['data']);
464
                            $.fn.showSuccess(response['data']);
465
                            gridTable.api().ajax.reload(null, false);
465
                            tableForm.fnDraw();
466
                        } else {
466
                        } else {
467
                            $.fn.showError(response['data']);
467
                            $.fn.showError(response['data']);
468
                        }
468
                        }
469
                    }).fail(function(jqXHR, textStatus, errorThrown) {
469
                    }).fail(function(jqXHR, textStatus, errorThrown) {
470
                        $.fn.showError(textStatus);
470
                        $.fn.showError(textStatus);
Línea 541... Línea 541...
541
                    instanceName = 'form-description';
541
                    instanceName = 'form-description';
542
                let editor = CKEDITOR.instances[instanceName];
542
                let editor = CKEDITOR.instances[instanceName];
543
                editor.setData(response['data']['description'], function() {
543
                editor.setData(response['data']['description'], function() {
544
                    editor.focus();
544
                    editor.focus();
545
                });
545
                });
546
 
-
 
547
 
-
 
548
 
-
 
549
                console.log(response['data'])
-
 
550
 
-
 
551
                instanceName = 'form-text';
546
                instanceName = 'form-text';
552
                CKEDITOR.instances[instanceName].setData(response['data']['text']);
547
                CKEDITOR.instances[instanceName].setData(response['data']['text']);
553
                $('#form-main #form-language').val(response['data']['language']),
548
                $('#form-main #form-language').val(response['data']['language']),
554
                    $('#form-main #form-status').val(response['data']['status']);
549
                    $('#form-main #form-status').val(response['data']['status']);
555
                objFormGenerator.clear();
550
                objFormGenerator.clear();
556
                objFormGenerator.sections = response['data']['content'] || [];
551
                objFormGenerator.sections = response['data']['content'] || [];
557
                objFormGenerator.render();
552
                objFormGenerator.render();
-
 
553
                renderSectionData(objFormGenerator.sections);
558
                $('#row-forms').hide();
554
                $('#row-forms').hide();
559
                $('#row-edit').show();
555
                $('#row-edit').show();
560
                $('#form-main #form-name').focus();
556
                $('#form-main #form-name').focus();
561
            } else {
557
            } else {
562
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
558
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
Línea 763... Línea 759...
763
                        'method': 'post',
759
                        'method': 'post',
764
                        'url': '$routeAdd',
760
                        'url': '$routeAdd',
765
                        'data': data,
761
                        'data': data,
766
                    }).done(function(response) {
762
                    }).done(function(response) {
767
                        if (response['success']) {
763
                        if (response['success']) {
768
                            $.fn.showSuccess(response['message']);
764
                            $.fn.showSuccess(response['data']);
769
                            if (formContinue == 1) {
765
                            if (formContinue == 1) {
770
                                $('#form-main #form-id').val(response['form-id']);
766
                                $('#form-main #form-id').val(response['form-id']);
771
                                $('#form-main #form-continue').val(0);
767
                                $('#form-main #form-continue').val(0);
772
                            } else {
768
                            } else {
773
                                $('#row-edit').hide();
769
                                $('#row-edit').hide();
Línea 846... Línea 842...
846
                    $('#form-section #section-name').val(),
842
                    $('#form-section #section-name').val(),
847
                    $('#form-section #section-text').val(),
843
                    $('#form-section #section-text').val(),
848
                    $('#form-section #section-value').val()
844
                    $('#form-section #section-value').val()
849
                );
845
                );
850
            }
846
            }
851
            renderData(objFormGenerator.sections);
847
            renderSectionData(objFormGenerator.sections);
852
            $('#modal-section').modal('hide');
848
            $('#modal-section').modal('hide');
853
            return false;
849
            return false;
854
        }
850
        }
855
    });
851
    });
856
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
852
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
Línea 927... Línea 923...
927
                    $('#form-question #question-max-length').val(),
923
                    $('#form-question #question-max-length').val(),
928
                    $('#form-question #question-multiline').val(),
924
                    $('#form-question #question-multiline').val(),
929
                    $('#form-question #question-range').val()
925
                    $('#form-question #question-range').val()
930
                );
926
                );
931
            }
927
            }
932
            renderData(objFormGenerator.sections);
928
            renderSectionData(objFormGenerator.sections);
933
            $('#modal-question').modal('hide');
929
            $('#modal-question').modal('hide');
934
            return false;
930
            return false;
935
        }
931
        }
936
    });
932
    });
937
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
933
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
Línea 991... Línea 987...
991
                    $('#form-option #option-text').val(),
987
                    $('#form-option #option-text').val(),
992
                    $('#form-option #option-correct').val(),
988
                    $('#form-option #option-correct').val(),
993
                    $('#form-option #option-value').val()
989
                    $('#form-option #option-value').val()
994
                );
990
                );
995
            }
991
            }
996
            renderData(objFormGenerator.sections);
992
            renderSectionData(objFormGenerator.sections);
997
            $('#modal-option').modal('hide');
993
            $('#modal-option').modal('hide');
998
            return false;
994
            return false;
999
        }
995
        }
1000
    });
996
    });
1001
    $('body').on('click', 'button[id="btn-add-section"]', function(e) {
997
    $('body').on('click', 'button[id="btn-add-section"]', function(e) {
Línea 1053... Línea 1049...
1053
                }
1049
                }
1054
            },
1050
            },
1055
            callback: function(result) {
1051
            callback: function(result) {
1056
                if (result) {
1052
                if (result) {
1057
                    objFormGenerator.deleteSection(slug);
1053
                    objFormGenerator.deleteSection(slug);
1058
                    renderData(objFormGenerator.sections);
1054
                    renderSectionData(objFormGenerator.sections);
1059
                }
1055
                }
1060
            }
1056
            }
1061
        });
1057
        });
1062
    });
1058
    });
1063
    $('body').on('click', 'button.btn-add-question', function(e) {
1059
    $('body').on('click', 'button.btn-add-question', function(e) {
Línea 1147... Línea 1143...
1147
                }
1143
                }
1148
            },
1144
            },
1149
            callback: function(result) {
1145
            callback: function(result) {
1150
                if (result) {
1146
                if (result) {
1151
                    objFormGenerator.deleteQuestion(slug_section, slug);
1147
                    objFormGenerator.deleteQuestion(slug_section, slug);
1152
                    renderData(objFormGenerator.sections);
1148
                    renderSectionData(objFormGenerator.sections);
1153
                }
1149
                }
1154
            }
1150
            }
1155
        });
1151
        });
1156
    });
1152
    });
Línea 1171... Línea 1167...
1171
     }
1167
     }
Línea 1172... Línea 1168...
1172
        
1168
        
1173
     /**
1169
     /**
1174
      * Render Sections data
1170
      * Render Sections data
1175
      */
1171
      */
1176
     const renderData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
1172
     const renderSectionData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
1177
         getType: getQuestionTypeBySlug
1173
         getType: getQuestionTypeBySlug
-
 
1174
     }));
-
 
1175
     
-
 
1176
     /**
-
 
1177
      * Clear Div Section data 
-
 
1178
      */
Línea 1178... Línea 1179...
1178
     }));
1179
     const clearSectionData () => $("#rows").html(''); 
1179
        
1180
        
1180
    $('body').on('click', 'button.btn-add-option', function(e) {
1181
    $('body').on('click', 'button.btn-add-option', function(e) {
1181
        e.preventDefault();
1182
        e.preventDefault();
Línea 1206... Línea 1207...
1206
                            $('#form-option #option-value').parent().show();
1207
                            $('#form-option #option-value').parent().show();
1207
                        } else {
1208
                        } else {
1208
                            $('#form-option #option-value').val('1');
1209
                            $('#form-option #option-value').val('1');
1209
                            $('#form-option #option-value').parent().hide();
1210
                            $('#form-option #option-value').parent().hide();
1210
                        }
1211
                        }
1211
                        renderData(objFormGenerator.sections);
1212
                        renderSectionData(objFormGenerator.sections);
1212
                        showForm = true;
1213
                        showForm = true;
1213
                    }
1214
                    }
1214
                }
1215
                }
1215
            }
1216
            }
1216
        }
1217
        }
Línea 1289... Línea 1290...
1289
                }
1290
                }
1290
            },
1291
            },
1291
            callback: function(result) {
1292
            callback: function(result) {
1292
                if (result) {
1293
                if (result) {
1293
                    objFormGenerator.deleteOption(slug_section, slug_question, slug);
1294
                    objFormGenerator.deleteOption(slug_section, slug_question, slug);
1294
                    renderData(objFormGenerator.sections);
1295
                    renderSectionData(objFormGenerator.sections);
1295
                }
1296
                }
1296
            }
1297
            }
1297
        });
1298
        });
1298
    })
1299
    })
1299
    $('#form-section #section-value').inputNumberFormat({
1300
    $('#form-section #section-value').inputNumberFormat({
Línea 1329... Línea 1330...
1329
    $('button.btn-add-form').click(function(e) {
1330
    $('button.btn-add-form').click(function(e) {
1330
        e.preventDefault();
1331
        e.preventDefault();
1331
        objFormGenerator.clear();
1332
        objFormGenerator.clear();
1332
        objFormGenerator.render();
1333
        objFormGenerator.render();
1333
        validatorForm.resetForm();
1334
        validatorForm.resetForm();
-
 
1335
        clearSectionData();
1334
        $('#form-main #form-id').val('0');
1336
        $('#form-main #form-id').val('0');
1335
        $('#form-main #form-continue').val('0');
1337
        $('#form-main #form-continue').val('0');
1336
        $('#form-main #form-name').val('');
1338
        $('#form-main #form-name').val('');
1337
        instanceName = 'form-text';
1339
        instanceName = 'form-text';
1338
        let editor = CKEDITOR.instances[instanceName];
1340
        let editor = CKEDITOR.instances[instanceName];