Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 1046 Rev 1047
Línea 216... Línea 216...
216
            'accept': 'application/json',
216
            'accept': 'application/json',
217
            'method': 'get',
217
            'method': 'get',
218
            'url': action,
218
            'url': action,
219
        }).done(function(response) {
219
        }).done(function(response) {
220
            if (response['success']) {
220
            if (response['success']) {
-
 
221
                $("#rows").html('');
-
 
222
                sections = [];
221
                $('#form-main').attr('action', action);
223
                $('#form-main').attr('action', action);
222
                $('#form-main #form-id').val(response['data']['id']),
224
                $('#form-main #form-id').val(response['data']['id']),
223
                    $('#form-main #form-continue').val('0');
-
 
224
                $('#form-main #form-name').val(response['data']['name']),
225
                $('#form-main #form-name').val(response['data']['name']),
225
                    /*----------Set Ckeditor ------------*/
-
 
226
                    CKEDITOR.instances['form-description'].setData(response['data']['description']);
-
 
227
                CKEDITOR.instances['form-text'].setData(response['data']['text']);
-
 
228
                $('#form-main #form-language').val(response['data']['language']),
-
 
229
                    $('#form-main #form-status').val(response['data']['status']);
-
 
230
                /*-------------Render Sections -------*/
-
 
231
                renderSectionData();
-
 
232
                $('#row-lists').hide();
226
                $('#row-lists').hide();
233
                $('#row-form').show();
227
                $('#row-form').show();
234
                $('#form-main #form-name').focus();
-
 
235
            } else {
228
            } else {
236
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
229
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
237
            }
230
            }
238
        }).fail(function(jqXHR, textStatus, errorThrown) {
231
        }).fail(function(jqXHR, textStatus, errorThrown) {
239
            $.fn.showError(textStatus);
232
            $.fn.showError(textStatus);
Línea 244... Línea 237...
244
     */
237
     */
245
    $('#btn-add-section').click(function(e) {
238
    $('#btn-add-section').click(function(e) {
246
        $('#form-section #id-section').val('');
239
        $('#form-section #id-section').val('');
247
        $('#form-section #title-section').val('');
240
        $('#form-section #title-section').val('');
248
        $('#form-section #text-section').val('');
241
        $('#form-section #text-section').val('');
-
 
242
        $("#rows").html('');
-
 
243
        sections = [];
249
        $('#form-section #type-section').val($('#form-section #type-section option:first').val());
244
        $('#form-section #type-section').val($('#form-section #type-section option:first').val());
250
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
245
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
251
        $('#modal-section').modal('show');
246
        $('#modal-section').modal('show');
252
    });
247
    });
253
    /**
248
    /**
Línea 348... Línea 343...
348
     */
343
     */
349
    $('body').on('click', 'button.btn-add-option', function(e) {
344
    $('body').on('click', 'button.btn-add-option', function(e) {
350
        e.preventDefault();
345
        e.preventDefault();
351
        var id = $(this).data('section');
346
        var id = $(this).data('section');
352
        $('#section-option').val(id);
347
        $('#section-option').val(id);
-
 
348
        $('#text-option').val('');
353
        $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
349
        $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
354
        $('#modal-option').modal('show');
350
        $('#modal-option').modal('show');
355
        return;
351
        return;
356
    });
352
    });
357
    /**
353
    /**
358
     * Clicked add new Option
354
     * Clicked add new Option
359
     */
355
     */
360
    $('#btn-save-option').click(function(e) {
356
    $('#btn-save-option').click(function(e) {
361
        if ($('#title-option').val() == '') {
357
        if ($('#text-option').val() == '') {
362
            $.fn.showError('Ingrese un texto');
358
            $.fn.showError('Ingrese un texto');
363
            return;
359
            return;
364
        } else {
360
        } else {
365
            if ($('#id-option').val() == "") {
361
            if ($('#id-option').val() == "") {
366
            addOption(
362
            addOption(
367
                $('#section-option').val(),
363
                $('#section-option').val(),
368
                $('#title-option').val(),
364
                $('#text-option').val(),
369
            )
365
            )
370
        } else {
366
        } else {
371
            editOption(
367
            editOption(
372
                $('#section-option').val(),
368
                $('#section-option').val(),
373
                $('#id-option').val(),
369
                $('#id-option').val(),
374
                $('#title-option').val(),
370
                $('#text-option').val(),
375
            )
371
            )
376
        }
372
        }
377
            $('#modal-option').modal('hide');
373
            $('#modal-option').modal('hide');
378
            return;
374
            return;
379
        }
375
        }
Línea 392... Línea 388...
392
            if (item.id_section == id_section) {
388
            if (item.id_section == id_section) {
393
                item.options.map((opt) => {
389
                item.options.map((opt) => {
394
                    if (opt.id_option == id_option) {
390
                    if (opt.id_option == id_option) {
395
                        $('#id-option').val(opt.id_option);
391
                        $('#id-option').val(opt.id_option);
396
                        $('#section-option').val(opt.id_section);
392
                        $('#section-option').val(opt.id_section);
397
                        $("#title-option").val(opt.title);
393
                        $("#text-option").val(opt.title);
398
                        $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
394
                        $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
399
                        $('#modal-option').modal('show');
395
                        $('#modal-option').modal('show');
400
                        return;
396
                        return;
401
                    }
397
                    }
402
                });
398
                });
Línea 647... Línea 643...
647
                  <span aria-hidden="true">&times;</span>
643
                  <span aria-hidden="true">&times;</span>
648
                  </button>
644
                  </button>
649
               </div>
645
               </div>
650
               <div class="modal-body">
646
               <div class="modal-body">
651
                  <div class="form-group">
647
                  <div class="form-group">
652
                     <label for="title-option">LABEL_TEXT</label>
648
                     <label for="text-option">LABEL_TEXT</label>
653
                     <!--  ckeditor -->
649
                     <!--  ckeditor -->
654
                     <textarea  name="title-option" id="title-option" rows="5" class="form-control"></textarea>
650
                     <textarea  name="text-option" id="text-option" rows="5" class="form-control"></textarea>
655
                  </div>
651
                  </div>
656
               </div>
652
               </div>
657
               <div class="modal-footer">
653
               <div class="modal-footer">
658
                  <button type="button" class="btn btn-primary" id="btn-save-option">LABEL_SAVE</button>
654
                  <button type="button" class="btn btn-primary" id="btn-save-option">LABEL_SAVE</button>
659
                  <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
655
                  <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>