Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 14213 Rev 16817
Línea 11... Línea 11...
11
$allowAdd = $acl->isAllowed($roleName, 'survey/form/add') ? 1 : 0;
11
$allowAdd = $acl->isAllowed($roleName, 'survey/form/add') ? 1 : 0;
12
$allowEdit = $acl->isAllowed($roleName, 'survey/form/edit') ? 1 : 0;
12
$allowEdit = $acl->isAllowed($roleName, 'survey/form/edit') ? 1 : 0;
13
$allowDelete = $acl->isAllowed($roleName, 'survey/form/delete') ? 1 : 0;
13
$allowDelete = $acl->isAllowed($roleName, 'survey/form/delete') ? 1 : 0;
Línea 14... Línea 14...
14
 
14
 
Línea 15... Línea 15...
15
 
15
 
16
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
16
//$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
Línea 60... Línea 60...
60
$this->headLink()->appendStylesheet($this->basePath('css/pages/self-evaluation.css'));
60
$this->headLink()->appendStylesheet($this->basePath('css/pages/self-evaluation.css'));
Línea 61... Línea 61...
61
 
61
 
62
$status_active = \LeadersLinked\Model\SurveyForm::STATUS_ACTIVE;
62
$status_active = \LeadersLinked\Model\SurveyForm::STATUS_ACTIVE;
Línea -... Línea 63...
-
 
63
$status_inactive = \LeadersLinked\Model\SurveyForm::STATUS_INACTIVE;
-
 
64
 
-
 
65
$this->headStyle()->captureStart();
-
 
66
echo <<<CSS
-
 
67
[data-toggle="collapse"] .fa:before {   
-
 
68
  content: "\f139";
-
 
69
}
-
 
70
 
-
 
71
[data-toggle="collapse"].collapsed .fa:before {
-
 
72
  content: "\f13a";
-
 
73
}
-
 
74
CSS;
-
 
75
$this->headStyle()->captureEnd();
63
$status_inactive = \LeadersLinked\Model\SurveyForm::STATUS_INACTIVE;
76
 
64
 
77
 
65
$this->inlineScript()->captureStart();
78
$this->inlineScript()->captureStart();
66
echo <<<JS
79
echo <<<JS
67
    const classFormGenerator = function() {
80
    const FormGenerator = function() {
68
    this.id = 0,
81
        this.uuid   = 0,
69
        this.table = '',
82
        this.table  = '',
70
        this.name = '',
83
        this.name   = '',
71
        this.text = '',
84
        this.text   = '',
-
 
85
        this.status     = '$status_active',
-
 
86
        this.sections   = []
-
 
87
 
72
        this.status = 'a',
88
    }
-
 
89
 
73
        this.sections = [],
90
    FormGenerator.prototype.isValid = function() {
74
        this.clear = function() {
91
 
75
            this.sections = [];
-
 
76
            this.render();
-
 
77
        },
92
        if(this.sections.length == 0) {
78
        /**
93
            $.fn.showError('ERROR_QUESTIONARY_NOT_SECTIONS');
-
 
94
            return false;        
-
 
95
        }
79
         * Render array sections
96
 
80
         */
-
 
-
 
97
        
81
        this.renderSection = function(slug_section) {
98
        for (i = 0; i < this.sections.length; i++) {
82
            var s = '';
99
 
83
            for (i = 0; i < this.sections.length; i++) {
100
            if(this.sections[i].questions.length == 0) {
84
                if (slug_section != this.sections[i].slug_section) {
101
                $.fn.showError('ERROR_QUESTIONARY_QUESTIONS'.replace('%s', this.sections[i].name));
-
 
102
                return false;
85
                    continue;
103
            }
86
                }
-
 
87
                for (j = 0; j < this.sections[i].questions.length; j++) {
104
 
88
                    this.sections[i].questions[j].position = j;
105
            for (j = 0; j < this.sections[i].questions.length; j++) {
89
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
-
 
90
                        this.sections[i].questions[j].options.sort(function(a, b) {
106
                if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
91
                            if (a.position > b.position) {
-
 
92
                                return 1;
107
                    if (this.sections[i].questions[j].options.length == 0) {
93
                            }
108
                        var questionNumber = j + 1;
94
                            if (a.position < b.position) {
109
                        $.fn.showError('ERROR_QUESTIONARY_OPTIONS'.replace('%s', this.sections[i].name).replace('%n', questionNumber));
-
 
110
                        return false;
95
                                return -1;
111
                    }
96
                            }
112
 
97
                            return 0;
113
                    if (this.sections[i].questions[j].options.length < 2) {
98
                        });
-
 
99
                        for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
114
                        var questionNumber = j + 1;
100
                            this.sections[i].questions[j].options[k].position = j;
115
                        $.fn.showError('ERROR_QUESTIONARY_MIN_TWO_OPTIONS'.replace('%s', this.sections[i].name).replace('%n', questionNumber));
-
 
116
                        return false;
-
 
117
                    }
101
                        }
118
   
102
                    }
119
 
-
 
120
                }
-
 
121
            }
-
 
122
 
-
 
123
        }
-
 
124
 
-
 
125
 
-
 
126
        return true;
-
 
127
 
-
 
128
    }
-
 
129
 
-
 
130
 
-
 
131
    FormGenerator.prototype.clear = function() {
-
 
132
        this.sections = [];
-
 
133
        this.render();
-
 
134
    }
-
 
135
 
-
 
136
 
103
                }
137
    FormGenerator.prototype.render = function() {
-
 
138
 
-
 
139
        $('#containter-sections').empty();
-
 
140
        this.sections.sort(function(a, b) {
-
 
141
            if (a.position > b.position) {
-
 
142
                return 1;
-
 
143
            } else if (a.position < b.position) {
-
 
144
                return -1;
-
 
145
            } else {
104
            }
146
                return 0;
-
 
147
            }
-
 
148
        });
105
            $('[data-toggle="tooltip"]').tooltip();
149
 
106
        },
150
        for (i = 0; i < this.sections.length; i++) {
107
        this.render = function() {
151
            this.sections[i].position = i;
108
            this.sections.sort(function(a, b) {
152
            this.sections[i].questions.sort(function(a, b) {
109
                if (a.position > b.position) {
-
 
110
                    return 1;
153
                if (a.position > b.position) {
111
                }
154
                    return 1;
-
 
155
                } else if (a.position < b.position) {
-
 
156
                    return -1;
112
                if (a.position < b.position) {
157
                } else { 
113
                    return -1;
-
 
114
                }
158
                    return 0;
115
                return 0;
-
 
116
            });
159
                }
117
            var s = '';
160
            });
-
 
161
            for (j = 0; j < this.sections[i].questions.length; j++) {
118
            for (i = 0; i < this.sections.length; i++) {
162
                this.sections[i].questions[j].position = j;
119
                this.sections[i].position = i;
163
                if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
120
                this.sections[i].questions.sort(function(a, b) {
164
                    this.sections[i].questions[j].options.sort(function(a, b) {
-
 
165
                        if (a.position > b.position) {
-
 
166
                            return 1;
121
                    if (a.position > b.position) {
167
                        } else if (a.position < b.position) {
122
                        return 1;
168
                            return -1;
123
                    }
169
                        } else { 
-
 
170
                            return 0;
-
 
171
                        }
-
 
172
                    });
124
                    if (a.position < b.position) {
173
                    for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
125
                        return -1;
174
                        this.sections[i].questions[j].options[k].position = j;
126
                    }
175
                    }
-
 
176
                }
-
 
177
            }
-
 
178
        }
-
 
179
 
-
 
180
        $('#containter-sections').html(
-
 
181
            $('#sectionTemplateAdd').render(this.sections)
-
 
182
        );
-
 
183
 
-
 
184
        $('[data-toggle="tooltip"]').tooltip();
-
 
185
    }
-
 
186
 
-
 
187
    FormGenerator.prototype.renderSection = function(slug_section) {
127
                    return 0;
188
        for (i = 0; i < this.sections.length; i++) {
128
                });
189
            if (slug_section == this.sections[i].slug_section) {
129
                for (j = 0; j < this.sections[i].questions.length; j++) {
190
                for (j = 0; j < this.sections[i].questions.length; j++) {
130
                    this.sections[i].questions[j].position = j;
191
                    this.sections[i].questions[j].position = j;
131
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
192
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
132
                        this.sections[i].questions[j].options.sort(function(a, b) {
193
                        this.sections[i].questions[j].options.sort(function(a, b) {
133
                            if (a.position > b.position) {
-
 
134
                                return 1;
194
                            if (a.position > b.position) {
135
                            }
195
                                return 1;
-
 
196
                            } else if (a.position < b.position) {
-
 
197
                                return -1;
136
                            if (a.position < b.position) {
198
                            } else {
137
                                return -1;
-
 
138
                            }
199
                                return 0;   
-
 
200
                            }
139
                            return 0;
201
                        });
140
                        });
202
                    }
141
                        for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
-
 
142
                            this.sections[i].questions[j].options[k].position = j;
203
                    for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
143
                        }
204
                        this.sections[i].questions[j].options[k].position = j;
144
                    }
-
 
145
                }
-
 
146
            }
205
                    }
147
            $('[data-toggle="tooltip"]').tooltip();
-
 
148
        },
-
 
149
        /**
206
                }
150
         * Add element to section array
-
 
151
         */
-
 
152
        this.addSection = function(name, text) {
207
 
153
            var d = new Date();
208
 
154
            var slug = 'section' + d.getTime();
-
 
155
            var position = 0;
209
                var element = $('#panel-' + slug_section);
156
            $.each(this.sections, function(index, section) {
210
                if(element.length == 0) {
157
                if (position < section.position) {
211
                    $('#containter-sections').append(
158
                    position = section.position;
-
 
159
                }
-
 
160
            });
-
 
161
            position++;
-
 
162
            var section = {
-
 
163
                'slug_section': slug,
-
 
164
                'name': name,
-
 
165
                'text': text,
-
 
166
                'position': position,
212
                        $('#sectionTemplateAdd').render(this.sections[i])
167
                'questions': [],
-
 
168
                'status': 0
-
 
169
            }
-
 
170
            this.sections.push(section);
-
 
171
        },
-
 
172
         /**
-
 
173
         * Edit element to section array
-
 
174
         */
-
 
175
        this.editSection = function(slug, name, text) {
-
 
176
            var renderTable = false;
213
                    );
177
            for (i = 0; i < this.sections.length; i++) {
-
 
178
                if (slug == this.sections[i].slug_section) {
214
                } else {
179
                    this.sections[i].name = name;
-
 
180
                    this.sections[i].text = text;
215
                    $('#panel-' + slug_section).html(
181
                    renderTable = true;
216
                        $('#sectionTemplateReplace').render(this.sections[i])
-
 
217
                    );
-
 
218
                }
-
 
219
                $('[data-toggle="tooltip"]').tooltip();
-
 
220
 
-
 
221
                break
182
                    break;
222
            } else {
-
 
223
                continue;
-
 
224
            }
-
 
225
            
-
 
226
        }
-
 
227
 
-
 
228
 
-
 
229
    }
183
                }
230
        
-
 
231
    FormGenerator.prototype.addSection = function(name, text) {
-
 
232
        var d = new Date();
-
 
233
        var slug = 'section' + d.getTime();
-
 
234
        var position = 0;
184
            }
235
        $.each(this.sections, function(index, section) {
185
            if (renderTable) {
236
            if (position < section.position) {
186
                this.renderSection(slug);
237
                position = section.position;
187
            }
238
            }
-
 
239
        });
-
 
240
        position++;
-
 
241
        var section = {
-
 
242
            'slug_section': slug,
188
        },
243
            'name': name,
-
 
244
            'text': text,
-
 
245
            'position': position,
189
         /**
246
            'questions': [],
190
         * Remove element to section array
247
            'status': 0
-
 
248
        }
-
 
249
        this.sections.push(section);
-
 
250
 
-
 
251
        return slug;
-
 
252
    }
191
         */
253
 
192
        this.deleteSection = function(slug) {
254
    FormGenerator.prototype.editSection = function(slug, name, text) {
193
            var renderTable = false;
255
        var renderTable = false;
194
            for (i = 0; i < this.sections.length; i++) {
256
        for (i = 0; i < this.sections.length; i++) {
195
                if (slug == this.sections[i].slug_section) {
257
            if (slug == this.sections[i].slug_section) {
196
                    this.sections.splice(i, 1);
258
                this.sections[i].name = name;
197
                    renderTable = true;
259
                this.sections[i].text = text;
198
                    break;
260
                renderTable = true;
-
 
261
                break;
199
                }
262
            }
-
 
263
        }
-
 
264
        if (renderTable) {
-
 
265
            this.renderSection(slug);
-
 
266
        }
-
 
267
    }
-
 
268
 
-
 
269
    FormGenerator.prototype.deleteSection = function(slug) {
-
 
270
        var renderTable = false;
200
            }
271
        for (i = 0; i < this.sections.length; i++) {
-
 
272
            if (slug == this.sections[i].slug_section) {
-
 
273
                this.sections.splice(i, 1);
201
            if (renderTable) {
274
                renderTable = true;
202
                $('#panel' + slug).remove();
275
                break;
203
            }
276
            }
204
        },
277
        }
205
         /**
278
        if (renderTable) {
-
 
279
            $('#panel-' + slug).remove();
-
 
280
        }
206
         * Add element to question array
281
    }
207
         */
282
 
208
        this.addQuestion = function(slug_section, text, type, maxlength, multiline, range) {
283
    FormGenerator.prototype.addQuestion = function(slug_section, text, type) {
209
            var d = new Date();
284
        var d = new Date();
210
            var slug_question = 'question' + d.getTime();
285
        var slug_question = 'question' + d.getTime();
211
            var position = 0;
286
        var position = 0;
212
            var renderTable = false;
287
        var renderTable = false;
213
            for (i = 0; i < this.sections.length; i++) {
288
        for (i = 0; i < this.sections.length; i++) {
214
                if (slug_section == this.sections[i].slug_section) {
289
            if (slug_section == this.sections[i].slug_section) {
215
                    $.each(this.sections[i].questions, function(index, question) {
290
                $.each(this.sections[i].questions, function(index, question) {
216
                        if (position < question.position) {
291
                    if (position < question.position) {
217
                            position = question.position;
292
                        position = question.position;
218
                        }
293
                    }
219
                    });
294
                });
220
                    position++;
295
                position++;
221
                    var question = {
296
                var question = {
222
                        'slug_section': slug_section,
297
                    'slug_section': slug_section,
223
                        'slug_question': slug_question,
298
                    'slug_question': slug_question,
224
                        'text': text,
299
                    'text': text,
225
                        'type': type,
-
 
226
                        'position': position,
-
 
227
                        'maxlength': maxlength,
-
 
228
                        'multiline': multiline,
300
                    'type': type,
229
                        'range': range,
-
 
230
                        'options': [],
-
 
231
                        'answer': type=='multiple' ? [] : ''
-
 
232
                    }
-
 
233
                    this.sections[i].questions.push(question);
-
 
234
                    renderTable = true;
301
                    'position': position,
-
 
302
                    'options': []
-
 
303
                }
-
 
304
                this.sections[i].questions.push(question);
235
                    break;
305
                renderTable = true;
-
 
306
                break;
236
                }
307
            }
237
            }
308
        }
238
            if (renderTable) {
-
 
239
                this.renderSection(slug_section);
309
        if (renderTable) {
240
            }
-
 
241
        },
-
 
242
         /**
310
            this.renderSection(slug_section);
243
         * Add element to question array
-
 
244
         */
-
 
245
        this.editQuestion = function(slug_section, slug_question, text, type, maxlength, multiline, range) {
-
 
246
            var renderTable = false;
-
 
247
            for (i = 0; i < this.sections.length; i++) {
-
 
248
                if (slug_section == this.sections[i].slug_section) {
-
 
249
                    for (j = 0; j < this.sections[i].questions.length; j++) {
-
 
250
                        if (slug_question == this.sections[i].questions[j].slug_question) {
-
 
251
                            this.sections[i].questions[j].text = text,
-
 
252
                                this.sections[i].questions[j].type = type;
-
 
253
                            if (type == 'open') {
-
 
254
                                this.sections[i].questions[j].maxlength = maxlength;
-
 
255
                                this.sections[i].questions[j].multiline = multiline;
-
 
256
                                this.sections[i].questions[j].options = [];
-
 
257
                            } else {
-
 
258
                                this.sections[i].questions[j].maxlength = 0;
-
 
259
                                this.sections[i].questions[j].multiline = 0;
-
 
260
                            }
-
 
261
                            if (type == 'rating-range') {
-
 
262
                                this.sections[i].questions[j].range = range;
-
 
263
                            } else {
-
 
Línea -... Línea 311...
-
 
311
        }
-
 
312
    }
264
                                this.sections[i].questions[j].range = 0;
313
 
-
 
314
    FormGenerator.prototype.editQuestion = function(slug_section, slug_question, text, type) {
265
                            }
315
        var renderTable = false;
266
 
316
        for (i = 0; i < this.sections.length; i++) {
267
                            if(type=='multiple'){
317
            if (slug_section == this.sections[i].slug_section) {
268
                                this.sections[i].questions[j].answer = [];  
318
                for (j = 0; j < this.sections[i].questions.length; j++) {
Línea 269... Línea 319...
269
                            }else{
319
                    if (slug_question == this.sections[i].questions[j].slug_question) {
270
                                this.sections[i].questions[j].answer = '';  
320
                        this.sections[i].questions[j].text = text,
271
                            }
-
 
272
 
321
                        this.sections[i].questions[j].type = type;
273
                            renderTable = true;
322
 
274
                            break;
-
 
275
                        }
-
 
276
                    }
-
 
277
                }
323
                        renderTable = true;
278
                if (renderTable) {
324
                        break;
279
                    break;
325
                    }
280
                }
326
                }
281
            }
327
            }
282
            if (renderTable) {
328
            if (renderTable) {
283
                this.renderSection(slug_section);
329
                break;
284
            }
330
            }
-
 
331
        }
-
 
332
        if (renderTable) {
285
        },
333
            this.renderSection(slug_section);
286
        /**
334
        }
287
         * Remove element to question array
335
    }
288
         */
336
 
289
        this.deleteQuestion = function(slug_section, slug_question) {
337
    FormGenerator.prototype.deleteQuestion = function(slug_section, slug_question) {
290
            var renderTable = false;
338
        var renderTable = false;
291
            for (i = 0; i < this.sections.length; i++) {
339
        for (i = 0; i < this.sections.length; i++) {
292
                if (slug_section == this.sections[i].slug_section) {
340
            if (slug_section == this.sections[i].slug_section) {
293
                    for (j = 0; j < this.sections[i].questions.length; j++) {
341
                for (j = 0; j < this.sections[i].questions.length; j++) {
294
                        if (slug_question == this.sections[i].questions[j].slug_question) {
-
 
295
                            this.sections[i].questions.splice(j, 1);
342
                    if (slug_question == this.sections[i].questions[j].slug_question) {
296
                            renderTable = true;
343
                        this.sections[i].questions.splice(j, 1);
297
                            break;
-
 
298
                        }
-
 
299
                    }
-
 
300
                }
344
                        renderTable = true;
301
                if (renderTable) {
345
                        break;
302
                    break;
346
                    }
303
                }
347
                }
304
            }
348
            }
305
            if (renderTable) {
349
            if (renderTable) {
306
                this.renderSection(slug_section);
350
                break;
307
            }
351
            }
-
 
352
        }
-
 
353
        if (renderTable) {
308
        },
354
            this.renderSection(slug_section);
309
        /**
355
        }
310
         * Add element to option array
356
    }
311
         */
357
 
312
        this.addOption = function(slug_section, slug_question, text) {
358
    FormGenerator.prototype.addOption = function(slug_section, slug_question, text) {
313
            var d = new Date();
359
        var d = new Date();
314
            var slug_option = 'option' + d.getTime();
360
        var slug_option = 'option' + d.getTime();
315
            var position = 0;
361
        var position = 0;
316
            var renderTable = false;
362
        var renderTable = false;
317
            for (i = 0; i < this.sections.length; i++) {
363
        for (i = 0; i < this.sections.length; i++) {
318
                if (slug_section == this.sections[i].slug_section) {
364
            if (slug_section == this.sections[i].slug_section) {
319
                    for (j = 0; j < this.sections[i].questions.length; j++) {
365
                for (j = 0; j < this.sections[i].questions.length; j++) {
320
                        if (slug_question == this.sections[i].questions[j].slug_question) {
-
 
321
                            $.each(this.sections[i].questions[j].options, function(index, option) {
-
 
322
                                if (position < option.position) {
-
 
323
                                    position = option.position;
-
 
324
                                }
-
 
325
                            });
-
 
326
                            position++;
-
 
327
                            var option = {
-
 
328
                                'slug_section': slug_section,
-
 
329
                                'slug_question': slug_question,
366
                    if (slug_question == this.sections[i].questions[j].slug_question) {
-
 
367
                        $.each(this.sections[i].questions[j].options, function(index, option) {
330
                                'slug_option': slug_option,
368
                            if (position < option.position) {
331
                                'text': text,
369
                                position = option.position;
332
                                'checked': false
370
                            }
-
 
371
                        });
333
                            }
372
                        position++;
334
                            this.sections[i].questions[j].options.push(option);
373
                        var option = {
335
                            renderTable = true;
374
                            'slug_section': slug_section,
336
                            break;
375
                            'slug_question': slug_question,
-
 
376
                            'slug_option': slug_option,
-
 
377
                            'text': text,
-
 
378
                            'checked': false
-
 
379
                        }
-
 
380
                        this.sections[i].questions[j].options.push(option);
-
 
381
                        renderTable = true;
337
                        }
382
                        break;
338
                        if (renderTable) {
383
                    }
339
                            break;
384
                    if (renderTable) {
-
 
385
                        break;
340
                        }
386
                    }
341
                    }
387
                }
342
                }
-
 
343
            }
388
            }
344
            if (renderTable) {
389
        }
345
                this.renderSection(slug_section);
-
 
346
            }
390
        if (renderTable) {
347
        },
391
            this.renderSection(slug_section);
348
        /**
392
        }
349
         * Edit element to option array
393
    }
350
         */
394
 
351
        this.editOption = function(slug_section, slug_question, option_slug, text) {
395
    FormGenerator.prototype.editOption = function(slug_section, slug_question, option_slug, text) {
352
            var renderTable = false;
396
        var renderTable = false;
353
            for (i = 0; i < this.sections.length; i++) {
397
        for (i = 0; i < this.sections.length; i++) {
354
                if (slug_section == this.sections[i].slug_section) {
398
            if (slug_section == this.sections[i].slug_section) {
355
                    for (j = 0; j < this.sections[i].questions.length; j++) {
399
                for (j = 0; j < this.sections[i].questions.length; j++) {
356
                        if (slug_question == this.sections[i].questions[j].slug_question) {
400
                    if (slug_question == this.sections[i].questions[j].slug_question) {
357
                            for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
401
                        for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
358
                                if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
-
 
359
                                    this.sections[i].questions[j].options[k].text = text;
402
                            if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
360
                                    renderTable = true;
403
                                this.sections[i].questions[j].options[k].text = text;
361
                                    break;
-
 
362
                                }
-
 
363
                            }
-
 
364
                        }
404
                                renderTable = true;
365
                        if (renderTable) {
405
                                break;
366
                            break;
406
                            }
367
                        }
407
                        }
368
                    }
408
                    }
369
                }
409
                    if (renderTable) {
370
                if (renderTable) {
410
                        break;
371
                    break;
411
                    }
372
                }
412
                }
373
            }
413
            }
374
            if (renderTable) {
414
            if (renderTable) {
375
                this.renderSection(slug_section);
415
                break;
376
            }
416
            }
-
 
417
        }
-
 
418
        if (renderTable) {
377
        },
419
            this.renderSection(slug_section);
378
        /**
420
        }
379
         * Remove element to option array
421
    }
380
         */
422
 
381
        this.deleteOption = function(slug_section, slug_question, option_slug) {
423
    FormGenerator.prototype.deleteOption = function(slug_section, slug_question, option_slug) {
382
            var renderTable = false;
424
        var renderTable = false;
383
            for (i = 0; i < this.sections.length; i++) {
425
        for (i = 0; i < this.sections.length; i++) {
384
                if (slug_section == this.sections[i].slug_section) {
426
            if (slug_section == this.sections[i].slug_section) {
385
                    for (j = 0; j < this.sections[i].questions.length; j++) {
427
                for (j = 0; j < this.sections[i].questions.length; j++) {
386
                        if (slug_question == this.sections[i].questions[j].slug_question) {
428
                    if (slug_question == this.sections[i].questions[j].slug_question) {
387
                            for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
429
                        for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
388
                                if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
-
 
389
                                    this.sections[i].questions[j].options.splice(k, 1);
430
                            if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
390
                                    renderTable = true;
431
                                this.sections[i].questions[j].options.splice(k, 1);
391
                                    break;
-
 
392
                                }
-
 
393
                            }
-
 
394
                        }
432
                                renderTable = true;
395
                        if (renderTable) {
433
                                break;
396
                            break;
434
                            }
397
                        }
435
                        }
398
                    }
436
                    }
399
                }
437
                    if (renderTable) {
400
                if (renderTable) {
438
                        break;
401
                    break;
439
                    }
402
                }
440
                }
403
            }
441
            }
-
 
442
            if (renderTable) {
-
 
443
                break;
-
 
444
            }
-
 
445
        }
404
            if (renderTable) {
446
        if (renderTable) {
Línea 405... Línea -...
405
                this.renderSection(slug_section);
-
 
406
            }
-
 
407
        }
-
 
408
}
447
            this.renderSection(slug_section);
409
 
448
        }
410
function htmlEntities(str) {
449
    }
-
 
450
 
-
 
451
 
411
    return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
452
jQuery(document).ready(function($) {
412
}
453
    var objFormGenerator = new FormGenerator();
413
jQuery(document).ready(function($) {
-
 
414
    var objFormGenerator = new classFormGenerator();
-
 
415
    objFormGenerator.render();
454
    objFormGenerator.render();
416
    var allowEdit = $allowEdit;
455
 
417
    var allowDelete = $allowDelete;
456
 
418
    /**
457
    var allowEdit = $allowEdit;
419
     * Get rows and set data table
458
    var allowDelete = $allowDelete;
420
     */
459
    
421
    var tableForm = $('#gridTable').dataTable({
460
    var tableForm = $('#tableForm').dataTable({
Línea 521... Línea 560...
521
        'columnDefs': [{
560
        'columnDefs': [{
522
                'targets': 0,
561
                'targets': 0,
523
                'className': 'text-vertical-middle',
562
                'className': 'text-vertical-middle',
524
            },
563
            },
525
            {
564
            {
526
                'targets': 1,
-
 
527
                'className': 'text-vertical-middle',
-
 
528
            },
-
 
529
            {
-
 
530
                'targets': -2,
565
                'targets': -2,
531
                'orderable': false,
566
                'orderable': false,
532
                'className': 'text-center',
567
                'className': 'text-center',
533
                'render': function(data, type, row) {
568
                'render': function(data, type, row) {
534
                    checked = data == 'A' ? ' checked="checked" ' : '';
569
                    checked = data == '$status_active' ? ' checked="checked" ' : '';
535
                    return '<div class="checkbox checkbox-success">' +
570
                    return '<div class="checkbox checkbox-success">' +
536
                        '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
571
                        '<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
537
                        '<label ></label></div>';
572
                        '<label ></label></div>';
538
                }
573
                }
539
            },
574
            },
Línea 551... Línea 586...
551
                    return s;
586
                    return s;
552
                }
587
                }
553
            }
588
            }
554
        ],
589
        ],
555
    });
590
    });
556
    /**
-
 
557
     * Clicked on edit form
-
 
558
     */
591
 
559
    $('body').on('click', 'button.btn-edit-form', function(e) {
592
    $('body').on('click', 'button.btn-edit-form', function(e) {
560
        e.preventDefault();
593
        e.preventDefault();
561
        form_id = $(this).data('id')
594
        form_id = $(this).data('id')
562
        var action = $(this).data('href');
595
        var action = $(this).data('href');
563
        $.ajax({
596
        $.ajax({
Línea 570... Línea 603...
570
                validatorForm.resetForm();
603
                validatorForm.resetForm();
571
                $('#form-main').attr('action', action);
604
                $('#form-main').attr('action', action);
572
                $('#form-main #form-id').val(response['data']['id']),
605
                $('#form-main #form-id').val(response['data']['id']),
573
                $('#form-main #form-continue').val('0');
606
                $('#form-main #form-continue').val('0');
574
                $('#form-main #name').val(response['data']['name']),
607
                $('#form-main #name').val(response['data']['name']),
-
 
608
                $('#form-main #text').val(response['data']['text']),
-
 
609
                $('#form-main #status').bootstrapToggle(response['data']['status'] == '$status_active' ? 'on' : 'off')
Línea 575... Línea -...
575
 
-
 
576
                /*----------Set Ckeditor ------------*/
-
 
577
                CKEDITOR.instances.description.setData(response['data']['description']);
-
 
578
                CKEDITOR.instances.text.setData(response['data']['text']);
-
 
579
 
-
 
Línea 580... Línea -...
580
                $('#form-main #status').val(response['data']['status']);
-
 
581
 
-
 
582
                /*-------------Render Sections -------*/
610
 
583
               
611
 
584
                objFormGenerator.clear();
612
                objFormGenerator.clear();
585
                objFormGenerator.sections = response['data']['content'] || [];
-
 
Línea 586... Línea 613...
586
                objFormGenerator.render();
613
                objFormGenerator.sections = response['data']['content'] || [];
587
                renderSectionData(objFormGenerator.sections);
614
                objFormGenerator.render();
588
               
615
               
Línea 595... Línea 622...
595
            }
622
            }
596
        }).fail(function(jqXHR, textStatus, errorThrown) {
623
        }).fail(function(jqXHR, textStatus, errorThrown) {
597
            $.fn.showError(textStatus);
624
            $.fn.showError(textStatus);
598
        });
625
        });
599
    });
626
    });
600
    $(document).on('click', '[data-type="select_all"]', function() {
-
 
601
        if ($('input[name="select_all"]:checked').val() == 'all') {
-
 
602
            $('[data-type="select"]').prop('checked', true);
-
 
603
            $('[data-action="delete"]').removeClass('hide');
-
 
604
        } else {
-
 
605
            $('[data-type="select"]').prop('checked', false);
-
 
606
            $('[data-action="delete"]').addClass('hide');
-
 
607
        }
-
 
608
    });
-
 
609
 
-
 
610
    function getLength() {
-
 
611
        return $('[data-type="select"]').length;
-
 
612
    }
-
 
Línea 613... Línea 627...
613
 
627
 
614
    function currentSelected() {
628
    $.validator.setDefaults({
615
        var selected = [];
629
        debug: true,
616
        $.each($("input[name='select[]']:checked"), function() {
630
        highlight: function(element) {
617
            selected.push($(this).val());
631
            $(element).addClass('is-invalid');
618
        });
-
 
619
        return selected;
-
 
620
    }
-
 
621
    $(document).on('change', "input[name='select[]']", function() {
632
        },
622
        var c = currentSelected();
-
 
623
        var cc = getLength();
-
 
624
        if (c.length == cc) {
-
 
625
            if ($('[data-action="delete"]').hasClass('hide')) {
633
        unhighlight: function(element) {
626
                $('[data-action="delete"]').removeClass('hide');
634
            $(element).removeClass('is-invalid');
627
            }
635
        },
628
            return true;
636
        errorElement: 'span',
629
        } else {
637
        errorClass: 'error invalid-feedback',
630
            $('input[name="select_all"]').prop('checked', false);
638
        errorPlacement: function(error, element) {
631
        }
639
            if (element.parent('.form-group').length) {
632
        if (c.length > 0) {
640
                error.insertAfter(element);
633
            if ($('[data-action="delete"]').hasClass('hide')) {
641
            } else if (element.parent('.toggle').length) {
634
                $('[data-action="delete"]').removeClass('hide');
-
 
635
            }
642
                error.insertAfter(element.parent().parent());
636
        } else {
-
 
637
            if (!$('[data-action="delete"]').hasClass('hide')) {
643
            } else {
638
                $('[data-action="delete"]').addClass('hide');
644
                error.insertAfter(element.parent());
639
            }
645
            }
640
        }
646
        }
-
 
647
    });
641
    });
648
 
642
    var form3 = $('#form_sample_3');
-
 
643
    var error3 = $('.alert-danger', form3);
-
 
644
    var success3 = $('.alert-success', form3);
-
 
645
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
-
 
646
    $("#form-main").on('submit', function() {
-
 
647
        for (var instanceName in CKEDITOR.instances) {
-
 
648
            CKEDITOR.instances[instanceName].updateElement();
649
    var validatorForm = $('#form-main').validate({
649
        }
-
 
650
    })
-
 
651
    /**
650
        debug: true,
652
     * Validate rules form
-
 
653
     */
651
        onclick: false,
654
    var validatorForm = $("#form-main").validate({
652
        onkeyup: false,
655
        ignore: [],
-
 
656
        errorClass: 'help-block',
-
 
657
        errorElement: 'span',
653
        ignore: [],
658
        rules: {
654
        rules: {
659
            'form-name': {
655
            'name': {
660
                required: true,
656
                required: true,
661
                minlength: 2,
657
                minlength: 2,
662
                maxlength: 50
-
 
663
            },
-
 
664
            'description':{
-
 
665
                updateCkeditor:function() {
-
 
666
                    CKEDITOR.instances.description.updateElement();
-
 
667
                },
658
                maxlength: 128
668
            },
659
            },
669
            'text':{
-
 
670
                updateCkeditor:function() {
-
 
671
                    CKEDITOR.instances.text.updateElement();
660
            'text':{
672
                },
661
                required: true
673
            },
662
            },
674
            'forrm-status': {
663
            'status': {
675
                required: true,
664
                required: false,
676
            },
665
            },
677
        },
666
        },
678
        highlight: function(element) {
667
        highlight: function(element) {
679
            $(element).closest('.form-group').addClass('has-error');
668
            $(element).closest('.form-group').addClass('has-error');
Línea 686... Línea 675...
686
                error.appendTo(element.attr("data-error-container"));
675
                error.appendTo(element.attr("data-error-container"));
687
            } else {
676
            } else {
688
                error.insertAfter(element);
677
                error.insertAfter(element);
689
            }
678
            }
690
        },
679
        },
691
        invalidHandler: function(form, validator) {
-
 
692
            if (!validator.numberOfInvalids())
-
 
693
                return;
-
 
694
            $('html, body').animate({
-
 
695
                scrollTop: $(validator.errorList[0].element).offset().top - 100
-
 
696
            }, 1000);
-
 
697
        },
-
 
698
        submitHandler: function(form) {
680
        submitHandler: function(form) {
699
            var error = false;
-
 
-
 
681
 
700
            if (objFormGenerator.sections.length == 0) {
682
            if(!objFormGenerator.isValid()) {
701
                $.fn.showError('ERROR_SECCTIONS');
-
 
702
                return false;
683
                return false;
703
            } else {
-
 
704
                for (i = 0; i < objFormGenerator.sections.length; i++) {
-
 
705
                    if (objFormGenerator.sections[i].questions.length == 0) {
-
 
706
                        $.fn.showError('ERROR_QUESTIONS'.replace('%s', objFormGenerator.sections[i].name));
-
 
707
                        return false;
-
 
708
                    }
-
 
709
                    for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
-
 
710
                        if (objFormGenerator.sections[i].questions[j].type == 'simple' ||
-
 
711
                            objFormGenerator.sections[i].questions[j].type == 'multiple' ||
-
 
712
                            objFormGenerator.sections[i].questions[j].type == 'rating-open') {
-
 
713
                            var questionNumber = j + 1;
-
 
714
                            var numberCorrect = 0;
-
 
715
                            if (objFormGenerator.sections[i].questions[j].options.length == 0) {
-
 
716
                                $.fn.showError('ERROR_OPTIONS'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
-
 
717
                                return false;
-
 
718
                            }
-
 
719
                            var totalOption = 0;
-
 
720
                            var maxOption = 0;
-
 
721
                        }
-
 
722
                    }
-
 
723
                }
684
            }
724
                var formContinue = parseInt($('#form-main #form-continue').val());
-
 
725
                var data = {
-
 
726
                    'name': $('#form-main #name').val(),
-
 
727
                    'description': $('#form-main #description').val(),
-
 
728
                    'text': $('#form-main #text').val(),
-
 
729
                    'status': $('#form-main #status').val(),
-
 
730
                    'content': JSON.stringify(objFormGenerator.sections)
-
 
731
                }
-
 
732
                $.ajax({
-
 
733
                    'dataType': 'json',
-
 
734
                    'method': 'post',
-
 
735
                    'url': $('#form-main').attr('action'),
-
 
736
                    'data': data,
-
 
737
                }).done(function(response) {
-
 
738
                    if (response['success']) {
-
 
739
                        $.fn.showSuccess(response['data']);
-
 
740
                        if (formContinue == 1) {
-
 
741
                            $('#form-main').attr('action',response['action_edit']);
-
 
742
                            $('#form-main #form-id').val(response['id']);
-
 
743
                            $('#form-main #form-continue').val(0);
-
 
744
                        } else {
-
 
745
                            $('#row-edit').hide();
-
 
746
                            $('#row-forms').show();
-
 
747
                        /*---------- Reset Form -------- */
-
 
748
                        $('#form-main')[0].reset();
-
 
749
                        /*--------Reset Ckeditor ----------*/
-
 
750
                        CKEDITOR.instances.text.setData('');
-
 
751
                        CKEDITOR.instances.description.setData('');
-
 
752
                        /*--------Reset Sections ----------*/
-
 
753
                        clearSectionData();
-
 
754
                        /* ------- Refresh Table -----------*/
-
 
Línea -... Línea 685...
-
 
685
 
-
 
686
            var status = $('#form-main #status').prop('checked') ? '$status_active' : '$status_inactive';    
755
 
687
            var formContinue = parseInt($('#form-main #form-continue').val());
-
 
688
            var data = {
-
 
689
                'name': $('#form-main #name').val(),
-
 
690
                'text': $('#form-main #text').val(),
-
 
691
                'status': status,
-
 
692
                'content': JSON.stringify(objFormGenerator.sections)
-
 
693
            }
-
 
694
 
-
 
695
            $.ajax({
-
 
696
                'dataType': 'json',
-
 
697
                'method': 'post',
-
 
698
                'url': $('#form-main').attr('action'),
-
 
699
                'data': data,
-
 
700
            }).done(function(response) {
-
 
701
                if (response['success']) {
756
                        }
702
                    $.fn.showSuccess(response['data']['message']);
-
 
703
                    if (formContinue == 1) {
-
 
704
                        $('#form-main').attr('action',response['data']['action']);
757
                        tableForm.fnDraw();
705
                        $('#form-main #form-continue').val(0);
758
                    } else {
706
                    } else {
-
 
707
                        tableForm.api().ajax.reload(null, false);
-
 
708
 
-
 
709
                        $('#row-edit').hide();
-
 
710
                        $('#row-forms').show();
759
                        $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
711
                        
-
 
712
                    }
-
 
713
 
-
 
714
                    
-
 
715
 
-
 
716
                } else {
-
 
717
                    $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
760
                    }
718
                }
761
                }).fail(function(jqXHR, textStatus, errorThrown) {
719
            }).fail(function(jqXHR, textStatus, errorThrown) {
762
                    $.fn.showError(textStatus);
720
                $.fn.showError(textStatus);
763
                });
721
            });
764
                return false;
-
 
765
            }
722
            return false;
766
        }
723
        }
767
    });
-
 
768
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
-
 
769
    $("#form-section").on('submit', function() {
-
 
770
        for (var instanceName in CKEDITOR.instances) {
-
 
771
            CKEDITOR.instances[instanceName].updateElement();
-
 
772
        }
724
    });
773
    })
-
 
774
    /**
-
 
775
     * Validate rules form section
-
 
776
     */
725
 
-
 
726
    var validatorFormSection = $("#form-section").validate({
-
 
727
        debug: true,
-
 
728
        onclick: false,
777
    var validatorFormSection = $("#form-section").validate({
729
        onkeyup: false,
778
        ignore: [],
-
 
779
        errorClass: 'help-block',
-
 
780
        errorElement: 'span',
730
        ignore: [],
781
        rules: {
731
        rules: {
782
            'section-name': {
732
            'section-name': {
783
                required: true,
733
                required: true,
784
                minlength: 2,
734
                minlength: 2,
785
                maxlength: 50
735
                maxlength: 50
786
            },
736
            },
787
            'section-text': {
737
            'section-text': {
788
                required: false,
738
                required: false,
789
            },
739
            },
790
        },
-
 
791
        highlight: function(element) {
-
 
792
            $(element).closest('.form-group').addClass('has-error');
-
 
793
        },
-
 
794
        unhighlight: function(element) {
-
 
795
            $(element).closest('.form-group').removeClass('has-error');
-
 
796
        },
-
 
797
        errorPlacement: function(error, element) {
-
 
798
            if (element.attr("data-error-container")) {
-
 
799
                error.appendTo(element.attr("data-error-container"));
-
 
800
            } else {
-
 
801
                error.insertAfter(element);
-
 
802
            }
-
 
803
        },
-
 
804
        invalidHandler: function(form, validator) {
-
 
805
            if (!validator.numberOfInvalids())
-
 
806
                return;
-
 
807
            $('html, body').animate({
-
 
808
                scrollTop: $(validator.errorList[0].element).offset().top - 100
-
 
809
            }, 1000);
-
 
810
        },
740
        },
811
        submitHandler: function(form) {
741
        submitHandler: function(form) {
812
            // do other things for a valid form
742
            // do other things for a valid form
813
            //form.submit();
743
            //form.submit();
814
            var slug = $('#form-section #section-slug').val();
744
            var slug = $('#form-section #section-slug').val();
Línea 817... Línea 747...
817
                    $('#form-section #section-slug').val(),
747
                    $('#form-section #section-slug').val(),
818
                    $('#form-section #section-name').val(),
748
                    $('#form-section #section-name').val(),
819
                    $('#form-section #section-text').val(),
749
                    $('#form-section #section-text').val(),
820
                );
750
                );
821
            } else {
751
            } else {
822
                objFormGenerator.addSection(
752
                slug = objFormGenerator.addSection(
823
                    $('#form-section #section-name').val(),
753
                    $('#form-section #section-name').val(),
824
                    $('#form-section #section-text').val()
754
                    $('#form-section #section-text').val()
825
                );
755
                );
826
            }
756
            }
-
 
757
         
827
            renderSectionData(objFormGenerator.sections);
758
            objFormGenerator.renderSection(slug);
828
            $('#modal-section').modal('hide');
759
            $('#modal-section').modal('hide');
829
            return false;
760
            return false;
830
        }
761
        }
831
    });
762
    });
832
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
-
 
833
    $("#form-question").on('submit', function() {
-
 
834
        for (var instanceName in CKEDITOR.instances) {
-
 
835
            CKEDITOR.instances[instanceName].updateElement();
-
 
836
        }
-
 
837
    })
763
 
838
    /**
-
 
839
     * Validate rules form Questions
-
 
840
     */
-
 
841
    var validatorFormQuestion = $("#form-question").validate({
764
    var validatorFormQuestion = $("#form-question").validate({
-
 
765
        debug: true,
-
 
766
        onclick: false,
-
 
767
        onkeyup: false,
842
        ignore: [],
768
        ignore: [],
843
        errorClass: 'help-block',
-
 
844
        errorElement: 'span',
-
 
845
        rules: {
769
        rules: {
846
            'question-text': {
770
            'question-text': {
847
                required: true,
771
                required: true,
848
            },
772
            },
849
            'question-type': {
773
            'question-type': {
850
                required: true,
774
                required: true,
851
            },
775
            },
852
            'question-max-length': {
-
 
853
                required: true,
-
 
854
                digits: true,
-
 
855
                min: 0
-
 
856
            },
-
 
857
            'question-range': {
-
 
858
                required: true,
-
 
859
                number: true,
-
 
860
                min: 1
-
 
861
            },
-
 
862
        },
-
 
863
        highlight: function(element) {
-
 
864
            $(element).closest('.form-group').addClass('has-error');
-
 
865
        },
-
 
866
        unhighlight: function(element) {
-
 
867
            $(element).closest('.form-group').removeClass('has-error');
-
 
868
        },
-
 
869
        errorPlacement: function(error, element) {
-
 
870
            if (element.attr("data-error-container")) {
-
 
871
                error.appendTo(element.attr("data-error-container"));
-
 
872
            } else {
-
 
873
                error.insertAfter(element);
-
 
874
            }
-
 
875
        },
-
 
876
        invalidHandler: function(form, validator) {
-
 
877
            if (!validator.numberOfInvalids())
-
 
878
                return;
-
 
879
            $('html, body').animate({
-
 
880
                scrollTop: $(validator.errorList[0].element).offset().top - 100
-
 
881
            }, 1000);
-
 
882
        },
776
        },
883
        submitHandler: function(form) {
777
        submitHandler: function(form) {
-
 
778
 
884
            if ($('#form-question #question-slug').val()) {
779
            if ($('#form-question #question-slug').val()) {
885
                objFormGenerator.editQuestion(
780
                objFormGenerator.editQuestion(
886
                    $('#form-question #question-section').val(),
781
                    $('#form-question #question-section').val(),
887
                    $('#form-question #question-slug').val(),
782
                    $('#form-question #question-slug').val(),
888
                    $('#form-question #question-text').val(),
783
                    $('#form-question #question-text').val(),
889
                    $('#form-question #question-type').val(),
784
                    $('#form-question #question-type').val()
890
                    $('#form-question #question-max-length').val(),
-
 
891
                    $('#form-question #question-multiline').val(),
-
 
892
                    $('#form-question #question-range').val()
-
 
893
                );
785
                );
894
            } else {
786
            } else {
895
                objFormGenerator.addQuestion(
787
                objFormGenerator.addQuestion(
896
                    $('#form-question #question-section').val(),
788
                    $('#form-question #question-section').val(),
897
                    $('#form-question #question-text').val(),
789
                    $('#form-question #question-text').val(),
898
                    $('#form-question #question-type').val(),
790
                    $('#form-question #question-type').val()
899
                    $('#form-question #question-max-length').val(),
-
 
900
                    $('#form-question #question-multiline').val(),
-
 
901
                    $('#form-question #question-range').val()
-
 
902
                );
791
                );
903
            }
792
            }
904
            renderSectionData(objFormGenerator.sections);
793
            objFormGenerator.renderSection($('#form-question #question-section').val());
905
            $('#modal-question').modal('hide');
794
            $('#modal-question').modal('hide');
906
            return false;
795
            return false;
907
        }
796
        }
908
    });
797
    });
909
    //IMPORTANT: update CKEDITOR textarea with actual content before submit
-
 
910
    $("#form-option").on('submit', function() {
-
 
911
        for (var instanceName in CKEDITOR.instances) {
-
 
912
            CKEDITOR.instances[instanceName].updateElement();
-
 
913
        }
-
 
914
    })
798
 
915
    /**
-
 
916
     * Validate rules form options
-
 
917
     */
-
 
918
    var validatorFormOption = $("#form-option").validate({
799
    var validatorFormOption = $("#form-option").validate({
-
 
800
        debug: true,
-
 
801
        onclick: false,
-
 
802
        onkeyup: false,
919
        ignore: [],
803
        ignore: [],
920
        errorClass: 'help-block',
-
 
921
        errorElement: 'span',
-
 
922
        rules: {
804
        rules: {
923
            'option-text': {
805
            'option-text': {
924
                required: true,
806
                required: true,
925
            }
807
            }
Línea 926... Línea 808...
926
           
808
           
927
        },
-
 
928
        highlight: function(element) {
-
 
929
            $(element).closest('.form-group').addClass('has-error');
-
 
930
        },
-
 
931
        unhighlight: function(element) {
-
 
932
            $(element).closest('.form-group').removeClass('has-error');
-
 
933
        },
-
 
934
        errorPlacement: function(error, element) {
-
 
935
            if (element.attr("data-error-container")) {
-
 
936
                error.appendTo(element.attr("data-error-container"));
-
 
937
            } else {
-
 
938
                error.insertAfter(element);
-
 
939
            }
-
 
940
        },
-
 
941
        invalidHandler: function(form, validator) {
-
 
942
            if (!validator.numberOfInvalids())
-
 
943
                return;
-
 
944
            $('html, body').animate({
-
 
945
                scrollTop: $(validator.errorList[0].element).offset().top - 100
-
 
946
            }, 1000);
-
 
947
        },
809
        },
948
        submitHandler: function(form) {
810
        submitHandler: function(form) {
949
            if ($('#form-option #option-slug').val()) {
811
            if ($('#form-option #option-slug').val()) {
950
                objFormGenerator.editOption(
812
                objFormGenerator.editOption(
951
                    $('#form-option #option-section').val(),
813
                    $('#form-option #option-section').val(),
Línea 958... Línea 820...
958
                    $('#form-option #option-section').val(),
820
                    $('#form-option #option-section').val(),
959
                    $('#form-option #option-question').val(),
821
                    $('#form-option #option-question').val(),
960
                    $('#form-option #option-text').val()
822
                    $('#form-option #option-text').val()
961
                );
823
                );
962
            }
824
            }
963
            renderSectionData(objFormGenerator.sections);
825
            objFormGenerator.renderSection($('#form-option #option-section').val());
964
            $('#modal-option').modal('hide');
826
            $('#modal-option').modal('hide');
965
            return false;
827
            return false;
966
        }
828
        }
967
    });
829
    });
968
    /**
-
 
969
     * Clicked on add new section
-
 
970
     */
830
 
971
    $('body').on('click', 'button[id="btn-add-section"]', function(e) {
831
    $('body').on('click', 'button[id="btn-add-section"]', function(e) {
972
        e.preventDefault();
832
        e.preventDefault();
973
        validatorFormSection.resetForm();
833
        validatorFormSection.resetForm();
-
 
834
       
974
        $('#form-section #section-slug').val('');
835
        $('#form-section #section-slug').val('');
975
        $('#form-section #section-name').val('');
836
        $('#form-section #section-name').val('');
976
        CKEDITOR.instances['section-text'].setData('');
837
        $('#form-section #section-text').val('');
977
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
838
        $('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
978
        $('#modal-section').modal('show');
839
        $('#modal-section').modal('show');
979
    });
840
    });
980
    /**
-
 
981
     * Clicked on edit section
-
 
982
     */
841
 
983
    $('body').on('click', 'button.btn-edit-section', function(e) {
842
    $('body').on('click', 'button.btn-edit-section', function(e) {
984
        e.preventDefault();
843
        e.preventDefault();
985
        var slug = $(this).data('section');
844
        var slug = $(this).data('section');
986
        var section;
845
        var section;
987
        var showForm = false;
846
        var showForm = false;
Línea 989... Línea 848...
989
            section = objFormGenerator.sections[i];
848
            section = objFormGenerator.sections[i];
990
            if (slug == section.slug_section) {
849
            if (slug == section.slug_section) {
991
                validatorFormSection.resetForm();
850
                validatorFormSection.resetForm();
992
                $('#form-section #section-slug').val(section.slug_section);
851
                $('#form-section #section-slug').val(section.slug_section);
993
                $('#form-section #section-name').val(section.name);
852
                $('#form-section #section-name').val(section.name);
994
                CKEDITOR.instances['section-text'].setData(section.text);
853
                $('#form-section #section-text').val(section.text);
995
                showForm = true;
854
                showForm = true;
996
                break;
855
                break;
997
            }
856
            }
998
        }
857
        }
999
        if (showForm) {
858
        if (showForm) {
1000
            $('#modal-section h4[class="modal-title"]').html('LABEL_EDIT LABEL_SECTION');
859
            $('#modal-section h4[class="modal-title"]').html('LABEL_EDIT LABEL_SECTION');
1001
            $('#modal-section').modal('show');
860
            $('#modal-section').modal('show');
1002
        }
861
        }
1003
    });
862
    });
1004
    /**
-
 
1005
     * Clicked on remove section
-
 
1006
     */
863
 
1007
    $('body').on('click', 'button.btn-delete-section', function(e) {
864
    $('body').on('click', 'button.btn-delete-section', function(e) {
1008
        e.preventDefault();
865
        e.preventDefault();
1009
        var slug = $(this).data('section');
866
        var slug = $(this).data('section');
1010
        bootbox.confirm({
867
        bootbox.confirm({
1011
            title: "LABEL_DELETE LABEL_SECTION",
868
            title: "LABEL_DELETE LABEL_SECTION",
Línea 1019... Línea 876...
1019
                }
876
                }
1020
            },
877
            },
1021
            callback: function(result) {
878
            callback: function(result) {
1022
                if (result) {
879
                if (result) {
1023
                    objFormGenerator.deleteSection(slug);
880
                    objFormGenerator.deleteSection(slug);
1024
                    renderSectionData(objFormGenerator.sections);
-
 
1025
                }
881
                }
1026
            }
882
            }
1027
        });
883
        });
1028
    });
884
    });
1029
    /**
-
 
1030
     * Clicked add new question
-
 
1031
     */
885
 
1032
    $('body').on('click', 'button.btn-add-question', function(e) {
886
    $('body').on('click', 'button.btn-add-question', function(e) {
1033
        e.preventDefault();
887
        e.preventDefault();
1034
        validatorFormQuestion.resetForm();
888
        validatorFormQuestion.resetForm();
1035
        var slug = $(this).data('section');
889
        var slug = $(this).data('section');
1036
        $('#form-question #question-section').val(slug);
890
        $('#form-question #question-section').val(slug);
1037
        $('#form-question #question-slug').val('');
891
        $('#form-question #question-slug').val('');
1038
        CKEDITOR.instances['question-text'].setData('');
892
        $('#form-question #question-text').val('');
1039
        $('#form-question #question-type').val($('#form-question #question-type option:first').val());
893
        $('#form-question #question-type').val($('#form-question #question-type option:first').val());
1040
        $('#form-question #question-max-length').val('0');
-
 
1041
        $('#form-question #question-max-length').parent().show();
-
 
1042
        $('#form-question #question-multiline').val('0');
-
 
1043
        $('#form-question #question-multiline').parent().show();
-
 
1044
        $('#form-question #question-range').val('10');
-
 
1045
        $('#form-question #question-range').parent().hide();
-
 
1046
        $('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
894
        $('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
1047
        $('#modal-question').modal('show');
895
        $('#modal-question').modal('show');
1048
    });
896
    });
1049
    /**
-
 
1050
     * Clicked edit question
-
 
1051
     */
897
 
1052
    $('body').on('click', 'button.btn-edit-question', function(e) {
898
    $('body').on('click', 'button.btn-edit-question', function(e) {
1053
        e.preventDefault();
899
        e.preventDefault();
1054
        var slug_section = $(this).data('section');
900
        var slug_section = $(this).data('section');
1055
        var slug = $(this).data('question');
901
        var slug = $(this).data('question');
1056
        var showForm = false;
902
        var showForm = false;
Línea 1059... Línea 905...
1059
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
905
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1060
                    if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
906
                    if (slug == objFormGenerator.sections[i].questions[j].slug_question) {
1061
                        validatorFormQuestion.resetForm();
907
                        validatorFormQuestion.resetForm();
1062
                        $('#form-question #question-section').val(objFormGenerator.sections[i].slug_section);
908
                        $('#form-question #question-section').val(objFormGenerator.sections[i].slug_section);
1063
                        $('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug_question);
909
                        $('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug_question);
1064
                        CKEDITOR.instances['question-text'].setData(objFormGenerator.sections[i].questions[j].text);
910
                        $('#form-question #question-text').val(objFormGenerator.sections[i].questions[j].text);
1065
                        $('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
911
                        $('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
1066
                        if (objFormGenerator.sections[i].questions[j].type == 'open') {
-
 
1067
                            $('#form-question #question-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
-
 
1068
                            $('#form-question #question-max-length').parent().show();
-
 
1069
                            $('#form-question #question-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
-
 
1070
                            $('#form-question #question-multiline').parent().show();
-
 
1071
                        } else {
-
 
1072
                            $('#form-question #question-max-length').val('0');
-
 
1073
                            $('#form-question #question-max-length').parent().hide();
-
 
1074
                            $('#form-question #question-multiline').val('0');
-
 
1075
                            $('#form-question #question-multiline').parent().hide();
-
 
1076
                        }
-
 
1077
                        if (objFormGenerator.sections[i].questions[j].type == 'rating-range') {
-
 
-
 
912
 
1078
                            $('#form-question #question-range').val(objFormGenerator.sections[i].questions[j].range);
-
 
1079
                            $('#form-question #question-range').parent().show();
-
 
1080
                        } else {
-
 
1081
                            $('#form-question #question-range').val('10');
-
 
1082
                            $('#form-question #question-range').parent().hide();
-
 
1083
                        }
-
 
1084
                        showForm = true;
913
                        showForm = true;
1085
                        break;
914
                        break;
1086
                    }
915
                    }
1087
                }
916
                }
1088
                break;
917
                break;
Línea 1091... Línea 920...
1091
        if (showForm) {
920
        if (showForm) {
1092
            $('#modal-question h4[class="modal-title"]').html('LABEL_EDIT LABEL_QUESTION');
921
            $('#modal-question h4[class="modal-title"]').html('LABEL_EDIT LABEL_QUESTION');
1093
            $('#modal-question').modal('show');
922
            $('#modal-question').modal('show');
1094
        }
923
        }
1095
    });
924
    });
1096
    /**
-
 
1097
     * Clicked remove question
-
 
1098
     */
925
 
1099
    $('body').on('click', 'button.btn-delete-question', function(e) {
926
    $('body').on('click', 'button.btn-delete-question', function(e) {
1100
        e.preventDefault();
927
        e.preventDefault();
1101
        var slug_section = $(this).data('section');
928
        var slug_section = $(this).data('section');
1102
        var slug = $(this).data('question');
929
        var slug = $(this).data('question');
1103
        bootbox.confirm({
930
        bootbox.confirm({
Línea 1112... Línea 939...
1112
                }
939
                }
1113
            },
940
            },
1114
            callback: function(result) {
941
            callback: function(result) {
1115
                if (result) {
942
                if (result) {
1116
                    objFormGenerator.deleteQuestion(slug_section, slug);
943
                    objFormGenerator.deleteQuestion(slug_section, slug);
1117
                    renderSectionData(objFormGenerator.sections);
-
 
1118
                }
944
                }
1119
            }
945
            }
1120
        });
946
        });
1121
    });
947
    });
1122
    /**
-
 
1123
     * Clicked add new Option
-
 
1124
     */
948
 
1125
    $('body').on('click', 'button.btn-add-option', function(e) {
949
    $('body').on('click', 'button.btn-add-option', function(e) {
1126
        e.preventDefault();
950
        e.preventDefault();
1127
        var slug_section = $(this).data('section');
951
        var slug_section = $(this).data('section');
1128
        var slug_question = $(this).data('question');
952
        var slug_question = $(this).data('question');
1129
        var showForm = false;
953
        var showForm = false;
Línea 1133... Línea 957...
1133
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
957
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
1134
                        validatorFormOption.resetForm();
958
                        validatorFormOption.resetForm();
1135
                        $('#form-option #option-section').val(slug_section);
959
                        $('#form-option #option-section').val(slug_section);
1136
                        $('#form-option #option-question').val(slug_question);
960
                        $('#form-option #option-question').val(slug_question);
1137
                        $('#form-option #option-slug').val('');
961
                        $('#form-option #option-slug').val('');
1138
                        CKEDITOR.replace('option-text', {
962
                        $('#form-option #option-text').val('');
1139
                            toolbar: [
-
 
1140
                                        { name: 'editing', items: ['Scayt'] },
-
 
1141
                                        { name: 'links', items: ['Link', 'Unlink'] },
-
 
1142
                                        { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
-
 
1143
                                        { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
-
 
1144
                                        '/',
-
 
1145
                                        { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
-
 
1146
                                        { name: 'styles', items: ['Styles', 'Format'] },
-
 
1147
                                        { name: 'tools', items: ['Maximize'] }
-
 
1148
                                    ],
-
 
1149
                                    removePlugins: 'elementspath,Anchor',
-
 
1150
                                    heigth: 100
-
 
1151
                        })
-
 
1152
                        CKEDITOR.instances['option-text'].setData('', function() {
-
 
1153
                            editor.focus();
-
 
1154
                        });
-
 
1155
                       
963
 
1156
                        renderSectionData(objFormGenerator.sections);
-
 
1157
                        $('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
964
                        $('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
1158
                        $('#modal-option').modal('show');
965
                        $('#modal-option').modal('show');
1159
                        return true;
966
                        return true;
1160
                    }
967
                    }
1161
                }
968
                }
1162
            }
969
            }
1163
        }
970
        }
1164
    });
971
    });
1165
    /**
972
 
1166
     * Clicked edit option
-
 
1167
     */
973
 
1168
    $('body').on('click', 'button.btn-edit-option', function(e) {
974
    $('body').on('click', 'button.btn-edit-option', function(e) {
1169
        e.preventDefault();
975
        e.preventDefault();
1170
        var slug_section = $(this).data('section');
976
        var slug_section = $(this).data('section');
1171
        var slug_question = $(this).data('question');
977
        var slug_question = $(this).data('question');
1172
        var slug = $(this).data('slug');
978
        var slug = $(this).data('slug');
Línea 1179... Línea 985...
1179
                            if (slug == objFormGenerator.sections[i].questions[j].options[k].slug_option) {
985
                            if (slug == objFormGenerator.sections[i].questions[j].options[k].slug_option) {
1180
                                validatorFormOption.resetForm();
986
                                validatorFormOption.resetForm();
1181
                                $('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
987
                                $('#form-option #option-section').val(objFormGenerator.sections[i].slug_section);
1182
                                $('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug_question);
988
                                $('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug_question);
1183
                                $('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
989
                                $('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
1184
                                CKEDITOR.instances['option-text'].setData(objFormGenerator.sections[i].questions[j].options[k].text,
990
                                $('#form-option #option-text').val(objFormGenerator.sections[i].questions[j].options[k].text);
1185
                                    function() {
-
 
1186
                                        editor.focus();
-
 
1187
                                    });
-
 
1188
                                showForm = true;
991
                                showForm = true;
1189
                                break;
992
                                break;
1190
                            }
993
                            }
1191
                        }
994
                        }
1192
                    }
995
                    }
Línea 1202... Línea 1005...
1202
        if (showForm) {
1005
        if (showForm) {
1203
            $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
1006
            $('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
1204
            $('#modal-option').modal('show');
1007
            $('#modal-option').modal('show');
1205
        }
1008
        }
1206
    });
1009
    });
1207
    /**
1010
 
1208
     * Clicked remove option
-
 
1209
     */
1011
 
1210
    $('body').on('click', 'button.btn-delete-option', function(e) {
1012
    $('body').on('click', 'button.btn-delete-option', function(e) {
1211
        e.preventDefault();
1013
        e.preventDefault();
1212
        var slug_section = $(this).data('section');
1014
        var slug_section = $(this).data('section');
1213
        var slug_question = $(this).data('question');
1015
        var slug_question = $(this).data('question');
1214
        var slug = $(this).data('slug');
1016
        var slug = $(this).data('slug');
Línea 1224... Línea 1026...
1224
                }
1026
                }
1225
            },
1027
            },
1226
            callback: function(result) {
1028
            callback: function(result) {
1227
                if (result) {
1029
                if (result) {
1228
                    objFormGenerator.deleteOption(slug_section, slug_question, slug);
1030
                    objFormGenerator.deleteOption(slug_section, slug_question, slug);
1229
                    renderSectionData(objFormGenerator.sections);
-
 
1230
                }
1031
                }
1231
            }
1032
            }
1232
        });
1033
        });
1233
    })
1034
    })
1234
  
1035
 
1235
    /**
-
 
1236
     * Format input number (Form Question)
-
 
1237
     */
-
 
1238
    $('#form-question #question-max-length').inputNumberFormat({
-
 
1239
        'decimal': 0
-
 
1240
    });
-
 
1241
    /**
-
 
1242
     * Detect when updating question status and hide/Show options
-
 
1243
     */
-
 
1244
    $('#form-question #question-type').change(function(e) {
-
 
1245
        e.preventDefault();
-
 
1246
        if ($('#form-question #question-type').val() == 'open') {
-
 
1247
            $('#form-question #question-max-length').parent().show();
-
 
1248
            $('#form-question #question-multiline').parent().show();
-
 
1249
        } else {
-
 
1250
            $('#form-question #question-max-length').val('0');
-
 
1251
            $('#form-question #question-max-length').parent().hide();
-
 
1252
            $('#form-question #question-multiline').val('0');
-
 
1253
            $('#form-question #question-multiline').parent().hide();
-
 
1254
        }
-
 
1255
        $('#form-question #question-range').val('10');
-
 
1256
        if ($('#form-question #question-type').val() == 'rating-range') {
-
 
1257
            $('#form-question #question-range').parent().show();
-
 
1258
        } else {
-
 
1259
            $('#form-question #question-range').parent().hide();
-
 
1260
        }
-
 
1261
    });
-
 
1262
    /**
-
 
1263
     * Clicked new Form
-
 
1264
     */
1036
 
1265
    $('button.btn-add-form').click(function(e) {
1037
    $('button.btn-add-form').click(function(e) {
1266
        e.preventDefault();
1038
        e.preventDefault();
1267
        objFormGenerator.clear();
1039
        objFormGenerator.clear();
1268
        objFormGenerator.render();
1040
        objFormGenerator.render();
1269
        validatorForm.resetForm();
1041
        validatorForm.resetForm();
1270
        clearSectionData();
-
 
-
 
1042
      
1271
        $('#form-main').attr('action', '$routeAdd');
1043
        $('#form-main').attr('action', '$routeAdd');
1272
        $('#form-main #form-continue').val('0');
1044
        $('#form-main #form-continue').val('0');
1273
        $('#form-main #name').val('');
1045
        $('#form-main #name').val('');
1274
        $('#form-main #status').val('$status_inactive');
1046
        $('#form-main #status').bootstrapToggle('on')
1275
        CKEDITOR.instances.text.setData('');
1047
        $('#form-main #text').val('');
1276
        CKEDITOR.instances.description.setData('');
-
 
1277
        $('#row-forms').hide();
1048
        $('#row-forms').hide();
1278
        $('#row-edit').show();
1049
        $('#row-edit').show();
1279
        $('#form-main #name').focus();
1050
        $('#form-main #name').focus();
-
 
1051
 
1280
    });
1052
    });
1281
    /**
-
 
1282
     * Clicked cancel new/edit Form
-
 
1283
     */
1053
 
1284
    $('button.btn-edit-cancel').click(function(e) {
1054
    $('#btn-edit-cancel').click(function(e) {
1285
        e.preventDefault();
1055
        e.preventDefault();
-
 
1056
 
-
 
1057
         tableForm.api().ajax.reload(null, false);
-
 
1058
 
1286
        $('#row-edit').hide();
1059
        $('#row-edit').hide();
1287
        $('#row-forms').show();
1060
        $('#row-forms').show();
-
 
1061
 
-
 
1062
       
1288
    });
1063
    });
1289
    /**
1064
 
1290
     * Clicked save and continue new Form
-
 
1291
     */
1065
 
1292
    $('button.btn-form-save-continue').click(function(e) {
1066
    $('#btn-form-save-continue').click(function(e) {
1293
        e.preventDefault();
1067
        e.preventDefault();
1294
        $('#form-main #form-continue').val('1')
1068
        $('#form-main #form-continue').val('1')
1295
        $('#form-main').submit();
1069
        $('#form-main').submit();
1296
    });
1070
    });
1297
    /**
1071
 
1298
     * Clicked save and close new/edit Form
-
 
1299
     */
1072
 
1300
    $('button.btn-form-save-close').click(function(e) {
1073
    $('#btn-form-save-close').click(function(e) {
1301
        e.preventDefault();
1074
        e.preventDefault();
-
 
1075
 
1302
        $('#form-main #form-continue').val('0')
1076
        $('#form-main #form-continue').val('0')
1303
        $('#form-main').submit();
1077
        $('#form-main').submit();
1304
    });
1078
    });
Línea 1305... Línea -...
1305
 
-
 
1306
    const saveData = (action) => {
-
 
1307
       
-
 
1308
            $.ajax({
-
 
1309
                'dataType': 'json',
-
 
1310
                'method': 'post',
-
 
1311
                'url': $('#form-main').attr('action'),
-
 
1312
                'data': {
-
 
1313
                    'name': $('#form-main #form-name').val(),
-
 
1314
                   
-
 
1315
                    'status': $('#form-main #form-status').val(),
-
 
1316
                    'description': $('#form-main #form-description').val(),
-
 
1317
                    'content': JSON.stringify(sections)
-
 
1318
                },
-
 
1319
            }).done(function(response) {
-
 
1320
                if (response['success']) {
-
 
1321
                    $.fn.showSuccess(response['data']);
-
 
1322
                    if (action == 1) {
-
 
1323
                        $('#form-main').attr('action', response['action_edit']);
-
 
1324
                    } else {
-
 
1325
                        $('#row-form').hide();
-
 
1326
                        $('#row-lists').show();
-
 
1327
                        /*---------- Reset Form -------- */
-
 
1328
                        $('#form-main')[0].reset();
-
 
1329
                        /*--------Reset Sections ----------*/
-
 
1330
                        sections = [];
-
 
1331
                        tableForm.fnDraw();
-
 
1332
                    }
-
 
1333
                    return;
-
 
1334
                } else {
-
 
1335
                    $.fn.showError(response['message'] || 'ERROR_UNKNOWN');
-
 
1336
                    return;
-
 
1337
                }
-
 
1338
            });
-
 
1339
        
-
 
Línea 1340... Línea -...
1340
    }
-
 
1341
 
-
 
1342
    /**
-
 
1343
     * Modal Settings
1079
 
1344
     */
1080
 
1345
    $('#modal-section, #modal-question, #modal-option').modal({
1081
    $('#modal-section, #modal-question, #modal-option').modal({
1346
        backdrop: 'static',
1082
        backdrop: 'static',
1347
        keyboard: false,
1083
        keyboard: false,
1348
        show: false
-
 
1349
    });
-
 
1350
    /**
-
 
1351
     * Get Question type
-
 
1352
     */
-
 
1353
    const getQuestionTypeBySlug = (slug_section, slug_question) => {
-
 
1354
        for (i = 0; i < objFormGenerator.sections.length; i++) {
-
 
1355
            if (slug_section == objFormGenerator.sections[i].slug_section) {
-
 
1356
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
-
 
1357
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
-
 
1358
                        return objFormGenerator.sections[i].questions[j].type;
-
 
1359
                    }
-
 
1360
                }
-
 
1361
            }
-
 
1362
        }
-
 
1363
    }
-
 
1364
    /**
-
 
1365
     * Remove Html Tags
-
 
1366
     */
-
 
1367
    const removeTags = (str) => str.toString().replace( /(<([^>]+)>)/ig, '')
-
 
1368
    /**
-
 
1369
     * Render Sections data
-
 
1370
     */
-
 
1371
    const renderSectionData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
-
 
1372
        getType: getQuestionTypeBySlug,
-
 
1373
        removeTags: removeTags
-
 
1374
    }));
1084
        show: false
1375
 
-
 
1376
 
-
 
1377
    /**
-
 
1378
     * Clear Div Section data
-
 
1379
     */
-
 
1380
    const clearSectionData = () => $("#rows").html('');
-
 
1381
    /**
-
 
1382
     * Clicked refresh button
1085
    });
1383
     */
1086
 
1384
    $('button.btn-refresh').click(function(e) {
1087
    $('button.btn-refresh').click(function(e) {
Línea 1385... Línea -...
1385
        tableForm.fnDraw();
-
 
1386
    });
-
 
1387
 
-
 
1388
    CKEDITOR.replace('description', {
-
 
1389
        toolbar: [
-
 
1390
                    { name: 'editing', items: ['Scayt'] },
-
 
1391
                    { name: 'links', items: ['Link', 'Unlink'] },
-
 
1392
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
-
 
1393
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
-
 
1394
                    '/',
-
 
1395
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
-
 
1396
                    { name: 'styles', items: ['Styles', 'Format'] },
-
 
1397
                    { name: 'tools', items: ['Maximize'] }
-
 
1398
                ],
1088
        tableForm.api().ajax.reload(null, false);
1399
                removePlugins: 'elementspath,Anchor',
1089
    });
1400
                heigth: 100
-
 
1401
    });
-
 
1402
 
-
 
1403
    CKEDITOR.replace('text', {
-
 
1404
        toolbar: [
1090
 
1405
                    { name: 'editing', items: ['Scayt'] },
-
 
1406
                    { name: 'links', items: ['Link', 'Unlink'] },
-
 
1407
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
-
 
1408
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
-
 
1409
                    '/',
-
 
1410
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
-
 
1411
                    { name: 'styles', items: ['Styles', 'Format'] },
-
 
1412
                    { name: 'tools', items: ['Maximize'] }
-
 
1413
                ],
-
 
1414
                removePlugins: 'elementspath,Anchor',
1091
 
1415
                heigth: 100
1092
    
1416
    });
1093
    $('#form-main #status').bootstrapToggle({'on' : 'LABEL_ACTIVE',  'off' : 'LABEL_INACTIVE', 'width' : '160px', 'height' : '40px'});
1417
     
1094
 
1418
});
1095
});
Línea 1419... Línea 1096...
1419
JS;
1096
JS;
1420
$this->inlineScript()->captureEnd();
1097
$this->inlineScript()->captureEnd();
1421
?>
1098
?>
1422
 
1099
 
1423
<!-- Content Header (Page header) -->
1100
<!-- Content Header (Page header) -->
1424
<section class="content-header">
1101
<section class="content-header">
1425
    <div class="container-fluid">
1102
    <div class="container-fluid">
1426
        <div class="row mb-2">
1103
        <div class="row mb-2">
1427
            <div class="col-sm-12">
1104
            <div class="col-sm-12">
1428
                <h1>LABEL_SELF_EVALUATION_FORMS</h1>
1105
                <h1>LABEL_FORM_BUILDER</h1>
1429
            </div>
1106
            </div>
Línea 1435... Línea 1112...
1435
    <div class="container-fluid" id="row-forms">
1112
    <div class="container-fluid" id="row-forms">
1436
        <div class="row">
1113
        <div class="row">
1437
            <div class="col-12">
1114
            <div class="col-12">
1438
                <div class="card">
1115
                <div class="card">
1439
                    <div class="card-body">
1116
                    <div class="card-body">
1440
                        <table id="gridTable" class="table   table-hover">
1117
                        <table id="tableForm" class="table   table-hover">
1441
                            <thead>
1118
                            <thead>
1442
                                <tr>
1119
                                <tr>
1443
                                    <th>LABEL_NAME</th>
1120
                                    <th>LABEL_NAME</th>
1444
                                    <th>LABEL_ACTIVE</th>
1121
                                    <th>LABEL_ACTIVE</th>
1445
                                    <th>LABEL_ACTIONS</th>
1122
                                    <th>LABEL_ACTIONS</th>
Línea 1463... Línea 1140...
1463
 
1140
 
Línea 1464... Línea 1141...
1464
    <!-- Create/Edit Form -->
1141
    <!-- Create/Edit Form -->
1465
 
1142
 
1466
    <div class="row" id="row-edit" style="display: none">
1143
    <div class="row" id="row-edit" style="display: none">
1467
        <div class="col-xs-12 col-md-12">
-
 
1468
            <form action="#" name="form-main" id="form-main">
1144
        <div class="col-xs-12 col-md-12">
1469
                <input type="hidden" name="form-id" id="form-id" value="0" />
-
 
1470
                <input type="hidden" name="form-continue" id="form-continue" value="0" />
-
 
1471
                <?php
-
 
1472
                //$form = $this->formAdd;
-
 
1473
                $form->setAttributes([
-
 
1474
                    'method' => 'post',
-
 
1475
                    'name' => 'form-main',
-
 
1476
                    'action' => $routeAdd,
-
 
1477
                    'id' => 'form-main'
-
 
1478
                ]);
-
 
1479
                $form->prepare();
-
 
-
 
1145
            <form name="form-main" id="form-main">
1480
                echo $this->form()->openTag($form);
1146
                <input type="hidden" name="form-continue" id="form-continue" value="0" />
1481
                ?>
1147
                
1482
                <div class="form-group">
1148
                <div class="form-group">
1483
                    <?php
1149
                    <?php
1484
                    $element = $form->get('name');
1150
                    $element = $form->get('name');
1485
                    $element->setOptions(['label' => 'LABEL_FIRST_NAME']);
1151
                    $element->setOptions(['label' => 'LABEL_NAME']);
1486
                    $element->setAttributes(['class' => 'form-control']);
1152
                    $element->setAttributes(['class' => 'form-control']);
1487
                    echo $this->formLabel($element);
1153
                    echo $this->formLabel($element);
1488
                    echo $this->formText($element);
1154
                    echo $this->formText($element);
1489
                    ?>
-
 
1490
                </div>
-
 
1491
                <div class="form-group">
-
 
1492
                    <?php
-
 
1493
                    $element = $form->get('description');
-
 
1494
                    $element->setOptions(['label' => 'LABEL_DESCRIPTION']);
-
 
1495
                    $element->setAttributes(['class' => 'form-control']);
-
 
1496
                    echo $this->formLabel($element);
-
 
1497
                    echo $this->formTextArea($element);
-
 
-
 
1155
                    ?>
1498
                    ?>
1156
                </div>
1499
                </div>
1157
 
1500
                <div class="form-group">
1158
                <div class="form-group">
1501
                    <?php
1159
                    <?php
1502
                    $element = $form->get('text');
1160
                    $element = $form->get('text');
Línea 1510... Línea 1168...
1510
                    <?php
1168
                    <?php
1511
                    $element = $form->get('status');
1169
                    $element = $form->get('status');
1512
                    $element->setAttributes(['class' => 'form-control']);
1170
                    $element->setAttributes(['class' => 'form-control']);
1513
                    $element->setOptions(['label' => 'LABEL_STATUS']);
1171
                    $element->setOptions(['label' => 'LABEL_STATUS']);
1514
                    echo $this->formLabel($element);
1172
                    echo $this->formLabel($element);
-
 
1173
                    echo '<br>';    
1515
                    echo $this->formSelect($element);
1174
                    echo $this->formCheckbox($element);
1516
                    ?>
1175
                    ?>
1517
                </div>
1176
                </div>
1518
                <br />
1177
                <br />
1519
                <div class="row">
1178
                <div class="row">
1520
                    <div class="col-xs-12 col-md-12 text-right">
1179
                    <div class="col-xs-12 col-md-12 text-right">
Línea 1522... Línea 1181...
1522
                    </div>
1181
                    </div>
1523
                </div>
1182
                </div>
1524
                <br />
1183
                <br />
1525
                <div class="row">
1184
                <div class="row">
1526
                    <div class="col-xs-12 col-md-12">
1185
                    <div class="col-xs-12 col-md-12">
1527
                        <div class="panel-group" id="rows"></div>
1186
                        <div class="panel-group" id="containter-sections"></div>
1528
                    </div>
1187
                    </div>
1529
                </div>
1188
                </div>
1530
                <div class="form-group">
1189
                <div class="form-group">
1531
                    <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
1190
                    <button type="button" id="btn-form-save-continue" class="btn btn-info ">LABEL_SAVE & LABEL_CONTINUE</button>
1532
                    <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
1191
                    <button type="button" id="btn-form-save-close" class="btn btn-primary ">LABEL_SAVE & LABEL_CLOSE</button>
1533
                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
1192
                    <button type="button" id="btn-edit-cancel" class="btn btn-secondary ">LABEL_CANCEL</button>
1534
                </div>
1193
                </div>
1535
            </form>
1194
            </form>
1536
        </div>
1195
        </div>
1537
    </div>
1196
    </div>
Línea 1557... Línea 1216...
1557
                        </div>
1216
                        </div>
1558
                        <div class="form-group">
1217
                        <div class="form-group">
1559
                            <label for="section-text">LABEL_TEXT</label>
1218
                            <label for="section-text">LABEL_TEXT</label>
1560
                            <!--  ckeditor -->
1219
                            <!--  ckeditor -->
1561
                            <textarea name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
1220
                            <textarea name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
1562
                            <script>
-
 
1563
                                CKEDITOR.replace('section-text', {
-
 
1564
                                    toolbar: [{
-
 
1565
                                            name: 'editing',
-
 
1566
                                            items: ['Scayt']
-
 
1567
                                        },
-
 
1568
                                        {
-
 
1569
                                            name: 'links',
-
 
1570
                                            items: ['Link', 'Unlink']
-
 
1571
                                        },
-
 
1572
                                        {
-
 
1573
                                            name: 'paragraph',
-
 
1574
                                            items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote']
-
 
1575
                                        },
-
 
1576
                                        {
-
 
1577
                                            name: 'basicstyles',
-
 
1578
                                            items: ['Bold', 'Italic', 'Strike', 'RemoveFormat']
-
 
1579
                                        },
-
 
1580
                                        '/',
-
 
1581
                                        {
-
 
1582
                                            name: 'insert',
-
 
1583
                                            items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar']
-
 
1584
                                        },
-
 
1585
                                        {
-
 
1586
                                            name: 'styles',
-
 
1587
                                            items: ['Styles', 'Format']
-
 
1588
                                        },
-
 
1589
                                        {
-
 
1590
                                            name: 'tools',
-
 
1591
                                            items: ['Maximize']
-
 
1592
                                        }
-
 
1593
                                    ],
-
 
1594
                                    removePlugins: 'elementspath,Anchor',
-
 
1595
                                    heigth: 100
-
 
1596
                                });
-
 
1597
                            </script>
-
 
1598
                        </div>
1221
                        </div>
1599
                    </div>
1222
                    </div>
1600
                    <div class="modal-footer">
1223
                    <div class="modal-footer">
1601
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1224
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1602
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1225
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
Línea 1624... Línea 1247...
1624
                    <div class="modal-body">
1247
                    <div class="modal-body">
1625
                        <div class="form-group">
1248
                        <div class="form-group">
1626
                            <label for="question-text">LABEL_TEXT</label>
1249
                            <label for="question-text">LABEL_TEXT</label>
1627
                            <!--  ckeditor -->
1250
                            <!--  ckeditor -->
1628
                            <textarea name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
1251
                            <textarea name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
1629
                            <script>
-
 
1630
                                CKEDITOR.replace('question-text', {
-
 
1631
                                    toolbar: [{
-
 
1632
                                            name: 'editing',
-
 
1633
                                            items: ['Scayt']
-
 
1634
                                        },
-
 
1635
                                        {
-
 
1636
                                            name: 'links',
-
 
1637
                                            items: ['Link', 'Unlink']
-
 
1638
                                        },
-
 
1639
                                        {
-
 
1640
                                            name: 'paragraph',
-
 
1641
                                            items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote']
-
 
1642
                                        },
-
 
1643
                                        {
-
 
1644
                                            name: 'basicstyles',
-
 
1645
                                            items: ['Bold', 'Italic', 'Strike', 'RemoveFormat']
-
 
1646
                                        },
-
 
1647
                                        '/',
-
 
1648
                                        {
-
 
1649
                                            name: 'insert',
-
 
1650
                                            items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar']
-
 
1651
                                        },
-
 
1652
                                        {
-
 
1653
                                            name: 'styles',
-
 
1654
                                            items: ['Styles', 'Format']
-
 
1655
                                        },
-
 
1656
                                        {
-
 
1657
                                            name: 'tools',
-
 
1658
                                            items: ['Maximize']
-
 
1659
                                        }
-
 
1660
                                    ],
-
 
1661
                                    removePlugins: 'elementspath,Anchor',
-
 
1662
                                    heigth: 100
-
 
1663
                                });
-
 
1664
                            </script>
-
 
1665
                        </div>
1252
                        </div>
1666
                        <div class="form-group">
1253
                        <div class="form-group">
1667
                            <label for="question-type">LABEL_TYPE</label>
1254
                            <label for="question-type">LABEL_TYPE</label>
1668
                            <select name="question-type" id="question-type" class="form-control">
1255
                            <select name="question-type" id="question-type" class="form-control">
1669
                                <option value="open">LABEL_OPEN</option>
1256
                                <option value="simple">LABEL_SINGLE_SELECTION</option>
1670
                                <option value="simple">Simple</option>
1257
                                <option value="multiple">LABEL_MULTIPLE_SELECTION</option>
1671
                                <option value="multiple">Multiple</option>
1258
                                <option value="range1to5">LABEL_RANGE_1_5</option>
Línea 1672... Línea 1259...
1672
 
1259
 
1673
                            </select>
1260
                            </select>
1674
                        </div>
-
 
1675
                        <div class="form-group">
-
 
1676
                            <label for="question-max-length">LABEL_MAXLENGTH</label>
-
 
1677
                            <input type="text" name="question-max-length" id="question-max-length" class="form-control" />
-
 
1678
                        </div>
-
 
1679
                        <div class="form-group">
-
 
1680
                            <label for="question-multiline">LABEL_MULTI_LINE</label>
-
 
1681
                            <select name="question-multiline" id="question-multiline" class="form-control">
-
 
1682
                                <option value="1">LABEL_YES</option>
-
 
1683
                                <option value="0">LABEL_NOT</option>
-
 
1684
                            </select>
-
 
1685
                        </div>
-
 
1686
                        <div class="form-group">
-
 
1687
                            <label for="question-range">LABEL_RANGE</label>
-
 
1688
                            <select name="question-range" id="question-range" class="form-control">
-
 
1689
                                <option value="10">1-10</option>
-
 
1690
                                <option value="6">1-6</option>
-
 
1691
                                <option value="5">1-5</option>
-
 
1692
                            </select>
-
 
1693
                        </div>
1261
                        </div>
1694
                    </div>
1262
                    </div>
1695
                    <div class="modal-footer">
1263
                    <div class="modal-footer">
1696
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1264
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1697
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1265
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
Línea 1721... Línea 1289...
1721
                    <div class="modal-body">
1289
                    <div class="modal-body">
1722
                        <div class="form-group">
1290
                        <div class="form-group">
1723
                            <label for="option-text">LABEL_TEXT</label>
1291
                            <label for="option-text">LABEL_TEXT</label>
1724
                            <!--  ckeditor -->
1292
                            <!--  ckeditor -->
1725
                            <textarea name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
1293
                            <textarea name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
1726
                            <script>
-
 
1727
                                CKEDITOR.replace('option-text', {
-
 
1728
                                    toolbar: [{
-
 
1729
                                            name: 'editing',
-
 
1730
                                            items: ['Scayt']
-
 
1731
                                        },
-
 
1732
                                        {
-
 
1733
                                            name: 'links',
-
 
1734
                                            items: ['Link', 'Unlink']
-
 
1735
                                        },
-
 
1736
                                        {
-
 
1737
                                            name: 'paragraph',
-
 
1738
                                            items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote']
-
 
1739
                                        },
-
 
1740
                                        {
-
 
1741
                                            name: 'basicstyles',
-
 
1742
                                            items: ['Bold', 'Italic', 'Strike', 'RemoveFormat']
-
 
1743
                                        },
-
 
1744
                                        '/',
-
 
1745
                                        {
-
 
1746
                                            name: 'insert',
-
 
1747
                                            items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar']
-
 
1748
                                        },
-
 
1749
                                        {
-
 
1750
                                            name: 'styles',
-
 
1751
                                            items: ['Styles', 'Format']
-
 
1752
                                        },
-
 
1753
                                        {
-
 
1754
                                            name: 'tools',
-
 
1755
                                            items: ['Maximize']
-
 
1756
                                        }
-
 
1757
                                    ],
-
 
1758
                                    removePlugins: 'elementspath,Anchor',
-
 
1759
                                    heigth: 100
-
 
1760
                                });
-
 
1761
                            </script>
-
 
1762
                        </div>
1294
                        </div>
1763
                    </div>
1295
                    </div>
1764
                    <div class="modal-footer">
1296
                    <div class="modal-footer">
1765
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1297
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1766
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1298
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
Línea 1768... Línea 1300...
1768
                </div>
1300
                </div>
1769
            </form>
1301
            </form>
1770
        </div>
1302
        </div>
1771
    </div>
1303
    </div>
Línea 1772... Línea -...
1772
 
-
 
Línea -... Línea 1304...
-
 
1304
 
-
 
1305
 
-
 
1306
</section>
-
 
1307
 
1773
    <!-- End Modal Options -->
1308
 
1774
 
1309
    
1775
    <!---Template Sections --->
-
 
-
 
1310
    <!---Template Sections --->
1776
    <script id="sectionTemplate" type="text/x-jsrender">
1311
    <script id="sectionTemplateReplace" type="text/x-jsrender">
1777
        <div class="panel panel-default" id="panel-{{:slug_section}}">
1312
 
1778
        <div class="panel-heading">
1313
        <div class="panel-heading">
1779
            <h4 class="panel-title">
1314
            <h4 class="panel-title">
1780
                <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
1315
                <a class="accordion-toggle" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
Línea 1806... Línea 1341...
1806
                                    <button class="btn btn-default btn-delete-section" data-section="{{:slug_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>
1341
                                    <button class="btn btn-default btn-delete-section" data-section="{{:slug_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>
1807
                                    <button class="btn btn-default btn-add-question" data-section="{{:slug_section}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_QUESTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_QUESTION </button>
1342
                                    <button class="btn btn-default btn-add-question" data-section="{{:slug_section}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_QUESTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_QUESTION </button>
1808
                                </td>
1343
                                </td>
1809
                            </tr>
1344
                            </tr>
1810
                            {{for questions}}
1345
                            {{for questions}}
1811
                            <tr class="tr-question">
1346
                            <tr class="tr-question" id="tr-question-{{:slug_question}}">
1812
                                <td class="text-left">--LABEL_QUESTION</td>
1347
                                <td class="text-left">--LABEL_QUESTION</td>
1813
                                <td class="text-left">
1348
                                <td class="text-left">
1814
                                    {{:~removeTags(text)}}
1349
                                    {{:text}}
1815
                                </td>
1350
                                </td>
1816
                                <td class="text-capitalize">
1351
                                <td class="text-capitalize">
1817
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
1352
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
1818
                                    {{if type == 'simple'}} Simple {{/if}}
1353
                                    {{if type == 'simple'}} LABEL_SINGLE_SELECTION {{/if}}
1819
                                    {{if type == 'multiple'}} Multiple {{/if}}
1354
                                    {{if type == 'multiple'}} LABEL_MULTIPLE_SELECTION {{/if}}
-
 
1355
                                    {{if type == 'range1to5'}} LABEL_RANGE_1_5 {{/if}}
1820
                                </td>
1356
                                </td>
1821
                                <td>
1357
                                <td>
1822
                                    <button class="btn btn-default btn-edit-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_QUESTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_QUESTION</button>
1358
                                    <button class="btn btn-default btn-edit-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_QUESTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_QUESTION</button>
1823
                                    <button class="btn btn-default btn-delete-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_QUESTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_QUESTION</button>
1359
                                    <button class="btn btn-default btn-delete-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_QUESTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_QUESTION</button>
Línea 1824... Línea 1360...
1824
                                 
1360
                                 
1825
                                    {{if type == 'simple' || type == 'rating-open' || type=='multiple' }}
1361
                                    {{if type == 'simple' ||  type=='multiple' }}
1826
                                    <button class="btn btn-default btn-add-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_OPTION</button>
1362
                                    <button class="btn btn-default btn-add-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_OPTION</button>
Línea 1827... Línea 1363...
1827
                                    {{/if}}
1363
                                    {{/if}}
1828
                               
1364
                               
1829
                                </td>
1365
                                </td>
1830
                            </tr>
1366
                            </tr>
1831
                            {{for options}}
1367
                            {{for options}}
1832
                            <tr class="tr-option">
1368
                            <tr class="tr-option" id="tr-option-{{:slug_option}}">
1833
                                <td class="text-left">---LABEL_OPTION</td>
1369
                                <td class="text-left">---LABEL_OPTION</td>
1834
                                <td class="text-left">
1370
                                <td class="text-left">
1835
                                    {{:~removeTags(text)}}
1371
                                    {{:text}}
-
 
1372
                                </td>
-
 
1373
                                <td>
-
 
1374
                                    &nbsp;
-
 
1375
                                </td>
-
 
1376
                                <td>
-
 
1377
                                    <button class="btn btn-default btn-edit-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_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>
-
 
1378
                                    <button class="btn btn-default btn-delete-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_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>
-
 
1379
                                </td>
-
 
1380
                            </tr>
-
 
1381
                            {{/for}}
-
 
1382
                            {{/for}}
-
 
1383
                        </tbody>
-
 
1384
                    </table>
-
 
1385
                </div>
-
 
1386
            </div>
-
 
1387
        </div>
Línea -... Línea 1388...
-
 
1388
 
-
 
1389
    </script>
-
 
1390
 
-
 
1391
    <!---Template Sections --->
-
 
1392
    <script id="sectionTemplateAdd" type="text/x-jsrender">
-
 
1393
    <div class="panel panel-default" id="panel-{{:slug_section}}">
-
 
1394
        <div class="panel-heading">
-
 
1395
            <h4 class="panel-title">
-
 
1396
                <a class="d-block w-100 collapsed card-primary" data-toggle="collapse" aria-expanded="true" data-parent="#panel-{{:slug_section}}" href="#collapse-{{:slug_section}}">
-
 
1397
                    <i class="fa" aria-hidden="true"></i>     
-
 
1398
                    <span class="section-name{{:slug_section}}">
-
 
1399
                        {{:name}}
-
 
1400
                    </span>
-
 
1401
                </a>
-
 
1402
            </h4>
-
 
1403
        </div>
-
 
1404
        <div id="collapse-{{:slug_section}}" class="collapse show" data-parent="panel-{{:slug_section}}" style="">
-
 
1405
            <div class="panel-body">
-
 
1406
                <div class="table-responsive">
-
 
1407
                    <table class="table table-bordered">
-
 
1408
                        <thead>
-
 
1409
                            <tr>
-
 
1410
                                <th style="width: 10%;">LABEL_ELEMENT</th>
-
 
1411
                                <th style="width: 50%;">LABEL_TEXT</th>
-
 
1412
                                <th style="width: 10%;">LABEL_TYPE</th>
-
 
1413
                                <th style="width: 20%;">LABEL_ACTIONS</th>
-
 
1414
                            </tr>
-
 
1415
                        </thead>
-
 
1416
                        <tbody>
-
 
1417
                            <tr class="tr-section">
-
 
1418
                                <td class="text-left">LABEL_SECTION</td>
-
 
1419
                                <td class="text-left">{{:name}}</td>
-
 
1420
                                <td></td>
-
 
1421
                                <td>
-
 
1422
                                    <button class="btn btn-default btn-edit-section" data-section="{{:slug_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>
-
 
1423
                                    <button class="btn btn-default btn-delete-section" data-section="{{:slug_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>
-
 
1424
                                    <button class="btn btn-default btn-add-question" data-section="{{:slug_section}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_QUESTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_QUESTION </button>
-
 
1425
                                </td>
-
 
1426
                            </tr>
-
 
1427
                            {{for questions}}
-
 
1428
                            <tr class="tr-question" id="tr-question-{{:slug_question}}">
-
 
1429
                                <td class="text-left">--LABEL_QUESTION</td>
-
 
1430
                                <td class="text-left">
-
 
1431
                                    {{:text}}
-
 
1432
                                </td>
-
 
1433
                                <td class="text-capitalize">
-
 
1434
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
-
 
1435
                                    {{if type == 'simple'}} LABEL_SINGLE_SELECTION {{/if}}
-
 
1436
                                    {{if type == 'multiple'}} LABEL_MULTIPLE_SELECTION {{/if}}
-
 
1437
                                    {{if type == 'range1to5'}} LABEL_RANGE_1_5 {{/if}}
1836
                                </td>
1438
                                </td>
-
 
1439
                                <td>
-
 
1440
                                    <button class="btn btn-default btn-edit-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_QUESTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_QUESTION</button>
-
 
1441
                                    <button class="btn btn-default btn-delete-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_QUESTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_QUESTION</button>
1837
                                <td>
1442
                                 
-
 
1443
                                    {{if type == 'simple' || type=='multiple' }}
-
 
1444
                                    <button class="btn btn-default btn-add-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_OPTION</button>
-
 
1445
                                    {{/if}}
-
 
1446
                               
-
 
1447
                                </td>
-
 
1448
                            </tr>
-
 
1449
                            {{for options}}
-
 
1450
                            <tr class="tr-option" id="tr-option-{{:slug_option}}">
-
 
1451
                                <td class="text-left">---LABEL_OPTION</td>
-
 
1452
                                <td class="text-left">
-
 
1453
                                    {{:text}}
1838
 
1454
                                </td>
1839
                                    {{if ~getType( slug_section, slug_question) == 'multiple' || ~getType( slug_section, slug_question) == 'rating-open'  }}
1455
                                <td>
1840
                                    {{/if}}
1456
                                    &nbsp;
1841
                                </td>
1457
                                </td>
1842
                                <td>
1458
                                <td>
Línea 1850... Línea 1466...
1850
                    </table>
1466
                    </table>
1851
                </div>
1467
                </div>
1852
            </div>
1468
            </div>
1853
        </div>
1469
        </div>
1854
    </div>
1470
    </div>
1855
    </script>
-
 
1856
 
-
 
1857
    <!-- End Template Sections-->
-
 
Línea 1858... Línea -...
1858
 
-
 
1859
</section>
1471
 
-
 
1472
    </script>
1860
1473