Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 252 Rev 253
Línea 2... Línea 2...
2
$acl = $this->viewModel()->getRoot()->getVariable('acl');
2
$acl = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser = $this->currentUserHelper();
3
$currentUser = $this->currentUserHelper();
Línea 4... Línea 4...
4
 
4
 
Línea 5... Línea -...
5
$roleName = $currentUser->getUserTypeId();
-
 
6
 
5
$roleName = $currentUser->getUserTypeId();
7
$routeAdd = $this->url('self-evaluation/forms/add');
6
 
Línea 8... Línea -...
8
$routeDatatable = $this->url('self-evaluation/forms');
-
 
9
$routeDashboard = $this->url('dashboard');
7
$routeDatatable = $this->url('self-evaluation/reviews');
10
 
-
 
Línea 11... Línea 8...
11
$allowAdd = $acl->isAllowed($roleName, 'self-evaluation/forms/add') ? 1 : 0;
8
$routeDashboard = $this->url('dashboard');
Línea 148... Línea 145...
148
                    }
145
                    }
149
                }
146
                }
150
            }
147
            }
151
            $('[data-toggle="tooltip"]').tooltip();
148
            $('[data-toggle="tooltip"]').tooltip();
152
        },
149
        },
153
        /**
-
 
154
         * Add element to section array 
-
 
155
         */
-
 
156
        this.addSection = function(name, text, value) {
-
 
157
            var d = new Date();
-
 
158
            var slug = 'section' + d.getTime();
-
 
159
            var position = 0;
-
 
160
            $.each(this.sections, function(index, section) {
-
 
161
                if (position < section.position) {
-
 
162
                    position = section.position;
-
 
163
                }
-
 
164
            });
-
 
165
            position++;
-
 
166
            var section = {
-
 
167
                'slug_section': slug,
-
 
168
                'name': name,
-
 
169
                'text': text,
-
 
170
                'value': value,
-
 
171
                'position': position,
-
 
172
                'questions': [],
-
 
173
                'status': 0
-
 
174
            }
-
 
175
            this.sections.push(section);
-
 
176
        },
-
 
177
         /**
-
 
178
         * Edit element to section array 
-
 
179
         */
-
 
180
        this.editSection = function(slug, name, text, value) {
-
 
181
            var renderTable = false;
-
 
182
            for (i = 0; i < this.sections.length; i++) {
-
 
183
                if (slug == this.sections[i].slug_section) {
-
 
184
                    this.sections[i].name = name;
-
 
185
                    this.sections[i].text = text;
-
 
186
                    this.sections[i].value = value;
-
 
187
                    renderTable = true;
-
 
188
                    break;
-
 
189
                }
-
 
190
            }
-
 
191
            if (renderTable) {
-
 
192
                this.renderSection(slug);
-
 
193
            }
-
 
194
        },
-
 
195
         /**
-
 
196
         * Remove element to section array
-
 
197
         */
-
 
198
        this.deleteSection = function(slug) {
-
 
199
            var renderTable = false;
-
 
200
            for (i = 0; i < this.sections.length; i++) {
-
 
201
                if (slug == this.sections[i].slug_section) {
-
 
202
                    this.sections.splice(i, 1);
-
 
203
                    renderTable = true;
-
 
204
                    break;
-
 
205
                }
-
 
206
            }
-
 
207
            if (renderTable) {
-
 
208
                $('#panel' + slug).remove();
-
 
209
            }
-
 
210
        },
-
 
211
         /**
-
 
212
         * Add element to question array
-
 
213
         */
-
 
214
        this.addQuestion = function(slug_section, text, value, type, maxlength, multiline, range) {
-
 
215
            var d = new Date();
-
 
216
            var slug_question = 'question' + d.getTime();
-
 
217
            var position = 0;
-
 
218
            var renderTable = false;
-
 
219
            for (i = 0; i < this.sections.length; i++) {
-
 
220
                if (slug_section == this.sections[i].slug_section) {
-
 
221
                    $.each(this.sections[i].questions, function(index, question) {
-
 
222
                        if (position < question.position) {
-
 
223
                            position = question.position;
-
 
224
                        }
-
 
225
                    });
-
 
226
                    position++;
-
 
227
                    var question = {
-
 
228
                        'slug_section': slug_section,
-
 
229
                        'slug_question': slug_question,
-
 
230
                        'text': text,
-
 
231
                        'value': value,
-
 
232
                        'type': type,
-
 
233
                        'position': position,
-
 
234
                        'maxlength': maxlength,
-
 
235
                        'multiline': multiline,
-
 
236
                        'range': range,
-
 
237
                        'options': [],
-
 
238
                        'answer': type=='multiple' ? [] : ''
-
 
239
                    }
-
 
240
                    this.sections[i].questions.push(question);
-
 
241
                    renderTable = true;
-
 
242
                    break;
-
 
243
                }
-
 
244
            }
-
 
245
            if (renderTable) {
-
 
246
                this.renderSection(slug_section);
-
 
247
            }
-
 
248
        },
-
 
249
         /**
150
         /**
250
         * Add element to question array
151
         * Add element to question array
251
         */
152
         */
252
        this.editQuestion = function(slug_section, slug_question, text, value, type, maxlength, multiline, range) {
153
        this.editQuestion = function(slug_section, slug_question, text, value, type, maxlength, multiline, range) {
253
            var renderTable = false;
154
            var renderTable = false;
Línea 288... Línea 189...
288
                }
189
                }
289
            }
190
            }
290
            if (renderTable) {
191
            if (renderTable) {
291
                this.renderSection(slug_section);
192
                this.renderSection(slug_section);
292
            }
193
            }
293
        },
-
 
294
        /**
-
 
295
         * Remove element to question array
-
 
296
         */
-
 
297
        this.deleteQuestion = function(slug_section, slug_question) {
-
 
298
            var renderTable = false;
-
 
299
            for (i = 0; i < this.sections.length; i++) {
-
 
300
                if (slug_section == this.sections[i].slug_section) {
-
 
301
                    for (j = 0; j < this.sections[i].questions.length; j++) {
-
 
302
                        if (slug_question == this.sections[i].questions[j].slug_question) {
-
 
303
                            this.sections[i].questions.splice(j, 1);
-
 
304
                            renderTable = true;
-
 
305
                            break;
-
 
306
                        }
-
 
307
                    }
-
 
308
                }
-
 
309
                if (renderTable) {
-
 
310
                    break;
-
 
311
                }
-
 
312
            }
-
 
313
            if (renderTable) {
-
 
314
                this.renderSection(slug_section);
-
 
315
            }
-
 
316
        },
-
 
317
        /**
-
 
318
         * Add element to option array
-
 
319
         */
-
 
320
        this.addOption = function(slug_section, slug_question, text, correct, value) {
-
 
321
            var d = new Date();
-
 
322
            var slug_option = 'option' + d.getTime();
-
 
323
            var position = 0;
-
 
324
            var renderTable = false;
-
 
325
            for (i = 0; i < this.sections.length; i++) {
-
 
326
                if (slug_section == this.sections[i].slug_section) {
-
 
327
                    for (j = 0; j < this.sections[i].questions.length; j++) {
-
 
328
                        if (slug_question == this.sections[i].questions[j].slug_question) {
-
 
329
                            $.each(this.sections[i].questions[j].options, function(index, option) {
-
 
330
                                if (position < option.position) {
-
 
331
                                    position = option.position;
-
 
332
                                }
-
 
333
                            });
-
 
334
                            position++;
-
 
335
                            var option = {
-
 
336
                                'slug_section': slug_section,
-
 
337
                                'slug_question': slug_question,
-
 
338
                                'slug_option': slug_option,
-
 
339
                                'text': text,
-
 
340
                                'correct': correct,
-
 
341
                                'value': value,
-
 
342
                                'checked': false
-
 
343
                            }
-
 
344
                            this.sections[i].questions[j].options.push(option);
-
 
345
                            renderTable = true;
-
 
346
                            break;
-
 
347
                        }
-
 
348
                        if (renderTable) {
-
 
349
                            break;
-
 
350
                        }
-
 
351
                    }
-
 
352
                }
-
 
353
            }
-
 
354
            if (renderTable) {
-
 
355
                this.renderSection(slug_section);
-
 
356
            }
-
 
357
        },
-
 
358
        /**
-
 
359
         * Edit element to option array
-
 
360
         */
-
 
361
        this.editOption = function(slug_section, slug_question, option_slug, text, correct, value) {
-
 
362
            var renderTable = false;
-
 
363
            for (i = 0; i < this.sections.length; i++) {
-
 
364
                if (slug_section == this.sections[i].slug_section) {
-
 
365
                    for (j = 0; j < this.sections[i].questions.length; j++) {
-
 
366
                        if (slug_question == this.sections[i].questions[j].slug_question) {
-
 
367
                            for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
-
 
368
                                if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
-
 
369
                                    this.sections[i].questions[j].options[k].text = text;
-
 
370
                                    this.sections[i].questions[j].options[k].correct = correct;
-
 
371
                                    this.sections[i].questions[j].options[k].value = value;
-
 
372
                                    renderTable = true;
-
 
373
                                    break;
-
 
374
                                }
-
 
375
                            }
-
 
376
                        }
-
 
377
                        if (renderTable) {
-
 
378
                            break;
-
 
379
                        }
-
 
380
                    }
-
 
381
                }
-
 
382
                if (renderTable) {
-
 
383
                    break;
-
 
384
                }
-
 
385
            }
-
 
386
            if (renderTable) {
-
 
387
                this.renderSection(slug_section);
-
 
388
            }
-
 
389
        },
-
 
390
        /**
-
 
391
         * Remove element to option array
-
 
392
         */
-
 
393
        this.deleteOption = function(slug_section, slug_question, option_slug) {
-
 
394
            var renderTable = false;
-
 
395
            for (i = 0; i < this.sections.length; i++) {
-
 
396
                if (slug_section == this.sections[i].slug_section) {
-
 
397
                    for (j = 0; j < this.sections[i].questions.length; j++) {
-
 
398
                        if (slug_question == this.sections[i].questions[j].slug_question) {
-
 
399
                            for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
-
 
400
                                if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
-
 
401
                                    this.sections[i].questions[j].options.splice(k, 1);
-
 
402
                                    renderTable = true;
-
 
403
                                    break;
-
 
404
                                }
-
 
405
                            }
-
 
406
                        }
-
 
407
                        if (renderTable) {
-
 
408
                            break;
-
 
409
                        }
-
 
410
                    }
-
 
411
                }
-
 
412
                if (renderTable) {
-
 
413
                    break;
-
 
414
                }
-
 
415
            }
-
 
416
            if (renderTable) {
-
 
417
                this.renderSection(slug_section);
-
 
418
            }
-
 
419
        }
194
        }
-
 
195
 
-
 
196
        
420
}
197
}
Línea 421... Línea 198...
421
 
198
 
422
function htmlEntities(str) {
199
function htmlEntities(str) {
423
    return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
200
    return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
Línea 600... Línea 377...
600
                objFormGenerator.clear();
377
                objFormGenerator.clear();
601
                objFormGenerator.sections = response['data']['content'] || [];
378
                objFormGenerator.sections = response['data']['content'] || [];
602
                objFormGenerator.render();
379
                objFormGenerator.render();
603
                renderSectionData(objFormGenerator.sections);
380
                renderSectionData(objFormGenerator.sections);
Línea 604... Línea 381...
604
                
381
                
605
                $('#row-forms').hide();
382
                $('#row-reviews').hide();
606
                $('#row-edit').show();
383
                $('#row-edit').show();
Línea 607... Línea 384...
607
                $('#form-main #form-name').focus();
384
                $('#form-main #form-name').focus();
608
 
385
 
Línea 805... Línea 582...
805
                            $('#form-main').attr('action',response['action_edit']);
582
                            $('#form-main').attr('action',response['action_edit']);
806
                            $('#form-main #form-id').val(response['id']);
583
                            $('#form-main #form-id').val(response['id']);
807
                            $('#form-main #form-continue').val(0);
584
                            $('#form-main #form-continue').val(0);
808
                        } else {
585
                        } else {
809
                            $('#row-edit').hide();
586
                            $('#row-edit').hide();
810
                            $('#row-forms').show();
587
                            $('#row-reviews').show();
811
                        /*---------- Reset Form -------- */
588
                        /*---------- Reset Form -------- */
812
                        $('#form-main')[0].reset();
589
                        $('#form-main')[0].reset();
813
                        /*--------Reset Ckeditor ----------*/
590
                        /*--------Reset Ckeditor ----------*/
814
                        CKEDITOR.instances['form-text'].setData('');
591
                        CKEDITOR.instances['form-text'].setData('');
815
                        CKEDITOR.instances['form-description'].setData('');
592
                        CKEDITOR.instances['form-description'].setData('');
Línea 869... Línea 646...
869
        $('#form-main #form-name').val('');
646
        $('#form-main #form-name').val('');
870
        $('#form-main #form-language').val('$lang_es'),
647
        $('#form-main #form-language').val('$lang_es'),
871
        $('#form-main #form-status').val('$status_inactive');
648
        $('#form-main #form-status').val('$status_inactive');
872
        CKEDITOR.instances['form-text'].setData('');
649
        CKEDITOR.instances['form-text'].setData('');
873
        CKEDITOR.instances['form-description'].setData('');
650
        CKEDITOR.instances['form-description'].setData('');
874
        $('#row-forms').hide();
651
        $('#row-reviews').hide();
875
        $('#row-edit').show();
652
        $('#row-edit').show();
876
        $('#form-main #form-name').focus();
653
        $('#form-main #form-name').focus();
877
    });
654
    });
878
    /**
655
    /**
879
     * Clicked cancel new/edit Form
656
     * Clicked cancel new/edit Form
880
     */
657
     */
881
    $('button.btn-edit-cancel').click(function(e) {
658
    $('button.btn-edit-cancel').click(function(e) {
882
        e.preventDefault();
659
        e.preventDefault();
883
        $('#row-edit').hide();
660
        $('#row-edit').hide();
884
        $('#row-forms').show();
661
        $('#row-reviews').show();
885
    });
662
    });
886
    /**
663
    /**
887
     * Clicked save and continue new Form
664
     * Clicked save and continue new Form
888
     */
665
     */
889
    $('button.btn-form-save-continue').click(function(e) {
666
    $('button.btn-form-save-continue').click(function(e) {
Línea 960... Línea 737...
960
        </div>
737
        </div>
961
    </div>
738
    </div>
962
    <!-- /.container-fluid -->
739
    <!-- /.container-fluid -->
963
</section>
740
</section>
964
<section class="content">
741
<section class="content">
965
    <div class="container-fluid" id="row-forms">
742
    <div class="container-fluid" id="row-reviews">
966
        <div class="row">
743
        <div class="row">
967
            <div class="col-12">
744
            <div class="col-12">
968
                <div class="card">
745
                <div class="card">
969
                    <div class="card-body">
746
                    <div class="card-body">
970
                        <table id="gridTable" class="table   table-hover">
747
                        <table id="gridTable" class="table   table-hover">