Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 1011 Rev 1012
Línea 251... Línea 251...
251
 
251
 
252
    /**
252
    /**
253
     * Clicked add new section
253
     * Clicked add new section
254
     */
254
     */
255
    $('#btn-add-section').click(function(e) {
255
    $('#btn-add-section').click(function(e) {
256
        $('#form-section #section-id').val('');
256
        $('#form-section #id_section').val('');
257
        $('#form-section #section-name').val('');
257
        $('#form-section #name-section').val('');
258
        $('#form-section #section-name').val('');
-
 
259
        CKEDITOR.instances['section-text'].setData('');
258
        $('#form-section #text-section').val('');
260
        $('#form-section #section-type').val($('#form-section #section-type option:first').val());
259
        $('#form-section #type-section').val($('#form-section #type-section option:first').val());
261
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
260
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
262
        $('#modal-section').modal('show');
261
        $('#modal-section').modal('show');
263
    });
262
    });
264
    /**
263
    /**
Línea 272... Línea 271...
272
    /**
271
    /**
273
     * Clicked save section
272
     * Clicked save section
274
     */
273
     */
275
    $('#btn-save-section').click(function(e) {
274
    $('#btn-save-section').click(function(e) {
Línea 276... Línea 275...
276
        
275
        
Línea 277... Línea 276...
277
        if($('#section-name').val()==''){
276
        if($('#name-section').val()==''){
278
 
277
 
Línea 279... Línea 278...
279
            $.fn.showError('Ingrese un nombre');
278
            $.fn.showError('Ingrese un nombre');
280
            return;
279
            return;
281
 
280
 
282
        }else{
281
        }else{
283
            if($('#section-id').val()==""){
282
            if($('#id_section').val()==""){
284
                addSection(
283
                addSection(
285
                    $('#section-name').val(),
284
                    $('#name-section').val(),
286
                    $('#section-text').val(),
285
                    $('#text-section').val(),
287
                    $('#section-type').val(),
286
                    $('#type-section').val(),
288
                    ) 
287
                    ) 
289
            }else{
288
            }else{
290
                editSection(
289
                editSection(
291
                    $('#section-id').val(),
290
                    $('#id_section').val(),
292
                    $('#section-name').val(),
291
                    $('#name-section').val(),
293
                    $('#section-text').val(),
292
                    $('#text-section').val(),
294
                    $('#section-type').val()
293
                    $('#type-section').val()
295
                ) 
294
                ) 
Línea 380... Línea 379...
380
    /**
379
    /**
381
     * Render Sections data
380
     * Render Sections data
382
     */
381
     */
383
    const renderData= (data) => {
382
    const renderData= (data) => {
384
        console.log(data);
383
        console.log(data);
-
 
384
        $("#rows").html($("#sectionTemplate").render(data);
385
    }
385
    }
Línea 386... Línea 386...
386
 
386
 
387
    /**
387
    /**
388
     * Add Section to array
388
     * Add Section to array
389
     */
389
     */
390
    const addSection = (title, type, text) => {
390
    const addSection = (title, type, text) => {
391
        sections.push({
391
        sections.push({
392
            'id': new Date().getTime(),
392
            'id_section': new Date().getTime(),
393
            'title': title,
393
            'title': title,
394
            'type': type,
394
            'type': type,
395
            'text': text,
395
            'text': text,
396
            'options': []
396
            'options': []
Línea 400... Línea 400...
400
    /**
400
    /**
401
     * Edit item behavior
401
     * Edit item behavior
402
     */
402
     */
403
    const editSection = (id, title, type, text) => {
403
    const editSection = (id, title, type, text) => {
404
        sections.map((item) => {
404
        sections.map((item) => {
405
            if (item.id == id) {
405
            if (item.id_section == id) {
406
                item.title = title;
406
                item.title = title;
407
                item.type = type;
407
                item.type = type;
408
                item.text = text;
408
                item.text = text;
409
            }
409
            }
410
        });
410
        });
Línea 412... Línea 412...
412
    }
412
    }
413
    /**
413
    /**
414
     * Remove behavior
414
     * Remove behavior
415
     */
415
     */
416
    const removeSection = (id) => {
416
    const removeSection = (id) => {
417
        sections = sections.filter((item) => item.id != id);
417
        sections = sections.filter((item) => item.id_section != id);
418
        renderData(sections);
418
        renderData(sections);
419
    }
419
    }
Línea -... Línea 420...
-
 
420
 
-
 
421
     /**
-
 
422
     * Add Option to array
-
 
423
     */
-
 
424
    const addOption = (section, title) => {
-
 
425
        sections.map((item) => {
-
 
426
            if (item.id_option == section) {
-
 
427
                item.options.push({
-
 
428
                    'id_option': new Date().getTime(),
-
 
429
                    'title': title,
-
 
430
                });
-
 
431
            }
-
 
432
        });
420
 
433
        renderData(sections);
-
 
434
    }
-
 
435
    /**
-
 
436
    * Edit item Option
-
 
437
    */
-
 
438
    const editOption = (section, id, tilte) => {
-
 
439
        sections.map((item) => {
-
 
440
            if (item.id_section == section) {
-
 
441
                item.options.map((opt)=>{
-
 
442
                    if(opt.id_option == id){
-
 
443
                        opt.title = title
-
 
444
                    }
-
 
445
                });
-
 
446
            }
-
 
447
        });
-
 
448
        renderData(sections);
-
 
449
    }
-
 
450
    /**
-
 
451
     * Remove Option
-
 
452
     */
Línea -... Línea 453...
-
 
453
    const removeOption = (section, id) => {
-
 
454
 
-
 
455
        sections.map((item) => {
-
 
456
            if (item.id_section == section) {
-
 
457
                item.options = item.options.filter((opt) => opt.id_option != id) || []
Línea -... Línea 458...
-
 
458
            }
-
 
459
        });
421
    
460
 
422
 
461
        renderData(sections);
423
 
462
    }
424
    /**
463
    /**
425
     * Clicked refresh button
464
     * Clicked refresh button
Línea 511... Línea 550...
511
     <!-- section Modal -->
550
     <!-- section Modal -->
Línea 512... Línea 551...
512
 
551
 
513
    <div  id="modal-section" class="modal" tabindex="-1" role="dialog">
552
    <div  id="modal-section" class="modal" tabindex="-1" role="dialog">
514
        <div class="modal-dialog modal-lg" role="document">
553
        <div class="modal-dialog modal-lg" role="document">
515
            <form action="#" name="form-section" id="form-section">
554
            <form action="#" name="form-section" id="form-section">
516
                <input type="hidden" name="section-id" id="section-id" />
555
                <input type="hidden" name="id_section" id="id_section" />
517
                <div class="modal-content">
556
                <div class="modal-content">
518
                    <div class="modal-header">
557
                    <div class="modal-header">
519
                        <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
558
                        <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
520
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
559
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
521
                            <span aria-hidden="true">&times;</span>
560
                            <span aria-hidden="true">&times;</span>
522
                        </button>
561
                        </button>
523
                    </div>
562
                    </div>
524
                    <div class="modal-body">
563
                    <div class="modal-body">
525
                    <div class="form-group">
564
                    <div class="form-group">
526
                            <label for="section-name">LABEL_FIRST_NAME</label>
565
                            <label for="name-section">LABEL_FIRST_NAME</label>
527
                            <input type="text" name="section-name" id="section-name" class="form-control" maxlength="50" value="" />
566
                            <input type="text" name="name-section" id="name-section" class="form-control" maxlength="50" value="" />
528
                        </div>
567
                        </div>
529
                        <div class="form-group">
568
                        <div class="form-group">
530
                            <label for="section-text">LABEL_TEXT</label>
-
 
531
                            <!--  ckeditor -->
569
                            <label for="text-section">LABEL_TEXT</label>
532
                            <textarea  name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
570
                            <textarea  name="text-section" id="text-section" rows="5" class="form-control"></textarea>
533
                        </div>
571
                        </div>
534
                        <div class="form-group">
572
                        <div class="form-group">
535
                            <label for="section-type">LABEL_TYPE</label>
573
                            <label for="type-section">LABEL_TYPE</label>
536
                            <select name="section-type" id="section-type" class="form-control">
574
                            <select name="type-section" id="type-section" class="form-control">
537
                                <option value="simple">Simple</option>
575
                                <option value="simple">Simple</option>
538
                                <option value="multiple">Multiple</option>
576
                                <option value="multiple">Multiple</option>
539
                            </select>
577
                            </select>
540
                        </div>
578
                        </div>
Línea 581... Línea 619...
581
        </div>
619
        </div>
582
    </div>
620
    </div>
Línea 583... Línea 621...
583
 
621
 
Línea -... Línea 622...
-
 
622
    <!-- End Modal Options -->
-
 
623
 
-
 
624
    <!---Template Sections --->
-
 
625
    <script id="sectionTemplate" type="text/x-jsrender">
-
 
626
 
-
 
627
    <div class="panel panel-default" id="panel-{{:id_section}}">
-
 
628
        <div class="panel-heading">
-
 
629
            <h4 class="panel-title">
-
 
630
                <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:id_section}}" href="#collapse-{{:id_section}}">
-
 
631
                    <span class="section-name{{:id_section}}">
-
 
632
                        {{:name}}
-
 
633
                    </span>
-
 
634
                </a>
-
 
635
            </h4>
-
 
636
        </div>
-
 
637
        <div id="collapse-{{:id_section}}" class="panel-collapse in collapse show">
-
 
638
            <div class="panel-body">
-
 
639
                <div class="table-responsive">
-
 
640
                    <table class="table table-bordered">
-
 
641
                        <thead>
-
 
642
                            <tr>
-
 
643
                                <th style="width: 10%;">LABEL_ELEMENT</th>
-
 
644
                                <th style="width: 50%;">LABEL_TEXT</th>
-
 
645
                                <th style="width: 10%;">LABEL_VALUE</th>
-
 
646
                                <th style="width: 10%;">LABEL_TYPE</th>
-
 
647
                                <th style="width: 20%;">LABEL_ACTIONS</th>
-
 
648
                            </tr>
-
 
649
                        </thead>
-
 
650
                        <tbody>
-
 
651
                            <tr class="tr-section">
-
 
652
                                <td class="text-left">LABEL_SECTION</td>
-
 
653
                                <td class="text-left">{{:title}}</td>
-
 
654
                                <td>{{:value}}</td>
-
 
655
                                <td>
-
 
656
                                    
-
 
657
                                    {{if type == 'simple'}} Simple {{/if}}
-
 
658
                                    {{if type == 'multiple'}} Multiple {{/if}}
-
 
659
            
-
 
660
 
-
 
661
                                </td>
-
 
662
                                <td>
-
 
663
                                    <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>
-
 
664
 
-
 
665
                                    <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> 
-
 
666
 
-
 
667
                                     {{if type == 'multiple'}}
-
 
668
                                    <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> 
-
 
669
                                    {{/if}}
-
 
670
                                </td>
-
 
671
                            </tr>
-
 
672
                            {{for options}}
-
 
673
                            <tr >
-
 
674
                                <td class="text-left">--LABEL_OPTION</td>
-
 
675
                                <td class="text-left">
-
 
676
                                    {{:text}}
-
 
677
                                </td>
-
 
678
                                <td></td>
-
 
679
                                <td></td>
-
 
680
                                <td>
-
 
681
                                    <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> 
-
 
682
 
-
 
683
 
-
 
684
                                    <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> 
-
 
685
                                
-
 
686
                                </td>
-
 
687
                            </tr>
-
 
688
                      
-
 
689
                            {{/for}}
-
 
690
                        </tbody>
-
 
691
                    </table>
-
 
692
                </div>
-
 
693
            </div>
-
 
694
        </div>
-
 
695
    </div>
584
    <!-- End Modal Options -->
696
 
-
 
697
    </script>
Línea 585... Línea 698...
585
 
698
 
586
   
699
<!-- End Template Sections-->