|
@@ -155,17 +155,157 @@
|
155
|
155
|
|
156
|
156
|
$('#outcome-display').parent().hide();
|
157
|
157
|
|
158
|
|
- // --------------------------------------------------------------------------
|
159
|
|
- // Functions
|
160
|
|
- // --------------------------------------------------------------------------
|
|
158
|
+
|
|
159
|
+
|
161
|
160
|
|
162
|
|
- // --------------------------------------------------------------------------
|
163
|
|
- // Events
|
164
|
|
- // --------------------------------------------------------------------------
|
|
161
|
+ });
|
|
162
|
+
|
|
163
|
+ function draw_comment_section(typ_semester_outcome_id, outcome_comments){
|
|
164
|
+ $('#levelTabs').append('<li role = "presentation" id = "comments_for_outcome">'+
|
|
165
|
+ '<a data-toggle="tab" id="a_for_ta_outcome" href="#comments_outcome" role="tab" >Comments for Outcome</a>'+
|
|
166
|
+ '</li>');
|
|
167
|
+ $('#allLists').append('<div role="tabpanel" class="tab-pane" data-typ-semester-outcome-id = "'+typ_semester_outcome_id+'" id="comments_outcome"></div>');
|
|
168
|
+ button_for_adding_comments = $('<button>', {
|
|
169
|
+ 'class':'btn btn-secondary',
|
|
170
|
+ 'id':'add_comments_button',
|
|
171
|
+ 'style':'float: right',
|
|
172
|
+ 'onclick': 'add_comments_to_plan()'
|
|
173
|
+ }).html("<span class='glyphicon glyphicon-plus'></span> Add Comments");
|
|
174
|
+ $('#comments_outcome').append('<h3>Comments</h3>')
|
|
175
|
+ if(outcome_comments.length){
|
|
176
|
+ table_for_comments = $('<table>',{
|
|
177
|
+ 'class':'table table-striped table-condensed datatable',
|
|
178
|
+ 'id':'table_for_comments'
|
|
179
|
+ }).html('<thead><th>Comments</th><th>Edit or Delete</th></thead><tbody></tbody>');
|
|
180
|
+ table_for_comments.appendTo('#comments_outcome');
|
|
181
|
+ table_for_comments = table_for_comments.DataTable();
|
|
182
|
+ $.each(outcome_comments, function(index, comment){
|
|
183
|
+
|
|
184
|
+ comment_td = '<div id="comments_id_'+comment.id+'">'+comment.comments+'</div>';
|
|
185
|
+
|
|
186
|
+ inputEdit = $('<input>', {
|
|
187
|
+ 'type': 'button',
|
|
188
|
+ 'class': 'btn btn-secondary',
|
|
189
|
+ 'onclick': 'add_comments_to_plan('+comment.id+')',
|
|
190
|
+ 'id': 'edit_button_comment_' + comment.id,
|
|
191
|
+ 'value': 'Edit'
|
|
192
|
+ }).html('Edit');
|
|
193
|
+ inputDelete = $('<input>', {
|
|
194
|
+ 'type': 'button',
|
|
195
|
+ 'class': 'btn btn-primary',
|
|
196
|
+ 'style': 'display: inline',
|
|
197
|
+ 'onclick': 'deleteCommentsFromOutcome('+comment.id+')',
|
|
198
|
+ 'value': 'Delete'
|
|
199
|
+ })
|
|
200
|
+ div = $('<div>');
|
|
201
|
+ div.append(inputEdit);
|
|
202
|
+ div.append(inputDelete);
|
|
203
|
+ table_for_comments.row.add([
|
|
204
|
+ comment_td,
|
|
205
|
+ div.html()
|
|
206
|
+
|
|
207
|
+ ]).draw();
|
|
208
|
+ });
|
|
209
|
+
|
|
210
|
+ }
|
|
211
|
+
|
|
212
|
+ $('#comments_outcome').append('<hr>');
|
|
213
|
+ $('#comments_outcome').append(button_for_adding_comments);
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+ }
|
|
222
|
+
|
|
223
|
+ function add_comments_to_plan(edit_id = null){
|
|
224
|
+ $('#add_comments_button').hide();
|
|
225
|
+ div_for_inputs = $('<div>', {
|
|
226
|
+ 'id':'add_comment_div'
|
|
227
|
+ });
|
|
228
|
+ textarea = $('<textarea>',{
|
|
229
|
+ 'class':'form-control',
|
|
230
|
+ 'data-comment-id':edit_id,
|
|
231
|
+ 'id':'comment_textbox'
|
|
232
|
+ });
|
|
233
|
+ if(edit_id){
|
|
234
|
+ textarea.val($("#comments_id_"+edit_id).html());
|
|
235
|
+ }
|
|
236
|
+ save_button = $('<button>', {
|
|
237
|
+ 'class':'btn btn-primary',
|
|
238
|
+ 'onclick':'saveComment()',
|
|
239
|
+ 'style':'float: right'
|
|
240
|
+ }).html('Save');
|
|
241
|
+ $('#comments_outcome').append(div_for_inputs);
|
|
242
|
+ div_for_inputs.append('<h5>Add new comment</h5>');
|
|
243
|
+ div_for_inputs.append(textarea);
|
|
244
|
+ div_for_inputs.append(save_button);
|
|
245
|
+
|
|
246
|
+ }
|
|
247
|
+
|
|
248
|
+ function saveComment(){
|
|
249
|
+ typ_outcome_semester_id = $("#comments_outcome").data('typ-semester-outcome-id');
|
|
250
|
+ comment_area = $('#comment_textbox');
|
|
251
|
+
|
|
252
|
+ $.post(
|
|
253
|
+ "{{URL::action('AnnualPlansController@addCommentsToOutcome')}}",
|
|
254
|
+ {
|
|
255
|
+ typ_outcome_semester_id:typ_outcome_semester_id,
|
|
256
|
+ comments:comment_area.val(),
|
|
257
|
+ edit_id:comment_area.data('comment-id')
|
|
258
|
+ },
|
|
259
|
+ function(edit_id){
|
|
260
|
+ $('#add_comment_div').remove();
|
|
261
|
+ $('#add_comments_button').show();
|
|
262
|
+ if($('#comments_id_'+edit_id).length){
|
|
263
|
+ $('#comments_id_'+edit_id).html(comment_area.val());
|
|
264
|
+ }
|
|
265
|
+ else{
|
|
266
|
+ table_for_comments = $('#table_for_comments').DataTable();
|
|
267
|
+ comment_td = '<div id="comments_id_'+edit_id+'">'+comment_area.val()+'</div>';
|
|
268
|
+
|
|
269
|
+ inputEdit = $('<input>', {
|
|
270
|
+ 'type': 'button',
|
|
271
|
+ 'class': 'btn btn-secondary',
|
|
272
|
+ 'onclick': 'add_comments_to_plan('+edit_id+')',
|
|
273
|
+ 'id': 'edit_button_comment_' + edit_id,
|
|
274
|
+ 'value': 'Edit'
|
|
275
|
+ }).html('Edit');
|
|
276
|
+ inputDelete = $('<input>', {
|
|
277
|
+ 'type': 'button',
|
|
278
|
+ 'class': 'btn btn-primary',
|
|
279
|
+ 'style': 'display: inline',
|
|
280
|
+ 'onclick': 'deleteCommentsFromOutcome('+edit_id+')',
|
|
281
|
+ 'value': 'Delete'
|
|
282
|
+ })
|
|
283
|
+ div = $('<div>');
|
|
284
|
+ div.append(inputEdit);
|
|
285
|
+ div.append(inputDelete);
|
|
286
|
+ table_for_comments.row.add([
|
|
287
|
+ comment_td,
|
|
288
|
+ div.html()
|
|
289
|
+
|
|
290
|
+ ]).draw();
|
|
291
|
+ }
|
|
292
|
+ }
|
|
293
|
+ )
|
|
294
|
+
|
|
295
|
+ }
|
|
296
|
+
|
|
297
|
+ function deleteCommentsFromOutcome(id){
|
|
298
|
+ $.post(
|
|
299
|
+ "{{URL::action('AnnualPlansController@deleteCommentsFromOutcome')}}",
|
|
300
|
+ {id:id},
|
|
301
|
+ function(){
|
|
302
|
+ $('#comments_id_'+id).parent().parent().remove();
|
|
303
|
+
|
|
304
|
+ }
|
|
305
|
+ )
|
|
306
|
+ }
|
165
|
307
|
|
166
|
|
- // When list item is clicked, load corresponding info
|
167
|
308
|
|
168
|
|
- });
|
169
|
309
|
|
170
|
310
|
// Create everything
|
171
|
311
|
|
|
@@ -175,7 +315,7 @@
|
175
|
315
|
}
|
176
|
316
|
else{
|
177
|
317
|
$('#levelTabs').prepend('<li role = "presentation" id = "transformative_for_outcome">'+
|
178
|
|
- '<a data-toggle="tab" id="a_for_ta_outcome" href="#transformative_actions" role="tab" >Transformative Actions</a>'+
|
|
318
|
+ '<a data-toggle="tab" id="a_for_ta_outcome" href="#transformative_actions" role="tab" >Transformative Actions to Outcome</a>'+
|
179
|
319
|
'</li>');
|
180
|
320
|
$('#allLists').prepend('<div role="tabpanel" class="tab-pane" id="transformative_actions"></div>');
|
181
|
321
|
|
|
@@ -425,6 +565,8 @@
|
425
|
565
|
})
|
426
|
566
|
|
427
|
567
|
draw_transformative_actions(outcome.transforming_actions, outcome.semester_info.id)
|
|
568
|
+ draw_comment_section(typ_semester_outcome_id, outcome.comments);
|
|
569
|
+
|
428
|
570
|
//$('#a_for_'+first_objective_id).click();
|
429
|
571
|
theArray = [];
|
430
|
572
|
|