Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 1388 Rev 1389
Línea 245... Línea 245...
245
                $('#form-main #job_category_id').val(response['data']['job_category_id']).trigger('change');
245
                $('#form-main #job_category_id').val(response['data']['job_category_id']).trigger('change');
246
                $('#form-main #industry_id').val(response['data']['industry_id']).trigger('change');
246
                $('#form-main #industry_id').val(response['data']['industry_id']).trigger('change');
247
                $('#form-main #form-status').val(response['data']['status']);
247
                $('#form-main #form-status').val(response['data']['status']);
248
                CKEDITOR.instances['form-description'].setData(response['data']['description']);
248
                CKEDITOR.instances['form-description'].setData(response['data']['description']);
Línea 249... Línea -...
249
 
-
 
250
                sections = response['data']['content'] || [];
-
 
251
                renderData(sections);
-
 
252
                $('#row-lists').hide();
-
 
-
 
249
 
253
                $('#row-form').show();
250
                
254
            } else {
251
            } else {
255
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
252
                $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
256
            }
253
            }
257
        }).fail(function(jqXHR, textStatus, errorThrown) {
254
        }).fail(function(jqXHR, textStatus, errorThrown) {
258
            $.fn.showError(textStatus);
255
            $.fn.showError(textStatus);
259
        });
256
        });
260
    });
-
 
261
    /**
-
 
262
     * Clicked add new section
-
 
263
     */
-
 
264
    $('#btn-add-section').click(function(e) {
-
 
265
        $('#form-section #id-section').val('');
-
 
266
        $('#form-section #title-section').val('');
-
 
267
        $('#form-section #text-section').val('');
-
 
268
        $('#form-section #type-section').val($('#form-section #type-section option:first').val());
-
 
269
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
-
 
270
        $('#modal-section').modal('show');
-
 
271
        return;
-
 
272
    });
-
 
273
    /**
-
 
274
     * Clicked edit section
-
 
275
     */
-
 
276
    /**
-
 
277
     * Clicked save section
-
 
278
     */
-
 
279
    $('#btn-save-section').click(function(e) {
-
 
280
        if ($('#title-section').val() == '') {
-
 
281
            $.fn.showError('ERROR_ENTER_TITLE');
-
 
282
            return;
-
 
283
        } else {
-
 
284
            $('#id-section').val() == "" ?
-
 
285
                addSection($('#title-section').val(), $('#text-section').val(), $('#type-section').val()) :
-
 
286
                editSection($('#id-section').val(), $('#title-section').val(), $('#text-section').val(), $('#type-section').val())
-
 
287
            $('#modal-section').modal('hide');
-
 
288
            return;
-
 
289
        }
-
 
290
    });
-
 
291
    /**
-
 
292
     * Clicked remove section
-
 
293
     */
-
 
294
    $('body').on('click', 'button.btn-delete-section', function(e) {
-
 
295
        var id_section = $(this).data('section');
-
 
296
        bootbox.confirm({
-
 
297
            title: "LABEL_DELETE LABEL_SECTION",
-
 
298
            message: "LABEL_QUESTION_DELETE",
-
 
299
            buttons: {
-
 
300
                cancel: {
-
 
301
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
-
 
302
                },
-
 
303
                confirm: {
-
 
304
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
-
 
305
                }
-
 
306
            },
-
 
307
            callback: function(result) {
-
 
308
                if (result) {
-
 
309
                    removeSection(id_section);
-
 
310
                }
-
 
311
            }
-
 
312
        });
-
 
313
    });
-
 
314
    $('body').on('click', 'button.btn-edit-section', function(e) {
-
 
315
        var id = $(this).data('section');
-
 
316
        sections.map((item) => {
-
 
317
            if (item.id_section == id) {
-
 
318
                $('#form-section #id-section').val(item.id_section);
-
 
319
                $('#form-section #title-section').val(item.title);
-
 
320
                $('#form-section #text-section').val(item.text);
-
 
321
                $('#form-section #type-section').val(item.type);
-
 
322
                $('#modal-section').modal('show');
-
 
323
                return;
-
 
324
            }
-
 
325
        });
-
 
326
    });
-
 
327
    /**
-
 
328
     * Clicked remove option
-
 
329
     */
-
 
330
    $('body').on('click', 'button.btn-delete-option', function(e) {
-
 
331
        var id_section = $(this).data('section');
-
 
332
        var id_option = $(this).data('option');
-
 
333
        bootbox.confirm({
-
 
334
            title: "LABEL_DELETE LABEL_OPTION",
-
 
335
            message: "LABEL_QUESTION_DELETE",
-
 
336
            buttons: {
-
 
337
                cancel: {
-
 
338
                    label: '<i class="fa fa-times"></i> LABEL_CANCEL'
-
 
339
                },
-
 
340
                confirm: {
-
 
341
                    label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
-
 
342
                }
-
 
343
            },
-
 
344
            callback: function(result) {
-
 
345
                if (result) {
-
 
346
                    removeOption(id_section, id_option);
-
 
347
                    return;
-
 
348
                }
-
 
349
            }
-
 
350
        });
-
 
351
    });
-
 
352
    /**
-
 
353
     * Clicked add new Option
-
 
354
     */
-
 
355
    $('body').on('click', 'button.btn-add-option', function(e) {
-
 
356
        var id = $(this).data('section');
-
 
357
        $('#section-option').val(id);
-
 
358
        $('#text-option').val('');
-
 
359
        $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
-
 
360
        $('#modal-option').modal('show');
-
 
361
        return;
-
 
362
    });
-
 
363
    /**
-
 
364
     * Clicked add new Option
-
 
365
     */
-
 
366
    $('#btn-save-option').click(function(e) {
-
 
367
        if ($('#text-option').val() == '') {
-
 
368
            $.fn.showError('ERROR_ENTER_TEXT');
-
 
369
            return;
-
 
370
        } else {
-
 
371
            $('#id-option').val() == "" ?
-
 
372
                addOption($('#section-option').val(), $('#text-option').val()) :
-
 
373
                editOption($('#section-option').val(), $('#id-option').val(), $('#text-option').val())
-
 
374
        }
-
 
375
        $('#modal-option').modal('hide');
-
 
376
        return;
-
 
377
    });
-
 
378
    /**
-
 
379
     * Clicked edit Option
257
    });
380
     */
-
 
381
    $('body').on('click', 'button.btn-edit-option', function(e) {
-
 
382
        var id_section = $(this).data('section');
-
 
383
        var id_option = $(this).data('option');
-
 
384
        sections.map((item) => {
-
 
385
            if (item.id_section == id_section) {
-
 
386
                item.options.map((opt) => {
-
 
387
                    if (opt.id_option == id_option) {
-
 
388
                        $('#id-option').val(opt.id_option);
-
 
389
                        $('#section-option').val(opt.id_section);
-
 
390
                        $("#text-option").val(opt.title);
-
 
391
                        $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
-
 
392
                        $('#modal-option').modal('show');
-
 
393
                        return;
-
 
394
                    }
-
 
395
                });
-
 
396
            }
-
 
397
        });
258
  
398
    });
259
    
399
    /**
260
    /**
400
     * Clicked new Form
261
     * Clicked new Form
401
     */
262
     */
402
    $('button.btn-add-form').click(function(e) {
263
    $('button.btn-add-form').click(function(e) {
Línea 514... Línea 375...
514
    }
375
    }
515
    /**
376
    /**
516
     * Remove Html Tags
377
     * Remove Html Tags
517
     */
378
     */
518
    const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
379
    const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
519
    /**
-
 
520
     * Render Sections data
-
 
521
     */
-
 
522
    const renderData = (data) => {
-
 
523
        $("#rows").html($("#sectionTemplate").render(data));
-
 
524
    }
-
 
525
    /**
-
 
526
     * Add Section to array
-
 
527
     */
-
 
528
    const addSection = (title, text, type) => {
-
 
529
        sections.push({
-
 
530
            'id_section': new Date().getTime(),
-
 
531
            'title': title,
-
 
532
            'type': type,
-
 
533
            'text': text,
-
 
534
            'answer': '',
-
 
535
            'options': []
-
 
536
        });
-
 
537
        return renderData(sections);
-
 
538
    }
-
 
539
    /**
-
 
540
     * Edit item behavior
-
 
541
     */
-
 
542
    const editSection = (id, title, text, type) => {
-
 
543
        sections.map((item) => {
-
 
544
            if (item.id_section == id) {
-
 
545
                item.title = title;
-
 
546
                item.type = type;
-
 
547
                item.text = text;
-
 
548
            }
-
 
549
        });
-
 
550
        return renderData(sections);
-
 
551
    }
-
 
552
    /**
-
 
553
     * Remove behavior
-
 
554
     */
-
 
555
    const removeSection = (id) => {
-
 
556
        sections = sections.filter((item) => item.id_section != id);
-
 
557
        return renderData(sections);
-
 
558
    }
-
 
559
    /**
-
 
560
     * Add Option to array
-
 
561
     */
-
 
562
    const addOption = (id_section, title) => {
-
 
563
        sections.map((item) => {
-
 
564
            if (item.id_section == id_section) {
-
 
565
                item.options.push({
-
 
566
                    'id_section': id_section,
-
 
567
                    'id_option': new Date().getTime(),
-
 
568
                    'title': title,
-
 
569
                    'answer': ''
-
 
570
                });
-
 
571
            }
-
 
572
        });
-
 
573
        return renderData(sections);
-
 
574
    }
380
 
575
    /**
-
 
576
     * Edit item Option
-
 
577
     */
-
 
578
    const editOption = (id_section, id, title) => {
-
 
579
        sections.map((item) => {
-
 
580
            if (item.id_section == id_section) {
-
 
581
                item.options.map((opt) => {
-
 
582
                    if (opt.id_option == id) {
-
 
583
                        opt.title = title
-
 
584
                    }
-
 
585
                });
-
 
586
            }
-
 
587
        });
-
 
588
        return renderData(sections);
-
 
589
    }
381
   
590
    /**
382
    /**
591
     * Remove Option
383
     * Remove Option
592
     */
384
     */
593
    const removeOption = (id_section, id) => {
385
    const removeOption = (id_section, id) => {
594
        sections.map((item) => {
386
        sections.map((item) => {
Línea 739... Línea 531...
739
        e.preventDefault();
531
        e.preventDefault();
Línea 740... Línea 532...
740
        
532
        
741
        $("#location-box").modal('hide');
533
        $("#location-box").modal('hide');
742
        return false;
534
        return false;
743
    });
-
 
744
    /**
-
 
745
     * Filter competencie type
-
 
746
     */
-
 
747
    const filterTypeById = (id) => competencies_type.filter((item) => item.competency_type_id == id ? item : false)[0];
-
 
748
    /**
-
 
749
     * Render Competencies data
-
 
750
     */
-
 
751
    const renderCompetenciesData = (data) => {
-
 
752
        if (data.length > 0) {
-
 
753
            $("#competencies-to-job").show();
-
 
754
            $("#rows-job-competencies").html($("#sectionCompetencies").render(data, {
-
 
755
                getType: filterTypeById
-
 
756
            }));
-
 
757
        } else {
-
 
758
            $("#competencies-to-job").hide();
-
 
759
            $("#rows-job-competencies").html('');
-
 
760
        }
-
 
761
    }
535
    });
762
});
536
    
Línea 763... Línea 537...
763
JS;
537
JS;
764
 
538
 
765
$this->inlineScript()->captureEnd();
539
$this->inlineScript()->captureEnd();
Línea 864... Línea 638...
864
         <div class="row">
638
         <div class="row">
865
            <div class="col-xs-12 col-md-12">
639
            <div class="col-xs-12 col-md-12">
866
               <div class="panel-group" id="rows"></div>
640
               <div class="panel-group" id="rows"></div>
867
            </div>
641
            </div>
868
         </div>
642
         </div>
869
         <div class="form-group" id="competencies-to-job" style="display:none">
-
 
870
            <div class="row">
-
 
871
               <div class="col-xs-12 col-md-12">
-
 
872
                  <hr>
-
 
873
                  <h4 style="font-size: 18px;font-weight: bold;">LABEL_COMPETENCIES_TO_JOB:</h4>
-
 
874
                  <br>
-
 
875
                  <div class="panel-group" id="rows-job-competencies"></div>
-
 
876
               </div>
-
 
877
            </div>
-
 
878
         </div>
643
 
879
         <div class="form-group">
644
         <div class="form-group">
880
            <button type="button" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
645
            <button type="button" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
881
            <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
646
            <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
882
            <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
647
            <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
883
         </div>
648
         </div>