Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6661 | Rev 6663 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
5050 efrain 1
<?php
6552 stevensc 2
 
6521 efrain 3
use LeadersLinked\Model\ContentReaction;
4
 
6388 efrain 5
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
6
$currentUser    = $this->currentUserHelper();
7
$roleName       = $currentUser->getUserTypeId();
5050 efrain 8
 
6388 efrain 9
$routeQuestions     = $this->url('my-coach/questions');
10
$routeQuestionAdd   = $this->url('my-coach/questions/add');
11
$allowQuestionAdd   = $acl->isAllowed($roleName, 'my-coach/questions/add') ? 1 : 0;
5050 efrain 12
 
6388 efrain 13
 
14
 
15
 
16
$this->inlineScript()->appendFile($this->basePath('vendors/ckeditor/ckeditor.js'));
17
 
18
$this->headLink()->appendStylesheet($this->basePath('vendors/nprogress/nprogress.css'));
19
$this->inlineScript()->appendFile($this->basePath('vendors/nprogress/nprogress.js'));
20
 
21
$this->headLink()->appendStylesheet($this->basePath('vendors/select2/css/select2.min.css'));
22
$this->headLink()->appendStylesheet($this->basePath('vendors/select2-bootstrap4-theme/select2-bootstrap4.min.css'));
23
$this->inlineScript()->appendFile($this->basePath('vendors/select2/js/select2.min.js'));
24
 
25
$this->inlineScript()->appendFile($this->basePath('vendors/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
26
$this->inlineScript()->appendFile($this->basePath('vendors/jsrender/jsrender.min.js'));
27
 
28
 
29
$this->inlineScript()->appendFile($this->basePath('vendors/jquery-validation/jquery.validate.js'));
30
$this->inlineScript()->appendFile($this->basePath('vendors/jquery-validation/additional-methods.js'));
31
$this->inlineScript()->appendFile($this->basePath('vendors/jquery-validation/localization/messages_es.js'));
32
 
33
$this->inlineScript()->captureStart();
34
echo <<<JS
35
 
36
jQuery( document ).ready(function( $ ) {
37
 
6547 efrain 38
    $.fn.confirmationAnswers = function() {
6521 efrain 39
 
6547 efrain 40
        $('button.btn-my-coach-delete-answer').confirmation({
41
            rootSelector: 'button.btn-my-coach-delete-answer',
42
            title : 'LABEL_ARE_YOU_SURE',
43
            singleton : true,
44
            btnOkLabel: 'LABEL_YES',
45
            btnCancelLabel: 'LABEL_NO',
46
            onConfirm: function(value) {
47
                var action = $(this).data('link');
48
                var question = $(this).data('question');
49
                var answer = $(this).data('answer');
50
 
51
 
52
                NProgress.start();
53
                $.ajax({
54
                    'dataType'  : 'json',
55
                    'accept'    : 'application/json',
56
                    'method'    : 'post',
57
                    'url'       :  action,
58
                }).done(function(response) {
59
                    if(response['success']) {
60
 
61
                        $('#row-' + answer).remove();
62
 
63
                        $('#answers-' + question).html(response['data']['total_answers']);
6649 stevensc 64
                        $('#my-coach-question-answer-count-answers').html(response['data']['total_answers'] + ' LABEL_MY_COACH_ANSWERS');
6547 efrain 65
 
66
                        $('#reactions-' + question).html( response['data']['total_reactions']);
6649 stevensc 67
                        $('#my-coach-question-answer-count-reactions').html( response['data']['total_reactions'] + ' LABEL_MY_COACH_REACTIONS');
6547 efrain 68
 
69
                        $('#comments-' + question).html(response['data']['total_comments']);
6649 stevensc 70
                        $('#my-coach-question-answer-count-comments').html(response['data']['total_comments'] + ' LABEL_COMMENTS');
6547 efrain 71
 
72
                    } else {
73
                        $.fn.showError(response['data']);
74
                    }
75
                }).fail(function( jqXHR, textStatus, errorThrown) {
76
                    $.fn.showError(textStatus);
77
                }).always(function() {
78
                    NProgress.done();
79
                });
80
 
81
                return false;
82
            },
83
        });
84
    }
85
 
86
 
6521 efrain 87
    $.fn.reloadAnswers = function() {
88
 
89
        var action = $('#row-view').data('link-answers');
90
 
6388 efrain 91
        NProgress.start();
92
        $.ajax({
93
            'dataType'  : 'json',
94
            'accept'    : 'application/json',
95
            'method'    : 'get',
6521 efrain 96
            'url'       : action,
97
        }).done(function(response) {
98
            if(response['success']) {
99
                $('#my-coach-question-answers-list').empty();
100
                if(response['data']['items'].length > 0) {
101
                    $( "#my-coach-question-answers-list" ).html(
102
                		$( "#answerTemplate" ).render( response['data']['items'] )
103
                	);
6523 efrain 104
                }
6547 efrain 105
                $.fn.confirmationAnswers();
6521 efrain 106
 
6547 efrain 107
 
6521 efrain 108
 
109
            } else {
110
                $.fn.showError(response['data']);
111
            }
112
        }).fail(function( jqXHR, textStatus, errorThrown) {
113
            $.fn.showError(textStatus);
114
        }).always(function() {
115
            NProgress.done();
116
        });
117
 
118
    }
119
 
120
    $.fn.reload = function() {
121
 
122
        NProgress.start();
123
        $.ajax({
124
            'dataType'  : 'json',
125
            'accept'    : 'application/json',
126
            'method'    : 'get',
6388 efrain 127
            'url'       :  '$routeQuestions',
128
            'data'      : {
129
                'search' : $('#form-filter #search').val(),
130
                'category_id' : $('li.my-coach-category-li-selected > a.my-coach-category-a').data('uuid') ,
131
 
132
            }
133
        }).done(function(response) {
134
            if(response['success']) {
135
                $('#my-coach-record-list').empty();
136
 
137
 
138
                if(response['data']['items'].length > 0) {
139
 
140
 
141
 
142
                    $( "#my-coach-record-list" ).html(
143
                		$( "#recordTemplate" ).render( response['data']['items'] )
144
                	);
145
                } else {
146
                    var html = '<div class="company-title"><div class="widget widget-jobs"><div class="sd-title">ERROR_NO_RECORD_MATCHED_YOUR_QUERY</div></div></div>';
147
                    $( "#my-coach-record-list" ).html(html);
148
                }
149
 
150
 
6521 efrain 151
                $('button.btn-my-coach-delete-question').confirmation({
152
                    rootSelector: 'button.btn-my-coach-delete-question',
6388 efrain 153
                    title : 'LABEL_ARE_YOU_SURE',
154
                    singleton : true,
155
                    btnOkLabel: 'LABEL_YES',
156
                    btnCancelLabel: 'LABEL_NO',
157
                    onConfirm: function(value) {
158
                        var action = $(this).data('link');
159
                        NProgress.start();
160
                        $.ajax({
161
                            'dataType'  : 'json',
162
                            'accept'    : 'application/json',
163
                            'method'    : 'post',
164
                            'url'       :  action,
165
                        }).done(function(response) {
166
                            if(response['success']) {
167
                                $.fn.showSuccess(response['data']);
168
 
169
                                $.fn.reload();
170
                            } else {
171
                                $.fn.showError(response['data']);
172
                            }
173
                        }).fail(function( jqXHR, textStatus, errorThrown) {
174
                            $.fn.showError(textStatus);
175
                        }).always(function() {
176
                            NProgress.done();
177
                        });
178
 
179
                        return false;
180
                    },
181
                });
182
 
183
            } else {
184
                $.fn.showError(response['data']);
185
            }
186
        }).fail(function( jqXHR, textStatus, errorThrown) {
187
            $.fn.showError(textStatus);
188
        }).always(function() {
189
            NProgress.done();
190
        });
191
 
192
    }
193
 
194
 
195
    $.validator.setDefaults({
196
        debug: true,
197
        highlight: function(element) {
198
            $(element).addClass('is-invalid');
199
        },
200
        unhighlight: function(element) {
201
            $(element).removeClass('is-invalid');
202
        },
203
        errorElement: 'span',
204
        errorClass: 'error invalid-feedback',
205
        errorPlacement: function(error, element) {
206
            if(element.parent('.btn-file').length) {
207
                error.insertAfter(element.parent().parent());
208
            } else if(element.parent('.toggle').length) {
209
                error.insertAfter(element.parent().parent());
210
            } else {
211
                error.insertAfter(element.parent());
212
            }
213
        }
214
    });
215
 
216
 
217
    $.fn.showFormErrorValidator = function(fieldname, errors) {
218
        var field = $(fieldname);
219
        if(field) {
220
            $(field).addClass('is-invalid');
221
 
222
 
223
            var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
224
            if(element.parent('.btn-file').length) {
225
                error.insertAfter(element.parent().parent());
226
            } else if(element.parent('.toggle').length) {
227
                error.insertAfter(element.parent().parent());
228
            } else {
229
                error.insertAfter(element.parent());
230
            }
231
        }
232
    };
233
 
234
    var validatorQuestion = $('#form-question').validate({
235
        debug: true,
236
        onclick: false,
237
        onkeyup: false,
238
        ignore: [],
239
        rules: {
240
            'category_id': {
241
                required: true,
242
            },
243
            'title': {
244
                required: true,
245
                maxlength: 128,
246
            },
247
            'description': {
248
                updateCkeditor:function() {
249
                        CKEDITOR.instances.description_question.updateElement();
250
                },
251
 
252
                required: true
253
            },
254
 
255
        },
256
        submitHandler: function(form)
257
        {
258
 
259
 
260
			NProgress.start();
261
            $.ajax({
262
                'dataType'  : 'json',
263
                'accept'    : 'application/json',
264
                'method'    : 'post',
265
                'url'       :  $('#form-question').attr('action'),
266
                'data'      :  $('#form-question').serialize(),
267
 
268
            }).done(function(response) {
269
 
270
				if(response['success']) {
271
 
272
                    $('#modal-question').modal('hide');
273
 
274
                    $.fn.showSuccess(response['data']);
275
                    $.fn.reload();
276
 
277
 
278
 
279
                } else {
280
                    validatorQuestion.resetForm();
281
                    if(jQuery.type(response['data']) == 'string') {
282
                        $.fn.showError(response['data']);
283
                    } else  {
284
                        $.each(response['data'], function( fieldname, errors ) {
285
                            $.fn.showFormErrorValidator('#form-question #' + fieldname, errors);
286
                        });
287
                    }
288
                }
289
            }).fail(function( jqXHR, textStatus, errorThrown) {
290
                $.fn.showError(textStatus);
291
            }).always(function() {
292
                NProgress.done();
293
            });
294
            return false;
295
        },
296
        invalidHandler: function(form, validator) {
297
 
298
        }
299
    });
300
 
6547 efrain 301
    var  validatorAnswer = $('#form-answer').validate({
6521 efrain 302
        debug: true,
303
        onclick: false,
304
        onkeyup: false,
305
        ignore: [],
306
        rules: {
307
            'description': {
308
                updateCkeditor:function() {
309
                        CKEDITOR.instances.description_answer.updateElement();
310
                },
311
 
312
                required: true
313
            },
314
 
315
        },
316
        submitHandler: function(form)
317
        {
6547 efrain 318
 
6388 efrain 319
 
6521 efrain 320
			NProgress.start();
321
            $.ajax({
322
                'dataType'  : 'json',
323
                'accept'    : 'application/json',
324
                'method'    : 'post',
325
                'url'       :  $('#form-answer').attr('action'),
326
                'data'      :  $('#form-answer').serialize(),
327
 
328
            }).done(function(response) {
329
				if(response['success']) {
6547 efrain 330
                    var method = $('#form-answer').data('method');
331
                    var answer = $('#form-answer').data('answer');
332
 
333
 
6521 efrain 334
                    $('#modal-answer').modal('hide');
335
 
6547 efrain 336
                    if(method == 'add') {
337
                        var uuid = $('#row-view').data('question-uuid');
338
                        $('#answers-' + uuid).html(response['data']['answers']);
6649 stevensc 339
                        $('#my-coach-question-answer-count-answers').html(response['data']['answers'] + ' LABEL_MY_COACH_ANSWERS');
6547 efrain 340
                        $('#my-coach-question-answers-list').prepend(
341
                            $('#answerTemplate').render(response['data']['item'])
342
                        );
343
                        $.fn.confirmationAnswers()
344
                    } else {
345
                        $('#answer-text-' + answer).empty();
346
                        $('#answer-text-' + answer).html(response['data']['description']);
347
 
348
                    }
6521 efrain 349
                } else {
350
                    validatorAnswer.resetForm();
351
                    if(jQuery.type(response['data']) == 'string') {
352
                        $.fn.showError(response['data']);
353
                    } else  {
354
                        $.each(response['data'], function( fieldname, errors ) {
355
                            $.fn.showFormErrorValidator('#form-answer #' + fieldname, errors);
356
                        });
357
                    }
358
                }
359
            }).fail(function( jqXHR, textStatus, errorThrown) {
360
                $.fn.showError(textStatus);
361
            }).always(function() {
362
                NProgress.done();
363
            });
364
            return false;
365
        },
366
        invalidHandler: function(form, validator) {
367
 
368
        }
369
    });
370
 
371
 
6388 efrain 372
    $('a.my-coach-category-a').click(function(e) {
373
        e.preventDefault();
374
 
375
 
376
        $('li.my-coach-category-li').removeClass('my-coach-category-li-selected');
377
        $(this).closest('li.my-coach-category-li').addClass('my-coach-category-li-selected');
378
 
379
        $.fn.reload();
380
    });
381
 
382
    $('body').on('click', 'button.btn-my-coach-edit', function(e) {
383
        e.preventDefault();
384
        var action = $(this).data('link');
385
        NProgress.start();
386
        $.ajax({
387
            'dataType'  : 'json',
388
            'accept'    : 'application/json',
389
            'method'    : 'get',
390
            'url'       :  action,
391
        }).done(function(response) {
392
            if(response['success']) {
393
 
394
                $('#form-question').attr('action', action);
395
                $('#form-question #category_id').val(response['data']['category_id']).trigger('change');
396
                $('#form-question #title').val(response['data']['title']);
397
                CKEDITOR.instances.description_question.setData(response['data']['description']);
398
 
399
                $('#modal-question').modal('show');
400
            } else {
401
                $.fn.showError(response['data']);
402
            }
403
        }).fail(function( jqXHR, textStatus, errorThrown) {
404
            $.fn.showError(textStatus);
405
        }).always(function() {
406
            NProgress.done();
407
        });
408
 
409
    });
410
 
411
 
412
    $('#form-filter #search').keyup(function(e) {
413
 
414
        e.preventDefault();
415
 
416
        $.fn.reload();
417
    })
418
 
419
    $('button.btn-search').click(function(e) {
420
        e.preventDefault();
421
 
422
        $.fn.reload();
423
    });
424
 
425
    $('#my-coach-add-question').click(function(e) {
426
        e.preventDefault();
427
 
428
        $('#form-question').attr('action', '$routeQuestionAdd');
429
        $('#form-question #title').val('');
430
        $('#form-question #category_id').val('').trigger('change');
431
        CKEDITOR.instances.description_question.setData('');
432
 
433
        $('#modal-question').modal('show');
434
    });
435
 
436
    $('#form-question #category_id').select2({
437
        theme: 'bootstrap4'
438
    })
439
 
440
    $('button.btn-cancel').click(function(e) {
441
        e.preventDefault();
442
 
443
 
444
        $('#modal-question').modal('hide');
6521 efrain 445
        $('#modal-answer').modal('hide');
6388 efrain 446
    });
447
 
6521 efrain 448
    $('#my-coach-question-answer-btn-delete').confirmation({
449
        rootSelector: 'button.my-coach-question-answer-btn-delete',
450
        title : 'LABEL_ARE_YOU_SURE',
451
        singleton : true,
452
        btnOkLabel: 'LABEL_YES',
453
        btnCancelLabel: 'LABEL_NO',
454
        onConfirm: function(value) {
455
            var action = $(this).data('link');
456
            var uuid = $(this).data('question-uuid');
457
 
458
            NProgress.start();
459
            $.ajax({
460
                'dataType'  : 'json',
461
                'accept'    : 'application/json',
462
                'method'    : 'post',
463
                'url'       :  action,
464
            }).done(function(response) {
465
                if(response['success']) {
466
                    $.fn.showSuccess(response['data']);
467
 
468
                    var uuid = $('#row-view').data('question-uuid');
469
                    var key = 'my-coach-record-card-question-' + uuid;
470
                    $('#' + key).remove();
471
 
472
                    $('#row-view').hide();
473
 
474
                    $('#my-coach-add-question').show();
475
                    $('#row-list').show();
476
 
477
 
478
 
479
                } else {
480
                    $.fn.showError(response['data']);
481
                }
482
            }).fail(function( jqXHR, textStatus, errorThrown) {
483
                $.fn.showError(textStatus);
484
            }).always(function() {
485
                NProgress.done();
486
            });
487
 
488
            return false;
489
        },
490
    });
491
 
492
 
493
    $('body').on('click', 'button.btn-my-coach-edit-view', function(e) {
494
        e.preventDefault();
495
        var action = $(this).data('link');
496
 
497
        NProgress.start();
498
        $.ajax({
499
            'dataType'  : 'json',
500
            'accept'    : 'application/json',
501
            'method'    : 'get',
502
            'url'       :  action,
503
        }).done(function(response) {
504
            if(response['success']) {
505
                $('#row-view').data('link-answers', response['data']['link_answers']);
506
                $('#row-view').data('question-uuid', response['data']['uuid']);
507
 
508
 
6547 efrain 509
                if(!response['data']['link_answers_add']) {
510
                    $('#my-coach-question-answer-btn-answer').hide();
511
                } else {
512
                    $('#my-coach-question-answer-btn-answer').data('link', response['data']['link_answers_add']);
513
                    $('#my-coach-question-answer-btn-answer').show();
514
                }
6521 efrain 515
 
6547 efrain 516
                if(!response['data']['link_delete']) {
517
                    $('#my-coach-question-answer-btn-delete').hide();
518
                } else {
519
                    $('#my-coach-question-answer-btn-delete').data('link', response['data']['link_delete']);
520
                    $('#my-coach-question-answer-btn-delete').show();
521
                }
6521 efrain 522
 
523
                $('#my-coach-question-user-image').attr('src', response['data']['user_image']);
524
                $('#my-coach-question-user-name').html(response['data']['user_name']);
525
                $('#my-coach-question-title').html(response['data']['title']);
6569 stevensc 526
                $('#my-coach-question-description').html(response['data']['description'].replace('<p>',''));
6521 efrain 527
 
528
                $('#my-coach-answer-categories').empty();
529
                $.each(response['data']['categories'], function(key, value) {
530
 
531
                    var li = $('<li>');
532
                    li.text(value.category).appendTo('#my-coach-answer-categories')
533
                });
534
 
6568 stevensc 535
                $('#my-coach-question-answer-question-date').append(response['data']['added_on']);
536
                $('#my-coach-question-answer-last-date').append(response['data']['last_answer_on']);
6648 stevensc 537
                $('#my-coach-question-answer-count-answers').html(response['data']['answers'] + ' LABEL_MY_COACH_ANSWERS');
6649 stevensc 538
                $('#my-coach-question-answer-count-reactions').html(response['data']['reactions'] + ' LABEL_MY_COACH_REACTIONS');
539
                $('#my-coach-question-answer-count-views').html(response['data']['views'] + ' LABEL_MY_COACH_VIEWS');
540
                $('#my-coach-question-answer-count-comments').html(response['data']['comments'] + ' LABEL_COMMENTS');
6521 efrain 541
 
542
                $('#views-' + response['data']['uuid']).html( response['data']['views'] );
543
 
544
 
545
                $('#my-coach-add-question').hide();
546
                $('#row-list').hide();
547
                $('#row-view').show();
548
 
549
                $.fn.reloadAnswers();
550
 
551
            } else {
552
                $.fn.showError(response['data']);
553
            }
554
        }).fail(function( jqXHR, textStatus, errorThrown) {
555
            $.fn.showError(textStatus);
556
        }).always(function() {
557
            NProgress.done();
558
        });
559
    });
560
 
561
    $('#my-coach-question-answer-btn-back').click(function(e) {
562
        e.preventDefault();
563
 
564
        $('#my-coach-add-question').show();
565
        $('#row-view').hide();
566
        $('#row-list').show();
567
 
568
    });
569
 
6547 efrain 570
    /****** RESPUESTAS ******/
6521 efrain 571
 
6547 efrain 572
    $('body').on('click', 'button.btn-my-coach-edit-answer', function(e) {
573
        e.preventDefault();
574
        var action = $(this).data('link');
575
        var answer = $(this).data('answer');
576
        NProgress.start();
577
        $.ajax({
578
            'dataType'  : 'json',
579
            'accept'    : 'application/json',
580
            'method'    : 'get',
581
            'url'       :  action,
582
        }).done(function(response) {
583
            if(response['success']) {
584
 
585
                $('#modal-answer-title').html('LABEL_MY_COACH_ANSWER_EDIT');
586
                $('#form-answer').attr('action', action );
587
                $('#form-answer').data('method','edit');
588
                $('#form-answer').data('answer', answer);
589
                CKEDITOR.instances.description_answer.setData(response['data']['description']);
590
                validatorAnswer.resetForm();
591
 
592
                $('#modal-answer').modal('show');
593
            } else {
594
                $.fn.showError(response['data']);
595
            }
596
        }).fail(function( jqXHR, textStatus, errorThrown) {
597
            $.fn.showError(textStatus);
598
        }).always(function() {
599
            NProgress.done();
600
        });
601
 
602
    });
603
 
604
 
6521 efrain 605
    $('#my-coach-question-answer-btn-answer').click(function(e) {
606
        e.preventDefault();
6547 efrain 607
        console.log('agregar respuesta link = ' + $(this).data('link') );
6521 efrain 608
 
6547 efrain 609
        $('#modal-answer-title').html('LABEL_MY_COACH_ANSWER_ADD');
6521 efrain 610
        $('#form-answer').attr('action', $(this).data('link') );
6547 efrain 611
        $('#form-answer').data('method','add');
612
        $('#form-answer').data('answer', '');
6521 efrain 613
        CKEDITOR.instances.description_answer.setData('');
6547 efrain 614
        validatorAnswer.resetForm();
6521 efrain 615
 
616
        $('#modal-answer').modal('show');
617
    });
618
 
619
    $('body').on('click', 'a.btn-comment-trash', function(e) {
620
        e.preventDefault();
621
        var action = $(this).data('link');
622
        var unique = $(this).data('comment-unique');
623
        var answer_uuid = $(this).data('answer-uuid');
624
        var question_uuid = $('#row-view').data('question-uuid');
625
 
626
 
627
 
628
        NProgress.start();
629
        $.ajax({
630
            'dataType'  : 'json',
631
            'accept'    : 'application/json',
632
            'method'    : 'post',
633
            'url'       :  action,
634
        }).done(function(response) {
635
            if(response['success']) {
636
                $('div.comment-' + unique).remove();
637
 
638
                //Listado de la respuesta
639
                $('#answer-total-comment-' + answer_uuid).html( response['data']['total_comments_answer'] );
640
 
641
                //Encabezado pregunta del view
6649 stevensc 642
                $('#my-coach-question-answer-count-comments').html( response['data']['total_comments_question'] + ' LABEL_COMMENTS');
6521 efrain 643
 
644
                //Listado de preguntas
645
                $('#comments-' + question_uuid).html( response['data']['total_comments_question'] );
646
 
647
 
648
            } else {
649
                $.fn.showError(response['data']);
650
            }
651
        }).fail(function( jqXHR, textStatus, errorThrown) {
652
            $.fn.showError(textStatus);
653
        }).always(function() {
654
            NProgress.done();
655
        });
656
 
657
    });
658
 
659
    $('body').on('submit', 'form.feedCommentContainer', function(e) {
660
        e.preventDefault();
661
 
662
        var action          = $(this).attr('action');
663
        var answer_uuid     = $(this).data('answer');
664
        var question_uuid   = $('#row-view').data('question-uuid');
665
        var form_id         = $(this).attr('id');
666
 
667
        var comment = $('#' + form_id + ' #comment').val().trim();
668
        if(comment.length == 0) {
669
            return;
670
        }
671
 
672
        NProgress.start();
673
        $.ajax({
674
            'dataType'  : 'json',
675
            'accept'    : 'application/json',
676
            'method'    : 'post',
677
            'url'       : action,
678
            'data'      : $(this).serialize()
679
 
680
        }).done(function(response) {
681
		  if(response['success']) {
682
            $('#' + form_id + ' #comment').val('');
683
            $('#comment-list-' + answer_uuid).prepend(
684
                $( "#commentTemplate" ).render( response['data']['item'] )
685
            );
686
 
687
            //Listado de la respuesta
688
            $('#answer-total-comment-' + answer_uuid).html( response['data']['total_comments_answer'] );
689
 
690
            //Encabezado pregunta del view
6649 stevensc 691
            $('#my-coach-question-answer-count-comments').html( response['data']['total_comments_question'] + ' LABEL_COMMENTS');
6521 efrain 692
 
693
            //Listado de preguntas
694
            $('#comments-' + question_uuid).html( response['data']['total_comments_question'] );
695
 
696
          } else {
697
            $.fn.showError(textStatus);
698
          }
699
 
700
        }).fail(function( jqXHR, textStatus, errorThrown) {
701
            $.fn.showError(textStatus);
702
        }).always(function() {
703
            NProgress.done();
704
        });
705
        return false;
706
 
707
    });
708
 
709
  $('body').on('click', 'button.btn-save-reaction', function(e) {
710
        e.preventDefault();
711
        var reaction = $(this).data('reaction');
712
        var action = $(this).data('link');
713
        var answer_uuid = $(this).data('answer');
714
        var question_uuid   = $('#row-view').data('question-uuid');
715
 
716
        NProgress.start();
717
        $.ajax({
718
            'dataType'  : 'json',
719
            'accept'    : 'application/json',
720
            'method'    : 'post',
721
            'url'       :  action,
722
            'data'      : {
723
                'reaction' : reaction
724
            }
725
        }).done(function(response) {
726
            if(response['success']) {
727
 
728
                $('#reactions-' + question_uuid).html(response['data']['total_reactions_question']) ;
6649 stevensc 729
                $('#my-coach-question-answer-count-reactions').html(response['data']['total_reactions_question'] + ' LABEL_MY_COACH_REACTIONS') ;
6521 efrain 730
                $('#answer-total-reactions-' + answer_uuid).html(response['data']['total_reactions_answer']) ;
731
 
732
                $('#' + 'current-reaction-' + answer_uuid).data('reaction', response['data']['reaction']);
733
                $('#' + 'current-reaction-' + answer_uuid).html(
734
                    $('#reactionTemplate').render({reaction: reaction})
735
                );
736
            } else {
737
                $.fn.showError(response['data']);
738
            }
739
        }).fail(function( jqXHR, textStatus, errorThrown) {
740
            $.fn.showError(textStatus);
741
        }).always(function() {
742
            NProgress.done();
743
        });
744
 
745
    });
746
 
747
    $('body').on('click', 'button.reaction-btn', function(e) {
748
        e.preventDefault();
749
        var reaction = $(this).data('reaction');
750
 
751
        if(!reaction) return
752
        var action = $(this).data('link');
753
 
754
        var answer_uuid = $(this).data('answer');
755
        var question_uuid   = $('#row-view').data('question-uuid');
756
 
757
        NProgress.start();
758
        $.ajax({
759
            'dataType'  : 'json',
760
            'accept'    : 'application/json',
761
            'method'    : 'post',
762
            'url'       :  action,
763
        }).done(function(response) {
764
            if(response['success']) {
765
                $('#' + 'current-reaction-' + answer_uuid).data('reaction', response['data']['reaction']);
766
                $('#' + 'current-reaction-' + answer_uuid).html(
767
                    $('#reactionTemplate').render({reaction: ''})
768
                );
769
 
770
                $('#reactions-' + question_uuid).html(response['data']['total_reactions_question']) ;
6649 stevensc 771
                $('#my-coach-question-answer-count-reactions').html(response['data']['total_reactions_question'] + ' LABEL_MY_COACH_REACTIONS') ;
6521 efrain 772
                $('#answer-total-reactions-' + answer_uuid).html(response['data']['total_reactions_answer']) ;
773
 
774
            } else {
775
                $.fn.showError(response['data']);
776
            }
777
        }).fail(function( jqXHR, textStatus, errorThrown) {
778
            $.fn.showError(textStatus);
779
        }).always(function() {
780
            NProgress.done();
781
        });
782
    });
783
 
784
    let isMouseHover;
785
 
786
    $('body').on('mouseover', '#reaction-container', function(e) {
787
        isMouseHover = true;
6581 stevensc 788
 
6582 stevensc 789
        setTimeout(() => $(e.target).find('.reactions').addClass('active'), 500);
6521 efrain 790
    });
6581 stevensc 791
 
6521 efrain 792
    $('body').on('mouseout', '#reaction-container', function(e) {
793
        isMouseHover = false;
6581 stevensc 794
 
6583 stevensc 795
        setTimeout(() => !isMouseHover && $(e.target).find('.reactions').removeClass('active'), 500);
6521 efrain 796
    });
797
 
798
    $('#paginator-process-comm').click(function(e) {
799
        e.preventDefault();
800
 
801
        var next_page = $(this).data('next-page');
802
        $.fn.reload(false, next_page);
803
 
804
    });
805
 
6388 efrain 806
    $.fn.reload()
807
 
808
    CKEDITOR.replace('description_question',{
809
        toolbar: [
810
                    { name: 'editing', items: ['Scayt'] },
811
                    { name: 'links', items: ['Link', 'Unlink'] },
812
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
813
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
814
                    '/',
815
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
816
                    { name: 'styles', items: ['Styles', 'Format'] },
817
                    { name: 'tools', items: ['Maximize'] }
818
                ],
819
                removePlugins: 'elementspath,Anchor',
820
                heigth: 100
821
    });
6521 efrain 822
 
823
    CKEDITOR.replace('description_answer',{
824
        toolbar: [
825
                    { name: 'editing', items: ['Scayt'] },
826
                    { name: 'links', items: ['Link', 'Unlink'] },
827
                    { name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'] },
828
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Strike', 'RemoveFormat'] },
829
                    '/',
830
                    { name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar'] },
831
                    { name: 'styles', items: ['Styles', 'Format'] },
832
                    { name: 'tools', items: ['Maximize'] }
833
                ],
834
                removePlugins: 'elementspath,Anchor',
835
                heigth: 100
836
    });
6388 efrain 837
});
5050 efrain 838
JS;
6388 efrain 839
 
840
$this->inlineScript()->captureEnd();
841
$this->headLink()->appendStylesheet('/look-and-field/my-coach.css');
5050 efrain 842
?>
843
 
6645 stevensc 844
<section class="container px-0 d-flex flex-column gap-3">
6388 efrain 845
    <div class="company-title">
6645 stevensc 846
        <h1 class="title">LABEL_MY_COACH</h1>
6552 stevensc 847
        <?php if ($allowQuestionAdd) : ?>
6388 efrain 848
            <h2 class="title cursor-pointer" id="my-coach-add-question">
849
                LABEL_MY_COACH_QUESTION_ADD
850
            </h2>
6552 stevensc 851
        <?php endif; ?>
5050 efrain 852
 
6388 efrain 853
    </div>
5050 efrain 854
 
6388 efrain 855
    <div class="row gap-3" id="row-list">
6552 stevensc 856
        <div class="my-coach-category-list col-12 col-md-3">
6388 efrain 857
            <ul>
858
                <li class="my-coach-category-li my-coach-category-li-selected">
859
                    <a class="my-coach-category-a" href="" data-uuid="">LABEL_MY_COACH_CATEGORY_ALL</a>
860
                </li>
861
                <?php
6521 efrain 862
                foreach ($categories as $uuid => $name) :
6388 efrain 863
                ?>
864
                    <li class="my-coach-category-li">
6521 efrain 865
                        <a class="my-coach-category-a" href="" data-uuid="<?php echo $uuid ?>"><?php echo $name ?></a>
6388 efrain 866
                    </li>
867
 
868
                <?php endforeach; ?>
869
            </ul>
870
        </div>
871
 
872
 
873
        <div class="col px-0">
874
            <div class="search-box">
875
                <form id="form-filter" name="form-filter">
876
                    <input type="text" name="search" id="search" class="form-control"><button class="btn btn-search">LABEL_SEARCH</button>
877
                </form>
878
            </div>
879
 
6644 stevensc 880
            <div id="my-coach-record-list" class="my-coach-record-list mt-3 ">
6388 efrain 881
            </div>
882
 
883
            <div id="my-coach-pagination">
884
            </div>
885
 
886
        </div>
887
    </div>
6552 stevensc 888
 
889
 
6562 stevensc 890
    <div id="row-view" class="my-coach-answers-list" style="display: none">
6563 stevensc 891
        <div class="my-coach-record-card-container col-md-8 mx-auto">
892
            <div class="my-coach-record-card-details">
6562 stevensc 893
                <div class="my-coach-record-card-resume">
6563 stevensc 894
                    <img id="my-coach-question-user-image" src="" />
895
                    <p id="my-coach-question-user-name"></p>
6562 stevensc 896
                </div>
6597 stevensc 897
                <ul id="my-coach-answer-categories" class="my-coach-record-card-categories">
6596 stevensc 898
                </ul>
6563 stevensc 899
            </div>
6552 stevensc 900
 
6567 stevensc 901
            <h2 id="my-coach-question-title"></h2>
6568 stevensc 902
 
6595 stevensc 903
            <div class="d-flex flex-wrap align-items-center justify-content-between mb-3">
6568 stevensc 904
                <span id="my-coach-question-answer-question-date">LABEL_MY_COACH_QUESTION </span>
905
                <span id="my-coach-question-answer-last-date">LABEL_MY_COACH_LAST_ANSWER </span>
906
            </div>
907
 
6567 stevensc 908
            <p id="my-coach-question-description"></p>
6552 stevensc 909
 
6596 stevensc 910
            <div class="my-coach-record-card-info">
6648 stevensc 911
                <span id="my-coach-question-answer-count-answers"></span>
6649 stevensc 912
                <span id="my-coach-question-answer-count-reactions"></span>
913
                <span id="my-coach-question-answer-count-views"></span>
914
                <span id="my-coach-question-answer-count-comments"></span>
6596 stevensc 915
            </div>
6552 stevensc 916
 
6579 stevensc 917
            <div class="my-coach-record-card-actions">
6586 stevensc 918
                <button class="feed__share-option" id="my-coach-question-answer-btn-back"> <i class="fa fa-chevron-left" aria-hidden="true"></i> LABEL_BACK </button>
6584 stevensc 919
                <button class="feed__share-option" id="my-coach-question-answer-btn-answer"> <i class="fa fa-pencil" aria-hidden="true"></i> LABEL_REPLY </button>
920
                <button class="feed__share-option" id="my-coach-question-answer-btn-delete"> <i class="fa fa-trash" aria-hidden="true"></i> LABEL_DELETE </button>
6552 stevensc 921
            </div>
922
        </div>
923
 
6553 stevensc 924
        <div id="my-coach-question-answers-list" class="my-coach-answers-list">
6521 efrain 925
        </div>
6552 stevensc 926
    </div>
927
</section>
6521 efrain 928
 
6552 stevensc 929
 
6388 efrain 930
<!-- The Modal -->
931
<div class="modal" id="modal-question">
6646 stevensc 932
    <div class="modal-dialog  modal-lg">
6388 efrain 933
        <div class="modal-content">
934
 
935
            <!-- Modal Header -->
936
            <div class="modal-header">
6650 stevensc 937
                <h4 class="modal-title h4">LABEL_TOPIC_TO_WORK</h4>
6388 efrain 938
                <button type="button" class="close" data-dismiss="modal">&times;</button>
939
            </div>
940
 
941
            <!-- Modal body -->
942
            <div class="modal-body">
943
                <?php
944
                $form = $this->formQuestion;
945
                $form->setAttributes([
946
                    'method'    => 'post',
947
                    'name'      => 'form-questiom',
948
                    'id'        => 'form-question'
949
                ]);
950
 
951
                $form->prepare();
952
                echo $this->form()->openTag($form);
953
                ?>
954
                <div class="form-group">
955
                    <?php
956
                    $element = $form->get('title');
957
                    $element->setOptions(['label' => 'LABEL_TITLE']);
958
                    $element->setAttributes(['class' => 'form-control']);
959
 
960
                    echo $this->formLabel($element);
961
                    echo $this->formText($element);
962
                    ?>
963
                </div>
6552 stevensc 964
                <div class="form-group">
6388 efrain 965
                    <?php
966
                    $element = $form->get('description');
967
                    $element->setOptions(['label' => 'LABEL_DESCRIPTION']);
968
                    $element->setAttributes(['class' => 'form-control', 'id' => 'description_question']);
6552 stevensc 969
 
6388 efrain 970
                    echo $this->formLabel($element);
971
                    echo $this->formTextArea($element);
972
                    ?>
973
                </div>
974
                <div class="form-group">
975
                    <?php
6552 stevensc 976
 
6388 efrain 977
                    $element = $form->get('category_id');
978
                    $element->setOptions(['label' => 'LABEL_CATEGORY']);
6552 stevensc 979
 
6388 efrain 980
                    echo $this->formLabel($element);
981
                    echo $this->formSelect($element);
982
                    ?>
983
                </div>
984
                <div class="text-right">
985
                    <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
986
                    <button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
987
                </div>
988
                <?php echo $this->form()->closeTag($form); ?>
989
            </div>
990
 
991
 
992
        </div>
993
    </div>
994
</div>
6552 stevensc 995
 
6521 efrain 996
<div class="modal" id="modal-answer">
6647 stevensc 997
    <div class="modal-dialog modal-lg">
6521 efrain 998
        <div class="modal-content">
6388 efrain 999
 
6521 efrain 1000
            <!-- Modal Header -->
1001
            <div class="modal-header">
6647 stevensc 1002
                <h4 class="modal-title h4" id="modal-answer-title"></h4>
6521 efrain 1003
                <button type="button" class="close" data-dismiss="modal">&times;</button>
1004
            </div>
6388 efrain 1005
 
6521 efrain 1006
            <!-- Modal body -->
1007
            <div class="modal-body">
1008
                <?php
1009
                $form = $this->formAnswer;
1010
                $form->setAttributes([
1011
                    'method'    => 'post',
1012
                    'name'      => 'form-answer',
1013
                    'id'        => 'form-answer',
1014
                ]);
6388 efrain 1015
 
6521 efrain 1016
                $form->prepare();
1017
                echo $this->form()->openTag($form);
1018
                ?>
6552 stevensc 1019
                <div class="form-group">
6521 efrain 1020
                    <?php
1021
                    $element = $form->get('description');
1022
                    $element->setOptions(['label' => 'LABEL_TEXT']);
1023
                    $element->setAttributes(['class' => 'form-control', 'id' => 'description_answer']);
6552 stevensc 1024
 
6521 efrain 1025
                    echo $this->formLabel($element);
1026
                    echo $this->formTextArea($element);
1027
                    ?>
1028
                </div>
1029
                <div class="text-right">
1030
                    <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1031
                    <button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
1032
                </div>
1033
                <?php echo $this->form()->closeTag($form); ?>
1034
            </div>
6388 efrain 1035
 
6521 efrain 1036
 
1037
        </div>
1038
    </div>
1039
</div>
1040
 
1041
<script id="answerTemplate" type="text/x-jsrender">
6557 stevensc 1042
    <div class="my-coach-record-card-container col-md-8 mx-auto" id="row-{{:uuid}}">
6554 stevensc 1043
            <div class="my-coach-record-card-details">
6556 stevensc 1044
                <div class="my-coach-record-card-resume">
1045
                    <img src="{{:user_image}}" />
1046
                    <p>{{:user_name}}</p>
1047
                </div>
6594 stevensc 1048
                <div class="my-coach-record-card-info">
1049
                    <span>LABEL_PUBLISHED LABEL_AGO_SMALL {{:time_elapsed}}</span>
1050
                    <span id="answer-total-comment-{{:uuid}}">{{:total_comments}} LABEL_COMMENTS</span>
1051
                    <span id="answer-total-reactions-{{:uuid}}">{{:total_reactions}} LABEL_REACTIONS</span>
1052
                </div>
6553 stevensc 1053
            </div>
6554 stevensc 1054
 
6556 stevensc 1055
            {{:text}}
6553 stevensc 1056
 
6557 stevensc 1057
            <div class="my-coach-record-card-actions">
1058
                {{if link_edit }}
6660 stevensc 1059
                <button data-link="{{>link_edit}}" data-answer="{{:uuid}}" class="btn btn-my-coach-edit-answer feed__share-option"> <i class="fa fa-pencil" aria-hidden="true"></i> LABEL_EDIT </button>
6557 stevensc 1060
                {{/if}}
6547 efrain 1061
 
6557 stevensc 1062
                {{if link_delete }}
6661 stevensc 1063
                <button data-link="{{>link_delete}}" data-question="{{:question_uuid}}" data-answer="{{:uuid}}" class="btn btn-my-coach-delete-answer feed__share-option"> <i class="fa fa-trash" aria-hidden="true"></i> LABEL_DELETE </button>
6557 stevensc 1064
                {{/if}}
1065
 
6582 stevensc 1066
                <div class="position-relative feed__share-option" id="reaction-container">
6660 stevensc 1067
                    <button class="btn reaction-btn p-0" data-answer="{{:uuid}}" data-link="{{:link_reaction_delete}}" data-reaction="{{:reaction}}" id="current-reaction-{{:uuid}}">
6521 efrain 1068
                        {{if reaction === '<?php echo ContentReaction::REACTION_FUN ?>'}}
1069
                        <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="EmojiEmotionsIcon" style="color: rgb(255, 127, 80);">
1070
                            <path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM8.5 8c.83 0 1.5.67 1.5 1.5S9.33 11 8.5 11 7 10.33 7 9.5 7.67 8 8.5 8zM12 18c-2.28 0-4.22-1.66-5-4h10c-.78 2.34-2.72 4-5 4zm3.5-7c-.83 0-1.5-.67-1.5-1.5S14.67 8 15.5 8s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></path>
1071
                        </svg>
1072
                        LABEL_REACTION_FUN
1073
                        {{/if}}
1074
 
1075
                        {{if reaction === '<?php echo ContentReaction::REACTION_INTEREST ?>'}}
1076
                        <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="TungstenIcon" style="color: rgb(245, 187, 92);transform: rotate(180deg);">
1077
                            <path d="M11 19h2v3h-2zm-9-8h3v2H2zm17 0h3v2h-3zm-3.106 6.8014 1.4072-1.4071 2.1213 2.1213-1.4071 1.4071zm-11.3099.7071 2.1214-2.1213 1.4071 1.4072-2.1213 2.1213zM15 8.02V3H9v5.02c-1.21.92-2 2.35-2 3.98 0 2.76 2.24 5 5 5s5-2.24 5-5c0-1.63-.79-3.06-2-3.98zM11 5h2v2.1c-.32-.06-.66-.1-1-.1s-.68.04-1 .1V5z"></path>
1078
                        </svg>
1079
                        LABEL_REACTION_INTEREST
1080
                        {{/if}}
1081
 
1082
 
1083
                        {{if reaction === '<?php echo ContentReaction::REACTION_LOVE ?>'}}
1084
                        <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="FavoriteTwoToneIcon" style="color: rgb(223, 112, 77);">
1085
                            <path d="M16.5 5c-1.54 0-3.04.99-3.56 2.36h-1.87C10.54 5.99 9.04 5 7.5 5 5.5 5 4 6.5 4 8.5c0 2.89 3.14 5.74 7.9 10.05l.1.1.1-.1C16.86 14.24 20 11.39 20 8.5c0-2-1.5-3.5-3.5-3.5z" opacity=".3"></path>
1086
                            <path d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z"></path>
1087
                        </svg>
1088
                        LABEL_REACTION_LOVE
1089
                        {{/if}}
1090
 
1091
 
1092
                        {{if reaction === '<?php echo ContentReaction::REACTION_RECOMMENDED ?>'}}
1093
                        <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="RecommendIcon" style="color: rgb(116, 5, 249);">
1094
                            <path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm6 9.8a.9.9 0 0 1-.1.5l-2.1 4.9a1.34 1.34 0 0 1-1.3.8H9a2 2 0 0 1-2-2v-5a1.28 1.28 0 0 1 .4-1L12 5l.69.69a1.08 1.08 0 0 1 .3.7v.2L12.41 10H17a1 1 0 0 1 1 1z"></path>
1095
                        </svg>
1096
                        LABEL_REACTION_RECOMMENDED
1097
                        {{/if}}
1098
 
1099
                        {{if reaction === '<?php echo ContentReaction::REACTION_SUPPORT ?>'}}
1100
                        <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="VolunteerActivismIcon" style="color: rgb(100, 149, 237);">
1101
                            <path d="M1 11h4v11H1zm15-7.75C16.65 2.49 17.66 2 18.7 2 20.55 2 22 3.45 22 5.3c0 2.27-2.91 4.9-6 7.7-3.09-2.81-6-5.44-6-7.7C10 3.45 11.45 2 13.3 2c1.04 0 2.05.49 2.7 1.25zM20 17h-7l-2.09-.73.33-.94L13 16h2.82c.65 0 1.18-.53 1.18-1.18 0-.49-.31-.93-.77-1.11L8.97 11H7v9.02L14 22l8.01-3c-.01-1.1-.9-2-2.01-2z"></path>
1102
                        </svg>
1103
                        LABEL_REACTION_SUPPORT
1104
                        {{/if}}
1105
 
1106
                        {{if reaction === ''}}
1107
                        <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="RecommendIcon" style="color: gray;">
1108
                            <path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm6 9.8a.9.9 0 0 1-.1.5l-2.1 4.9a1.34 1.34 0 0 1-1.3.8H9a2 2 0 0 1-2-2v-5a1.28 1.28 0 0 1 .4-1L12 5l.69.69a1.08 1.08 0 0 1 .3.7v.2L12.41 10H17a1 1 0 0 1 1 1z"></path>
1109
                        </svg>
1110
                        LABEL_REACTION_UNSET
1111
                        {{/if}}
1112
 
1113
 
1114
                    </button>
6582 stevensc 1115
                    <div class="reactions">
6521 efrain 1116
                        <button class="btn-save-reaction" data-link="{{:link_save_reaction}}" data-reaction="<?php echo ContentReaction::REACTION_RECOMMENDED ?>" title="LABEL_REACTION_RECOMMENDED" data-answer="{{:uuid}}">
1117
                            <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="RecommendIcon" style="color: rgb(116, 5, 249);">
1118
                                <path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm6 9.8a.9.9 0 0 1-.1.5l-2.1 4.9a1.34 1.34 0 0 1-1.3.8H9a2 2 0 0 1-2-2v-5a1.28 1.28 0 0 1 .4-1L12 5l.69.69a1.08 1.08 0 0 1 .3.7v.2L12.41 10H17a1 1 0 0 1 1 1z"></path>
1119
                            </svg>
1120
                        </button>
1121
                        <button class="btn-save-reaction" data-link="{{:link_save_reaction}}" data-reaction="<?php echo ContentReaction::REACTION_SUPPORT ?>" title="LABEL_REACTION_SUPPORT" data-answer="{{:uuid}}">
1122
                            <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="VolunteerActivismIcon" style="color: rgb(100, 149, 237);">
1123
                                <path d="M1 11h4v11H1zm15-7.75C16.65 2.49 17.66 2 18.7 2 20.55 2 22 3.45 22 5.3c0 2.27-2.91 4.9-6 7.7-3.09-2.81-6-5.44-6-7.7C10 3.45 11.45 2 13.3 2c1.04 0 2.05.49 2.7 1.25zM20 17h-7l-2.09-.73.33-.94L13 16h2.82c.65 0 1.18-.53 1.18-1.18 0-.49-.31-.93-.77-1.11L8.97 11H7v9.02L14 22l8.01-3c-.01-1.1-.9-2-2.01-2z"></path>
1124
                            </svg>
1125
                        </button>
1126
                        <button class="btn-save-reaction" data-link="{{:link_save_reaction}}" data-reaction="<?php echo ContentReaction::REACTION_LOVE ?>" title="LABEL_REACTION_LOVE" data-answer="{{:uuid}}">
1127
                            <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="FavoriteTwoToneIcon" style="color: rgb(223, 112, 77);">
1128
                                <path d="M16.5 5c-1.54 0-3.04.99-3.56 2.36h-1.87C10.54 5.99 9.04 5 7.5 5 5.5 5 4 6.5 4 8.5c0 2.89 3.14 5.74 7.9 10.05l.1.1.1-.1C16.86 14.24 20 11.39 20 8.5c0-2-1.5-3.5-3.5-3.5z" opacity=".3"></path>
1129
                                <path d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z"></path>
1130
                            </svg>
1131
                        </button>
1132
                        <button class="btn-save-reaction" data-link="{{:link_save_reaction}}" data-reaction="<?php echo ContentReaction::REACTION_INTEREST ?>" title="LABEL_REACTION_INTEREST" data-answer="{{:uuid}}">
1133
                            <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="TungstenIcon" style="color: rgb(245, 187, 92);transform: rotate(180deg);">
1134
                                <path d="M11 19h2v3h-2zm-9-8h3v2H2zm17 0h3v2h-3zm-3.106 6.8014 1.4072-1.4071 2.1213 2.1213-1.4071 1.4071zm-11.3099.7071 2.1214-2.1213 1.4071 1.4072-2.1213 2.1213zM15 8.02V3H9v5.02c-1.21.92-2 2.35-2 3.98 0 2.76 2.24 5 5 5s5-2.24 5-5c0-1.63-.79-3.06-2-3.98zM11 5h2v2.1c-.32-.06-.66-.1-1-.1s-.68.04-1 .1V5z"></path>
1135
                            </svg>
1136
                        </button>
1137
                        <button class="btn-save-reaction" data-link="{{:link_save_reaction}}" data-reaction="<?php echo ContentReaction::REACTION_FUN ?>" title="LABEL_REACTION_FUN" data-answer="{{:uuid}}">
1138
                            <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="EmojiEmotionsIcon" style="color: rgb(255, 127, 80);">
1139
                                <path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM8.5 8c.83 0 1.5.67 1.5 1.5S9.33 11 8.5 11 7 10.33 7 9.5 7.67 8 8.5 8zM12 18c-2.28 0-4.22-1.66-5-4h10c-.78 2.34-2.72 4-5 4zm3.5-7c-.83 0-1.5-.67-1.5-1.5S14.67 8 15.5 8s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></path>
1140
                             </svg>
1141
                        </button>
1142
                    </div>
1143
                </div>
1144
            </div>
1145
 
6656 stevensc 1146
            <div class="comments-container mt-2 show">
6521 efrain 1147
                <form class="feedCommentContainer"  id="form-comment-{{:uuid}}" class="form-comment-{{:uuid}}" action="{{:link_add_comment}}" data-answer="{{:uuid}}">
1148
                    <input class="commentInput" type="text" name="comment" id="comment" maxlength="256" placeholder="LABEL_WRITE_A_COMMENT">
1149
                    <button class="btn btn-primary" type="submit">LABEL_SEND</button>
1150
                </form>
1151
                <ul id="comment-list-{{:uuid}}" class="comment-list">
1152
                    {{for comments}}
1153
 
1154
                    <li>
1155
                        <div class="comment-container">
1156
	                       <div class="comment-content comment-{{:unique}}" >
1157
	                           <div class="info">
1158
                                    <a href="{{>user_url}}">
1159
                                        <h3>{{>user_name}}</h3>
1160
                                    </a>
1161
                                    <span>
1162
                                        {{>time_elapsed}}
1163
                                        {{if link_delete}}
1164
                                        <a href="#" class="btn-comment-trash" data-link="{{:link_delete}}" data-comment-unique="{{>unique}}" data-answer-uuid="{{>answer_uuid}}">
1165
                                        <i class="fa fa-trash"></i>
1166
                                        </a>
1167
                                        {{/if}}
1168
                                    </span>
1169
                                </div>
1170
		                        <p>{{>comment}}</p>
1171
		                  </div>
1172
	                   </div>
1173
                    </li>
1174
 
1175
 
1176
                    {{/for}}
1177
                </ul>
1178
 
1179
            </div>
1180
    </div>
1181
</script>
1182
 
1183
<script id="reactionTemplate" type="text/x-jsrender">
6552 stevensc 1184
    {{if reaction === '<?php echo ContentReaction::REACTION_FUN ?>'}}
1185
    <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="EmojiEmotionsIcon" style="color: rgb(255, 127, 80);">
1186
        <path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM8.5 8c.83 0 1.5.67 1.5 1.5S9.33 11 8.5 11 7 10.33 7 9.5 7.67 8 8.5 8zM12 18c-2.28 0-4.22-1.66-5-4h10c-.78 2.34-2.72 4-5 4zm3.5-7c-.83 0-1.5-.67-1.5-1.5S14.67 8 15.5 8s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"></path>
1187
    </svg>
1188
    LABEL_REACTION_FUN
1189
    {{/if}}
6521 efrain 1190
 
6552 stevensc 1191
    {{if reaction === '<?php echo ContentReaction::REACTION_INTEREST ?>'}}
1192
    <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="TungstenIcon" style="color: rgb(245, 187, 92);transform: rotate(180deg);">
1193
        <path d="M11 19h2v3h-2zm-9-8h3v2H2zm17 0h3v2h-3zm-3.106 6.8014 1.4072-1.4071 2.1213 2.1213-1.4071 1.4071zm-11.3099.7071 2.1214-2.1213 1.4071 1.4072-2.1213 2.1213zM15 8.02V3H9v5.02c-1.21.92-2 2.35-2 3.98 0 2.76 2.24 5 5 5s5-2.24 5-5c0-1.63-.79-3.06-2-3.98zM11 5h2v2.1c-.32-.06-.66-.1-1-.1s-.68.04-1 .1V5z"></path>
1194
    </svg>
1195
    LABEL_REACTION_INTEREST
1196
    {{/if}}
6521 efrain 1197
 
1198
 
6552 stevensc 1199
    {{if reaction === '<?php echo ContentReaction::REACTION_LOVE ?>'}}
1200
    <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="FavoriteTwoToneIcon" style="color: rgb(223, 112, 77);">
1201
        <path d="M16.5 5c-1.54 0-3.04.99-3.56 2.36h-1.87C10.54 5.99 9.04 5 7.5 5 5.5 5 4 6.5 4 8.5c0 2.89 3.14 5.74 7.9 10.05l.1.1.1-.1C16.86 14.24 20 11.39 20 8.5c0-2-1.5-3.5-3.5-3.5z" opacity=".3"></path>
1202
        <path d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z"></path>
1203
    </svg>
1204
    LABEL_REACTION_LOVE
1205
    {{/if}}
6521 efrain 1206
 
1207
 
6552 stevensc 1208
    {{if reaction === '<?php echo ContentReaction::REACTION_RECOMMENDED ?>'}}
1209
    <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="RecommendIcon" style="color: rgb(116, 5, 249);">
1210
        <path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm6 9.8a.9.9 0 0 1-.1.5l-2.1 4.9a1.34 1.34 0 0 1-1.3.8H9a2 2 0 0 1-2-2v-5a1.28 1.28 0 0 1 .4-1L12 5l.69.69a1.08 1.08 0 0 1 .3.7v.2L12.41 10H17a1 1 0 0 1 1 1z"></path>
1211
    </svg>
1212
    LABEL_REACTION_RECOMMENDED
1213
    {{/if}}
6521 efrain 1214
 
6552 stevensc 1215
    {{if reaction === '<?php echo ContentReaction::REACTION_SUPPORT ?>'}}
1216
    <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="VolunteerActivismIcon" style="color: rgb(100, 149, 237);">
1217
        <path d="M1 11h4v11H1zm15-7.75C16.65 2.49 17.66 2 18.7 2 20.55 2 22 3.45 22 5.3c0 2.27-2.91 4.9-6 7.7-3.09-2.81-6-5.44-6-7.7C10 3.45 11.45 2 13.3 2c1.04 0 2.05.49 2.7 1.25zM20 17h-7l-2.09-.73.33-.94L13 16h2.82c.65 0 1.18-.53 1.18-1.18 0-.49-.31-.93-.77-1.11L8.97 11H7v9.02L14 22l8.01-3c-.01-1.1-.9-2-2.01-2z"></path>
1218
    </svg>
1219
    LABEL_REACTION_SUPPORT
1220
    {{/if}}
1221
 
1222
    {{if reaction === ''}}
1223
    <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="RecommendIcon" style="color: gray;">
1224
        <path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm6 9.8a.9.9 0 0 1-.1.5l-2.1 4.9a1.34 1.34 0 0 1-1.3.8H9a2 2 0 0 1-2-2v-5a1.28 1.28 0 0 1 .4-1L12 5l.69.69a1.08 1.08 0 0 1 .3.7v.2L12.41 10H17a1 1 0 0 1 1 1z"></path>
1225
    </svg>
1226
    LABEL_REACTION_UNSET
1227
    {{/if}}
6521 efrain 1228
</script>
1229
 
1230
<script id="commentTemplate" type="text/x-jsrender">
1231
    <li>
1232
        <div class="comment-container">
1233
	        <div class="comment-content comment-{{:unique}}" >
1234
	            <div class="info">
1235
                    <a href="{{>user_url}}">
1236
                        <h3>{{>user_name}}</h3>
1237
                    </a>
1238
                    <span>
1239
                        {{>time_elapsed}}
1240
                        {{if link_delete}}
1241
                        <a href="#" class="btn-comment-trash" data-link="{{:link_delete}}" data-comment-unique="{{>unique}}"  data-answer-uuid="{{>answer_uuid}}">
1242
                            <i class="fa fa-trash"></i>
1243
                        </a>
1244
                        {{/if}}
1245
                    </span>
1246
                </div>
1247
		      <p>{{>comment}}</p>
1248
		  </div>
1249
	   </div>
1250
    </li>
1251
</script>
1252
 
6388 efrain 1253
<script id="recordTemplate" type="text/x-jsrender">
6644 stevensc 1254
    <div class="my-coach-record-card-container col" id="my-coach-record-card-question-{{:uuid}}">
6594 stevensc 1255
        <div class="my-coach-record-card-details">
1256
            <div class="my-coach-record-card-resume" >
1257
                <img class="my_coach_question_detail_user_image" src="{{:user_image}}" />
1258
                <p class="my_coach_question_detail_user_name">{{:user_name}}</p>
1259
            </div>
6651 stevensc 1260
            <ul class="my-coach-record-card-categories">
1261
                {{for categories}}
1262
                <li>{{:category}}</li>
1263
                {{/for}}
1264
            </ul>
6388 efrain 1265
        </div>
6652 stevensc 1266
        <h2>{{>title}}</h2>
1267
        <span>LABEL_MY_COACH_QUESTION {{:added_on}}</span>
1268
        <p class="my-3">{{>description}}</p>
6651 stevensc 1269
        <div class="my-coach-record-card-info mb-2">
1270
            <span id="answers-{{:uuid}}">{{:answers}} LABEL_MY_COACH_ANSWERS</span>
1271
            <span id="reactions-{{:uuid}}">{{:reactions}} LABEL_MY_COACH_REACTIONS</span>
1272
            <span id="views-{{:uuid}}">{{:views}} LABEL_MY_COACH_VIEWS</span>
1273
            <span id="comments-{{:uuid}}">{{:comments}} LABEL_COMMENTS</span>
1274
        </div>
6654 stevensc 1275
        <div class="my-coach-record-card-actions">
6655 stevensc 1276
            <button data-link="{{:link_view}}" class="btn feed__share-option btn-my-coach-edit-view"> <i class="fa fa-external-link" aria-hidden="true"></i> LABEL_VIEW </button>
6594 stevensc 1277
 
1278
            {{if link_edit }}
6662 stevensc 1279
            <button data-link="{{>link_edit}}" class="btn feed__share-option btn-my-coach-edit-view"> <i class="fa fa-pencil" aria-hidden="true"></i> LABEL_EDIT </button>
6594 stevensc 1280
            {{/if}}
1281
            {{if link_delete }}
6655 stevensc 1282
            <button data-link="{{>link_delete}}" class="btn feed__share-option btn-my-coach-delete-question"> <i class="fa fa-trash" aria-hidden="true"></i> LABEL_DELETE </button>
6594 stevensc 1283
            {{/if}}
1284
        </div>
1285
    </div>
6552 stevensc 1286
</script>