Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 7814 Rev 7816
Línea 249... Línea 249...
249
            }
249
            }
250
        }).fail(function(jqXHR, textStatus, errorThrown) {
250
        }).fail(function(jqXHR, textStatus, errorThrown) {
251
            $.fn.showError(textStatus);
251
            $.fn.showError(textStatus);
252
        });
252
        });
253
    });
253
    });
254
    /**
-
 
255
     * Clicked add new section
-
 
256
     */
-
 
257
    $('#btn-add-section').click(function(e) {
-
 
258
        $('#form-section #id-section').val('');
-
 
259
        $('#form-section #title-section').val('');
-
 
260
        $('#form-section #text-section').val('');
-
 
261
        $('#form-section #type-section').val($('#form-section #type-section option:first').val());
-
 
262
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
-
 
263
        $('#modal-section').modal('show');
-
 
264
        return;
-
 
265
    });
-
 
266
    /**
-
 
267
     * Clicked edit section
-
 
268
     */
-
 
269
    /**
-
 
270
     * Clicked save section
-
 
271
     */
-
 
272
    $('#btn-save-section').click(function(e) {
-
 
273
        if ($('#title-section').val() == '') {
-
 
274
            $.fn.showError('ERROR_ENTER_TITLE');
-
 
275
            return;
-
 
276
        } else {
-
 
277
            $('#id-section').val() == "" ?
-
 
278
                addSection($('#title-section').val(), $('#text-section').val(), $('#type-section').val()) :
-
 
279
                editSection($('#id-section').val(), $('#title-section').val(), $('#text-section').val(), $('#type-section').val())
-
 
280
            $('#modal-section').modal('hide');
-
 
281
            return;
-
 
282
        }
-
 
283
    });
-
 
284
    /**
-
 
285
     * Clicked remove section
-
 
286
     */
-
 
287
    $('body').on('click', 'button.btn-delete-section', function(e) {
-
 
288
        var id_section = $(this).data('section');
-
 
289
        bootbox.confirm({
-
 
290
            title: "LABEL_DELETE LABEL_SECTION",
-
 
291
            message: "LABEL_QUESTION_DELETE",
-
 
292
            buttons: {
-
 
293
                cancel: {
-
 
294
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
-
 
295
                },
-
 
296
                confirm: {
-
 
297
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
-
 
298
                }
-
 
299
            },
-
 
300
            callback: function(result) {
-
 
301
                if (result) {
-
 
302
                    removeSection(id_section);
-
 
303
                }
-
 
304
            }
-
 
305
        });
-
 
306
    });
-
 
307
    $('body').on('click', 'button.btn-edit-section', function(e) {
-
 
308
        var id = $(this).data('section');
-
 
309
        sections.map((item) => {
-
 
310
            if (item.id_section == id) {
-
 
311
                $('#form-section #id-section').val(item.id_section);
-
 
312
                $('#form-section #title-section').val(item.title);
-
 
313
                $('#form-section #text-section').val(item.text);
-
 
314
                $('#form-section #type-section').val(item.type);
-
 
315
                $('#modal-section').modal('show');
-
 
316
                return;
-
 
317
            }
-
 
318
        });
-
 
319
    });
-
 
320
    /**
-
 
321
     * Clicked remove option
-
 
322
     */
-
 
323
    $('body').on('click', 'button.btn-delete-option', function(e) {
-
 
324
        var id_section = $(this).data('section');
-
 
325
        var id_option = $(this).data('option');
-
 
326
        bootbox.confirm({
-
 
327
            title: "LABEL_DELETE LABEL_OPTION",
-
 
328
            message: "LABEL_QUESTION_DELETE",
-
 
329
            buttons: {
-
 
330
                cancel: {
-
 
331
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
-
 
332
                },
-
 
333
                confirm: {
-
 
334
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
-
 
335
                }
-
 
336
            },
-
 
337
            callback: function(result) {
-
 
338
                if (result) {
-
 
339
                    removeOption(id_section, id_option);
-
 
340
                    return;
-
 
341
                }
-
 
342
            }
-
 
343
        });
-
 
344
    });
-
 
345
    /**
-
 
346
     * Clicked add new Option
-
 
347
     */
-
 
348
    $('body').on('click', 'button.btn-add-option', function(e) {
-
 
349
        var id = $(this).data('section');
-
 
350
        $('#section-option').val(id);
-
 
351
        $('#text-option').val('');
-
 
352
        $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
-
 
353
        $('#modal-option').modal('show');
-
 
354
        return;
-
 
355
    });
-
 
356
    /**
-
 
357
     * Clicked add new Option
-
 
358
     */
-
 
359
    $('#btn-save-option').click(function(e) {
-
 
360
        if ($('#text-option').val() == '') {
-
 
361
            $.fn.showError('ERROR_ENTER_TEXT');
-
 
362
            return;
-
 
363
        } else {
-
 
364
            $('#id-option').val() == "" ?
-
 
365
                addOption($('#section-option').val(), $('#text-option').val()) :
-
 
366
                editOption($('#section-option').val(), $('#id-option').val(), $('#text-option').val())
-
 
367
        }
-
 
368
        $('#modal-option').modal('hide');
-
 
369
        return;
-
 
370
    });
-
 
371
    /**
-
 
372
     * Clicked edit Option
-
 
373
     */
-
 
374
    $('body').on('click', 'button.btn-edit-option', function(e) {
-
 
375
        var id_section = $(this).data('section');
-
 
376
        var id_option = $(this).data('option');
-
 
377
        sections.map((item) => {
-
 
378
            if (item.id_section == id_section) {
-
 
379
                item.options.map((opt) => {
-
 
380
                    if (opt.id_option == id_option) {
-
 
381
                        $('#id-option').val(opt.id_option);
-
 
382
                        $('#section-option').val(opt.id_section);
-
 
383
                        $("#text-option").val(opt.title);
-
 
384
                        $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
-
 
385
                        $('#modal-option').modal('show');
-
 
386
                        return;
-
 
387
                    }
-
 
388
                });
-
 
389
            }
-
 
390
        });
-
 
391
    });
254
    
392
    /**
255
    /**
393
     * Clicked new Form
256
     * Clicked new Form
394
     */
257
     */
395
    $('button.btn-add-form').click(function(e) {
258
    $('button.btn-add-form').click(function(e) {
396
        $("#rows").html('');
259
        $("#rows").html('');
Línea 483... Línea 346...
483
    /**
346
    /**
484
     * Remove Html Tags
347
     * Remove Html Tags
485
     */
348
     */
486
    const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
349
    const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
487
    /**
350
    /**
488
     * Render Sections data
-
 
489
     */
-
 
490
    const renderData = (data) => {
-
 
491
        $("#rows").html($("#sectionTemplate").render(data));
-
 
492
    }
-
 
493
    /**
-
 
494
     * Add Section to array
-
 
495
     */
-
 
496
    const addSection = (title, text, type) => {
-
 
497
        sections.push({
-
 
498
            'id_section': new Date().getTime(),
-
 
499
            'title': title,
-
 
500
            'type': type,
-
 
501
            'text': text,
-
 
502
            'answer': '',
-
 
503
            'options': []
-
 
504
        });
-
 
505
        return renderData(sections);
-
 
506
    }
-
 
507
    /**
-
 
508
     * Edit item behavior
-
 
509
     */
-
 
510
    const editSection = (id, title, text, type) => {
-
 
511
        sections.map((item) => {
-
 
512
            if (item.id_section == id) {
-
 
513
                item.title = title;
-
 
514
                item.type = type;
-
 
515
                item.text = text;
-
 
516
            }
-
 
517
        });
-
 
518
        return renderData(sections);
-
 
519
    }
-
 
520
    /**
-
 
521
     * Remove behavior
-
 
522
     */
-
 
523
    const removeSection = (id) => {
-
 
524
        sections = sections.filter((item) => item.id_section != id);
-
 
525
        return renderData(sections);
-
 
526
    }
-
 
527
    /**
-
 
528
     * Add Option to array
-
 
529
     */
-
 
530
    const addOption = (id_section, title) => {
-
 
531
        sections.map((item) => {
-
 
532
            if (item.id_section == id_section) {
-
 
533
                item.options.push({
-
 
534
                    'id_section': id_section,
-
 
535
                    'id_option': new Date().getTime(),
-
 
536
                    'title': title,
-
 
537
                    'answer': ''
-
 
538
                });
-
 
539
            }
-
 
540
        });
-
 
541
        return renderData(sections);
-
 
542
    }
-
 
543
    /**
-
 
544
     * Edit item Option
-
 
545
     */
-
 
546
    const editOption = (id_section, id, title) => {
-
 
547
        sections.map((item) => {
-
 
548
            if (item.id_section == id_section) {
-
 
549
                item.options.map((opt) => {
-
 
550
                    if (opt.id_option == id) {
-
 
551
                        opt.title = title
-
 
552
                    }
-
 
553
                });
-
 
554
            }
-
 
555
        });
-
 
556
        return renderData(sections);
-
 
557
    }
-
 
558
    /**
-
 
559
     * Remove Option
-
 
560
     */
-
 
561
    const removeOption = (id_section, id) => {
-
 
562
        sections.map((item) => {
-
 
563
            if (item.id_section == id_section) {
-
 
564
                item.options = item.options.filter((opt) => opt.id_option != id) || []
-
 
565
            }
-
 
566
        });
-
 
567
        return renderData(sections);
-
 
568
    }
351
   
569
    /**
352
    /**
570
     * Clicked refresh button
353
     * Clicked refresh button
571
     */
354
     */
572
    $('button.btn-refresh').click(function(e) {
355
    $('button.btn-refresh').click(function(e) {
573
        tableForm.fnDraw();
356
        tableForm.fnDraw();
Línea 714... Línea 497...
714
         </div>
497
         </div>
715
      </form>
498
      </form>
716
   </div>
499
   </div>
717
</div>
500
</div>
718
<!-- Create/Edit Form-->
501
<!-- Create/Edit Form-->
719
<!-- section Modal -->
-
 
720
<div  id="modal-section" class="modal" tabindex="-1" role="dialog">
-
 
721
   <div class="modal-dialog modal-lg" role="document">
-
 
722
      <form action="#" name="form-section" id="form-section">
-
 
723
         <input type="hidden" name="id-section" id="id-section" />
-
 
724
         <div class="modal-content">
-
 
725
            <div class="modal-header">
-
 
726
               <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
-
 
727
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-
 
728
               <span aria-hidden="true">&times;</span>
-
 
729
               </button>
-
 
730
            </div>
-
 
731
            <div class="modal-body">
-
 
732
               <div class="form-group">
-
 
733
                  <label for="title-section">LABEL_FIRST_NAME</label>
-
 
734
                  <input type="text" name="title-section" id="title-section" class="form-control" maxlength="50" value="" />
-
 
735
               </div>
-
 
736
               <div class="form-group">
-
 
737
                  <label for="text-section">LABEL_TEXT</label>
-
 
738
                  <textarea  name="text-section" id="text-section" rows="5" class="form-control"></textarea>
-
 
739
               </div>
-
 
740
               <div class="form-group">
-
 
741
                  <label for="type-section">LABEL_TYPE</label>
-
 
742
                  <select name="type-section" id="type-section" class="form-control">
-
 
743
                     <option value="simple">Simple</option>
-
 
744
                     <option value="multiple">Multiple</option>
-
 
745
                  </select>
-
 
746
               </div>
-
 
747
            </div>
-
 
748
            <div class="modal-footer">
-
 
749
               <button type="button" id="btn-save-section" class="btn btn-primary">LABEL_SAVE</button>
-
 
750
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
-
 
751
            </div>
-
 
752
         </div>
-
 
753
      </form>
-
 
754
   </div>
-
 
755
</div>
-
 
756
<!-- End Modal section -->
-
 
757
<!-- Modal Options -->
-
 
758
<div  id="modal-option" class="modal" tabindex="-1" role="dialog">
-
 
759
   <div class="modal-dialog modal-lg" role="document">
-
 
760
      <form action="#" name="form-option" id="form-option">
-
 
761
         <input type="hidden" name="section-option" id="section-option" value="" />
-
 
762
         <input type="hidden" name="id-option" id="id-option" value="" />
-
 
763
         <div class="modal-content">
-
 
764
            <div class="modal-header">
-
 
765
               <h4 class="modal-title">LABEL_OPTION</h4>
-
 
766
               <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-
 
767
               <span aria-hidden="true">&times;</span>
-
 
768
               </button>
-
 
769
            </div>
-
 
770
            <div class="modal-body">
-
 
771
               <div class="form-group">
-
 
772
                  <label for="text-option">LABEL_TEXT</label>
-
 
773
                  <!--  ckeditor -->
-
 
774
                  <textarea  name="text-option" id="text-option" rows="5" class="form-control"></textarea>
-
 
775
               </div>
-
 
776
            </div>
-
 
777
            <div class="modal-footer">
-
 
778
               <button type="button" class="btn btn-primary" id="btn-save-option">LABEL_SAVE</button>
-
 
779
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
-
 
780
            </div>
-
 
781
         </div>
-
 
782
      </form>
-
 
783
   </div>
-
 
784
</div>
-
 
Línea 785... Línea -...
785
 
-
 
786
   <!-- End Modal Options -->
-
 
787
   <!---Template Sections --->
-
 
788
   <script id="sectionTemplate" type="text/x-jsrender">
-
 
789
   <div class="panel panel-default" id="panel-{{:id_section}}">
-
 
790
   <div class="panel-heading">
-
 
791
   <h4 class="panel-title" style="font-size: 18px;">
-
 
792
         <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:id_section}}" href="#collapse-{{:id_section}}">
-
 
793
         <span class="section-name{{:id_section}}">
-
 
794
         {{:title}}
-
 
795
         </span>
-
 
796
         </a>
-
 
797
      </h4>
-
 
798
   </div>
-
 
799
   <div id="collapse-{{:id_section}}" class="panel-collapse in collapse show">
-
 
800
      <div class="panel-body">
-
 
801
         <div class="table-responsive">
-
 
802
            <table class="table table-bordered">
-
 
803
               <thead>
-
 
804
                  <tr>
-
 
805
                     <th style="width: 10%;">LABEL_ELEMENT</th>
-
 
806
                     <th style="width: 30%;">LABEL_TEXT</th>
-
 
807
                     <th style="width: 10%;">LABEL_TYPE</th>
-
 
808
                     <th style="width: 50%;">LABEL_ACTIONS</th>
-
 
809
                  </tr>
-
 
810
               </thead>
-
 
811
               <tbody>
-
 
812
                  <tr>
-
 
813
                     <td class="text-left">LABEL_SECTION</td>
-
 
814
                     <td class="text-left">{{:title}}</td>
-
 
815
                     <td>
-
 
816
                        {{if type == 'simple'}} Simple {{/if}}
-
 
817
                        {{if type == 'multiple'}} Multiple {{/if}}
-
 
818
                     </td>
-
 
819
                     <td>
-
 
820
                        <button  type="button" class="btn btn-default btn-edit-section" data-section="{{:id_section}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_SECTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_SECTION </button>
-
 
821
                        <button  type="button" class="btn btn-default btn-delete-section" data-section="{{:id_section}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_SECTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_SECTION </button> 
-
 
822
                        {{if type == 'multiple'}}
-
 
823
                        <button type="button" class="btn btn-default btn-add-option" data-section="{{:id_section}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_OPTION </button> 
-
 
824
                        {{/if}}
-
 
825
                     </td>
-
 
826
                  </tr>
-
 
827
                  {{for options}}
-
 
828
                  <tr >
-
 
829
                     <td class="text-left">--LABEL_OPTION</td>
-
 
830
                     <td class="text-left">
-
 
831
                        {{:title}}
-
 
832
                     </td>
-
 
833
                     <td></td>
-
 
834
                     <td>
-
 
835
                        <button type="button"  class="btn btn-default btn-edit-option" data-section="{{:id_section}}" data-option="{{:id_option}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_OPTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_OPTION</button> 
-
 
836
                        <button type="button" class="btn btn-default btn-delete-option" data-section="{{:id_section}}" data-option="{{:id_option}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_OPTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_OPTION</button> 
-
 
837
                     </td>
-
 
838
                  </tr>
-
 
839
                  {{/for}}
-
 
840
               </tbody>
-
 
841
            </table>
-
 
842
         </div>
-
 
843
      </div>
-
 
844
   </div>
-
 
845
</div>
-
 
846
   </script>
-
 
Línea 847... Línea 502...
847
   <!-- End Template Sections-->
502
 
848
 
503
 
849
  <!---Template Competencies --->
504
  <!---Template Competencies --->
850
   <script id="sectionCompetencies" type="text/x-jsrender">
505
   <script id="sectionCompetencies" type="text/x-jsrender">