Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 1085 Rev 1101
Línea 398... Línea 398...
398
     */
398
     */
399
    $('body').on('click', 'button[id="btn-add-conduct"]', function(e) {
399
    $('body').on('click', 'button[id="btn-add-conduct"]', function(e) {
400
        e.preventDefault();
400
        e.preventDefault();
401
        $('#form-conduct #conduct-id').val('');
401
        $('#form-conduct #conduct-id').val('');
402
        $('#form-conduct #conduct-description').val('');
402
        $('#form-conduct #conduct-description').val('');
403
        $('#form-conduct #conduct-level').val('0');
-
 
404
        $('#modal-conduct h4[class="modal-title"]').html('LABEL_ADD LABEL_CONDUCT');
403
        $('#modal-conduct h4[class="modal-title"]').html('LABEL_ADD LABEL_CONDUCT');
405
        $('#modal-conduct').modal('show');
404
        $('#modal-conduct').modal('show');
406
    });
405
    });
407
    /**
406
    /**
408
     * Clicked on edit conduct
407
     * Clicked on edit conduct
Línea 412... Línea 411...
412
        var id = $(this).data('conduct');
411
        var id = $(this).data('conduct');
413
        behaviors.map((item) => {
412
        behaviors.map((item) => {
414
            if (item.id == id) {
413
            if (item.id == id) {
415
                $('#form-conduct #conduct-id').val(item.id);
414
                $('#form-conduct #conduct-id').val(item.id);
416
                $('#form-conduct #conduct-description').val(item.description);
415
                $('#form-conduct #conduct-description').val(item.description);
417
                $('#form-conduct #conduct-level').val(item.level);
-
 
418
                $('#modal-conduct h4[class="modal-title"]').html('LABEL_EDIT LABEL_CONDUCT');
416
                $('#modal-conduct h4[class="modal-title"]').html('LABEL_EDIT LABEL_CONDUCT');
419
                $('#modal-conduct').modal('show');
417
                $('#modal-conduct').modal('show');
420
                return;
418
                return;
421
            }
419
            }
422
        });
420
        });
Línea 452... Línea 450...
452
        if ($("#conduct-description").val() == "") {
450
        if ($("#conduct-description").val() == "") {
453
            $.fn.showError('ERROR_ENTER_DESCRIPTION');
451
            $.fn.showError('ERROR_ENTER_DESCRIPTION');
454
            return;
452
            return;
455
        } else {
453
        } else {
456
            $("#conduct-id").val() == "" ?
454
            $("#conduct-id").val() == "" ?
457
                addBehavior($("#conduct-description").val(), $("#conduct-level").val()) :
455
                addBehavior($("#conduct-description").val()) :
458
                editBehavior($("#conduct-id").val(), $("#conduct-description").val(), $("#conduct-level").val())
456
                editBehavior($("#conduct-id").val(), $("#conduct-description").val())
459
            $('#modal-conduct').modal('hide');
457
            $('#modal-conduct').modal('hide');
460
            return;
458
            return;
461
        }
459
        }
462
    });
460
    });
463
    /**
461
    /**
Línea 469... Línea 467...
469
        $('#row-list').show();
467
        $('#row-list').show();
470
    });
468
    });
471
    /**
469
    /**
472
     * Add Behavior to array
470
     * Add Behavior to array
473
     */
471
     */
474
    const addBehavior = (description, level) => {
472
    const addBehavior = (description) => {
475
        behaviors.push({
473
        behaviors.push({
476
            'id': new Date().getTime(),
474
            'id': new Date().getTime(),
477
            'description': description,
475
            'description': description
478
            'level': level
-
 
479
        });
476
        });
480
        renderData(behaviors);
477
        renderData(behaviors);
481
    }
478
    }
482
    /**
479
    /**
483
     * Edit item behavior
480
     * Edit item behavior
484
     */
481
     */
485
    const editBehavior = (id, description, level) => {
482
    const editBehavior = (id, description) => {
486
        behaviors.map((item) => {
483
        behaviors.map((item) => {
487
            if (item.id == id) {
484
            if (item.id == id) {
488
                item.description = description;
485
                item.description = description;
489
                item.level = level
-
 
490
            }
486
            }
491
        });
487
        });
492
        renderData(behaviors);
488
        renderData(behaviors);
493
    }
489
    }
494
    /**
490
    /**
Línea 629... Línea 625...
629
                  <br/>
625
                  <br/>
630
                  <div class="table-responsive">
626
                  <div class="table-responsive">
631
                     <table class="table table-bordered">
627
                     <table class="table table-bordered">
632
                        <thead>
628
                        <thead>
633
                           <tr>
629
                           <tr>
634
                              <th style="width: 40%;">LABEL_DESCRIPTION</th>
630
                              <th style="width: 60%;">LABEL_DESCRIPTION</th>
635
                              <th style="width: 20%;">LABEL_LEVEL</th>
-
 
636
                              <th style="width: 20%;">LABEL_ACTIONS</th>
631
                              <th style="width: 20%;">LABEL_ACTIONS</th>
637
                           </tr>
632
                           </tr>
638
                        </thead>
633
                        </thead>
639
                        <tbody id="rows"></tbody>
634
                        <tbody id="rows"></tbody>
640
                     </table>
635
                     </table>
Línea 671... Línea 666...
671
            <div class="modal-body">
666
            <div class="modal-body">
672
               <div class="form-group">
667
               <div class="form-group">
673
                  <label for="conduct-name">LABEL_DESCRIPTION</label>
668
                  <label for="conduct-name">LABEL_DESCRIPTION</label>
674
                  <input type="text" name="conduct-description" id="conduct-description" class="form-control" maxlength="95" value="" />
669
                  <input type="text" name="conduct-description" id="conduct-description" class="form-control" maxlength="95" value="" />
675
               </div>
670
               </div>
676
               <div class="form-group">
-
 
677
                  <label for="conduct-value">LABEL_LEVEL</label>
-
 
678
                  <select class="form-control" id="conduct-level" name="conduct-level">
-
 
679
                     <option value="0">LABEL_NA</option>
-
 
680
                     <option value="1">LABEL_LEVEL_ONE</option>
-
 
681
                     <option value="2">LABEL_LEVEL_TWO</option>
-
 
682
                     <option value="3">LABEL_LEVEL_THREE</option>
-
 
683
                     <option value="4">LABEL_LEVEL_FOUR</option>
-
 
684
                  </select>
-
 
685
               </div>
-
 
686
            </div>
671
            </div>
687
            <div class="modal-footer">
672
            <div class="modal-footer">
688
               <button type="button" class="btn btn-primary btn-conduct-submit">LABEL_SAVE</button>
673
               <button type="button" class="btn btn-primary btn-conduct-submit">LABEL_SAVE</button>
689
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
674
               <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
690
            </div>
675
            </div>