Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 338 Rev 339
Línea 62... Línea 62...
62
$review = \LeadersLinked\Model\CompanySelfEvaluationTest::STATUS_REVIEW;
62
$review = \LeadersLinked\Model\CompanySelfEvaluationTest::STATUS_REVIEW;
63
$completed = \LeadersLinked\Model\CompanySelfEvaluationTest::STATUS_COMPLETED;
63
$completed = \LeadersLinked\Model\CompanySelfEvaluationTest::STATUS_COMPLETED;
Línea 64... Línea 64...
64
 
64
 
65
$this->inlineScript()->captureStart();
65
$this->inlineScript()->captureStart();
66
echo <<<JS
66
echo <<<JS
67
    const classFormGenerator = function() {
67
const classFormGenerator = function() {
68
    this.id = 0,
68
    this.id = 0,
69
        this.table = '',
69
        this.table = '',
70
        this.name = '',
70
        this.name = '',
71
        this.text = '',
71
        this.text = '',
Línea 144... Línea 144...
144
                    }
144
                    }
145
                }
145
                }
146
            }
146
            }
147
            $('[data-toggle="tooltip"]').tooltip();
147
            $('[data-toggle="tooltip"]').tooltip();
148
        };
148
        };
149
    }
-
 
150
        
-
 
151
        
149
}
152
jQuery(document).ready(function($) {
150
jQuery(document).ready(function($) {
153
    var objFormGenerator = new classFormGenerator();
151
    var objFormGenerator = new classFormGenerator();
154
    objFormGenerator.render();
152
    objFormGenerator.render();
155
    var allowEdit = $allowEdit;
153
    var allowEdit = $allowEdit;
156
    /**
154
    /**
Línea 244... Línea 242...
244
                        NProgress.done();
242
                        NProgress.done();
245
                    });
243
                    });
246
                },
244
                },
247
            });
245
            });
248
        },
246
        },
249
        'aoColumns': [
247
        'aoColumns': [{
250
            {
-
 
251
                'mDataProp': 'user'
248
                'mDataProp': 'user'
252
            },{
249
            }, {
253
                'mDataProp': 'name'
250
                'mDataProp': 'name'
254
            },
251
            },
255
            {
252
            {
256
                'mDataProp': 'language'
253
                'mDataProp': 'language'
257
            },
254
            },
Línea 260... Línea 257...
260
            },
257
            },
261
            {
258
            {
262
                'mDataProp': 'link_edit'
259
                'mDataProp': 'link_edit'
263
            },
260
            },
264
        ],
261
        ],
265
        'columnDefs': [
262
        'columnDefs': [{
266
            {
-
 
267
                'targets': 0,
263
                'targets': 0,
268
                'className': 'text-vertical-middle',
264
                'className': 'text-vertical-middle',
269
            },{
265
            }, {
270
                'targets': 1,
266
                'targets': 1,
271
                'className': 'text-vertical-middle',
267
                'className': 'text-vertical-middle',
272
            },
268
            },
273
            {
269
            {
274
                'targets': -1,
270
                'targets': -1,
Línea 308... Línea 304...
308
        }).done(function(response) {
304
        }).done(function(response) {
309
            if (response['success']) {
305
            if (response['success']) {
310
                validatorForm.resetForm();
306
                validatorForm.resetForm();
311
                $('#form-main').attr('action', action);
307
                $('#form-main').attr('action', action);
312
                $('#form-main #form-id').val(response['data']['id']),
308
                $('#form-main #form-id').val(response['data']['id']),
313
                $('#name').html(response['data']['name']);
309
                    $('#name').html(response['data']['name']);
314
                $('#text').html(response['data']['text']);
310
                $('#text').html(response['data']['text']);
315
                $('#user').html(response['data']['user']);
311
                $('#user').html(response['data']['user']);
316
                
-
 
317
                /*-------------Render Sections -------*/
312
                /*-------------Render Sections -------*/
318
                
-
 
319
                objFormGenerator.clear();
313
                objFormGenerator.clear();
320
                objFormGenerator.sections = response['data']['content'] || [];
314
                objFormGenerator.sections = response['data']['content'] || [];
321
                objFormGenerator.render();
315
                objFormGenerator.render();
322
                renderSectionData(objFormGenerator.sections);
316
                renderSectionData(objFormGenerator.sections);
323
                
-
 
324
                $('#row-forms').hide();
317
                $('#row-forms').hide();
325
                $('#row-edit').show();
318
                $('#row-edit').show();
326
                $('#form-main #form-name').focus();
319
                $('#form-main #form-name').focus();
327
 
-
 
328
            } else {
320
            } else {
329
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
321
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
330
            }
322
            }
331
        }).fail(function(jqXHR, textStatus, errorThrown) {
323
        }).fail(function(jqXHR, textStatus, errorThrown) {
332
            $.fn.showError(textStatus);
324
            $.fn.showError(textStatus);
333
        });
325
        });
334
    });
326
    });
335
   
-
 
336
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
327
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
337
    $("#form-main").on('submit', function() {
328
    $("#form-main").on('submit', function() {
338
        for (var instanceName in CKEDITOR.instances) {
329
        for (var instanceName in CKEDITOR.instances) {
339
            CKEDITOR.instances[instanceName].updateElement();
330
            CKEDITOR.instances[instanceName].updateElement();
340
        }
331
        }
Línea 475... Línea 466...
475
                    'data': data,
466
                    'data': data,
476
                }).done(function(response) {
467
                }).done(function(response) {
477
                    if (response['success']) {
468
                    if (response['success']) {
478
                        $.fn.showSuccess(response['data']);
469
                        $.fn.showSuccess(response['data']);
479
                        if (formContinue == 1) {
470
                        if (formContinue == 1) {
480
                            $('#form-main').attr('action',response['action_edit']);
471
                            $('#form-main').attr('action', response['action_edit']);
481
                            $('#form-main #form-id').val(response['id']);
472
                            $('#form-main #form-id').val(response['id']);
482
                            $('#form-main #form-continue').val(0);
473
                            $('#form-main #form-continue').val(0);
483
                        } else {
474
                        } else {
484
                            $('#row-edit').hide();
475
                            $('#row-edit').hide();
485
                            $('#row-forms').show();
476
                            $('#row-forms').show();
486
                        /*---------- Reset Form -------- */
477
                            /*---------- Reset Form -------- */
487
                        $('#form-main')[0].reset();
478
                            $('#form-main')[0].reset();
488
                        /*--------Reset Sections ----------*/
479
                            /*--------Reset Sections ----------*/
489
                        clearSectionData();
480
                            clearSectionData();
490
                        /* ------- Refresh Table -----------*/
481
                            /* ------- Refresh Table -----------*/
491
 
-
 
492
                        }
482
                        }
493
                        tableForm.fnDraw();
483
                        tableForm.fnDraw();
494
                    } else {
484
                    } else {
495
                        $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
485
                        $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
496
                    }
486
                    }
Línea 499... Línea 489...
499
                });
489
                });
500
                return false;
490
                return false;
501
            }
491
            }
502
        }
492
        }
503
    });
493
    });
504
 
-
 
505
    /**
494
    /**
506
     * Clicked cancel new/edit Form
495
     * Clicked cancel new/edit Form
507
     */
496
     */
508
    $('button.btn-edit-cancel').click(function(e) {
497
    $('button.btn-edit-cancel').click(function(e) {
509
        e.preventDefault();
498
        e.preventDefault();
Línea 524... Línea 513...
524
    $('button.btn-form-save-close').click(function(e) {
513
    $('button.btn-form-save-close').click(function(e) {
525
        e.preventDefault();
514
        e.preventDefault();
526
        $('#form-main #form-continue').val('0')
515
        $('#form-main #form-continue').val('0')
527
        $('#form-main').submit();
516
        $('#form-main').submit();
528
    });
517
    });
-
 
518
    /**
-
 
519
     * Get Answers
529
 
520
     */
530
    const getAnswer = (type, options, answer) =>{
521
    const getAnswer = (type, options, answer) => {
531
 
-
 
532
        if(type =='open'  || type=='rating-range' ){
522
        if (type == 'open' || type == 'rating-range') {
533
 
-
 
534
            return answer;
523
            return answer;
535
        }
524
        }
536
 
-
 
537
        if(type=='multiple'){
525
        if (type == 'multiple') {
538
 
-
 
539
            var opt  = '';
526
            var opt = '';
540
 
-
 
541
            opt += removeTags(options.filter((opt) =>  answer.includes(opt.slug_option))[0].text)+' ';
527
            opt += removeTags(options.filter((opt) => answer.includes(opt.slug_option))[0].text) + ' ';
542
        
-
 
543
            return opt;
528
            return opt;
544
        }
529
        }
545
        
-
 
546
        return removeTags(options.filter((opt) => opt.slug_option == answer)[0].text);
530
        return removeTags(options.filter((opt) => opt.slug_option == answer)[0].text);
547
        
-
 
548
 
-
 
549
    }
531
    }
550
   
-
 
551
    /**
532
    /**
552
     * Remove Html Tags
533
     * Remove Html Tags
553
     */
534
     */
554
    const removeTags = (str) => str.toString().replace( /(<([^>]+)>)/ig, '')
535
    const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
555
    /**
536
    /**
556
     * Render Sections data
537
     * Render Sections data
557
     */
538
     */
558
    const renderSectionData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
539
    const renderSectionData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
559
        removeTags: removeTags,
540
        removeTags: removeTags,
560
        getAnswer: getAnswer
541
        getAnswer: getAnswer
561
    }));
542
    }));
562
 
-
 
563
 
-
 
564
    /**
543
    /**
565
     * Clear Div Section data 
544
     * Clear Div Section data 
566
     */
545
     */
567
    const clearSectionData = () => $("#rows").html('');
546
    const clearSectionData = () => $("#rows").html('');
568
    /**
547
    /**
569
     * Clicked refresh button
548
     * Clicked refresh button
570
     */
549
     */
571
    $('button.btn-refresh').click(function(e) {
550
    $('button.btn-refresh').click(function(e) {
572
        tableForm.fnDraw();
551
        tableForm.fnDraw();
573
    });
552
    });
574
     
-
 
575
});
553
});
576
JS;
554
JS;
577
$this->inlineScript()->captureEnd();
555
$this->inlineScript()->captureEnd();
578
?>
556
?>
Línea 685... Línea 663...
685
                            </tr>
663
                            </tr>
686
                        </thead>
664
                        </thead>
687
                        <tbody>
665
                        <tbody>
688
                            <tr class="tr-question">
666
                            <tr class="tr-question">
689
                                <td class="text-left">{{:~removeTags(text)}} </td>
667
                                <td class="text-left">{{:~removeTags(text)}} </td>
-
 
668
                                <td>
-
 
669
<select class="form-control">
-
 
670
    <option value="true">LABEL_CORRECT
-
 
671
    </option>
-
 
672
    <option value="false">LABEL_FAIL</option>
-
 
673
</select>
-
 
674
 
690
                                <td></td>
675
                                </td>
691
                            </tr>
676
                            </tr>
692
                        </tbody>
677
                        </tbody>
693
                        <thead>
678
                        <thead>
694
                            <tr>
679
                            <tr>
695
                                <th colspan="2">LABEL_ANSWER</th>
680
                                <th colspan="2">LABEL_ANSWER</th>