Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 2504 Rev 2506
Línea 64... Línea 64...
64
echo <<<JS
64
echo <<<JS
Línea 65... Línea 65...
65
 
65
 
66
const classFormGenerator = function() {
66
const classFormGenerator = function() {
67
    this.id = 0,
67
    this.id = 0,
68
        this.table = '',
-
 
69
        this.name = '',
68
        this.table = '',
70
        this.text = '',
-
 
71
        this.status = 'a',
69
        this.text = '',
72
        this.sections = [],
70
        this.behaviors = [],
73
        this.clear = function() {
71
        this.clear = function() {
74
            this.sections = [];
72
            this.behaviors = [];
75
            this.render();
73
            this.render();
Línea 76... Línea 74...
76
        },
74
        },
77
       
75
       
78
        /**
76
        /**
79
         * Add element to section array
77
         * Add element to section array
80
         */
78
         */
81
        this.addSection = function(name, text, value) {
79
        this.addSection = function( text, value) {
82
            var d = new Date();
80
            var d = new Date();
83
            var slug = 'section' + d.getTime();
81
            var slug = 'section' + d.getTime();
84
            var position = 0;
82
            var position = 0;
85
            $.each(this.sections, function(index, section) {
83
            $.each(this.behaviors, function(index, section) {
86
                if (position < section.position) {
84
                if (position < section.position) {
87
                    position = section.position;
85
                    position = section.position;
88
                }
86
                }
89
            });
87
            });
90
            position++;
88
            position++;
91
            var section = {
-
 
92
                'slug_section': slug,
89
            var section = {
93
                'name': name,
90
                'slug_behaviors': slug,
94
                'text': text,
91
                'text': text,
95
                'value': value,
92
                'value': value,
96
                'position': position,
93
                'position': position,
97
                'questions': [],
94
                'questions': [],
98
                'status': 0
95
                'status': 0
99
            }
96
            }
100
            this.sections.push(section);
97
            this.behaviors.push(section);
101
        },
98
        },
102
         /**
99
         /**
103
         * Edit element to section array
100
         * Edit element to section array
104
         */
101
         */
105
        this.editSection = function(slug, name, text, value) {
102
        this.editSection = function(slug, text, value) {
106
            var renderTable = false;
103
            var renderTable = false;
107
            for (i = 0; i < this.sections.length; i++) {
-
 
108
                if (slug == this.sections[i].slug_section) {
104
            for (i = 0; i < this.behaviors.length; i++) {
109
                    this.sections[i].name = name;
105
                if (slug == this.behaviors[i].slug_behaviors) {
110
                    this.sections[i].text = text;
106
                    this.behaviors[i].text = text;
111
                    this.sections[i].value = value;
107
                    this.behaviors[i].value = value;
112
                    renderTable = true;
108
                    renderTable = true;
113
                    break;
109
                    break;
114
                }
110
                }
Línea 120... Línea 116...
120
         /**
116
         /**
121
         * Remove element to section array
117
         * Remove element to section array
122
         */
118
         */
123
        this.deleteSection = function(slug) {
119
        this.deleteSection = function(slug) {
124
            var renderTable = false;
120
            var renderTable = false;
125
            for (i = 0; i < this.sections.length; i++) {
121
            for (i = 0; i < this.behaviors.length; i++) {
126
                if (slug == this.sections[i].slug_section) {
122
                if (slug == this.behaviors[i].slug_behaviors) {
127
                    this.sections.splice(i, 1);
123
                    this.behaviors.splice(i, 1);
128
                    renderTable = true;
124
                    renderTable = true;
129
                    break;
125
                    break;
130
                }
126
                }
131
            }
127
            }
132
            if (renderTable) {
128
            if (renderTable) {
Línea 139... Línea 135...
139
        return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
135
        return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
140
    }
136
    }
Línea 141... Línea 137...
141
 
137
 
142
jQuery( document ).ready(function( $ ) {
138
jQuery( document ).ready(function( $ ) {
143
    var objFormGenerator = new classFormGenerator();
139
    var objFormGenerator = new classFormGenerator();
144
    objFormGenerator.render();
140
    //objFormGenerator.render();
145
    $.validator.setDefaults({
141
    $.validator.setDefaults({
146
        debug: true,
142
        debug: true,
147
        highlight: function(element) {
143
        highlight: function(element) {
148
            $(element).addClass('is-invalid');
144
            $(element).addClass('is-invalid');
Línea 421... Línea 417...
421
                <tr>
417
                <tr>
422
                   <td class="text-left">--LABEL_CONDUCT</td>
418
                   <td class="text-left">--LABEL_CONDUCT</td>
423
                   <td class="text-left">
419
                   <td class="text-left">
424
                      {{:description}}
420
                      {{:description}}
425
                   </td>
421
                   </td>
426
                </tr>
-
 
427
            {{/for}}
-
 
428
 
-
 
429
            <tr>
-
 
430
                <td colspan="2">
422
                   <td colspan="2">
431
                    <label for="textarea-{{:competency_uuid}}">LABEL_COMMENT</label>
423
                    <label for="textarea-{{:competency_uuid}}">LABEL_COMMENT</label>
432
                    <textarea
424
                    <textarea
433
                        id="textarea-{{:competency_uuid}}"
425
                        id="textarea-{{:competency_uuid}}"
434
                        class="form-control"
426
                        class="form-control"
435
                    ></textarea>
427
                    ></textarea>
-
 
428
                    </td>
436
                </td>
429
                </tr>
437
            </tr>
430
            {{/for}}
-
 
431
 
438
        {{/for}}
432
        {{/for}}
439
    </tbody>
433
    </tbody>
440
</table>
434
</table>
441
</script>
435
</script>