{% extends 'base.html.twig' %}
{% block title %}Question: {{ question.name }}{% endblock %}
{% block body %}
<div class="container">
<div class="row">
<div class="col-12">
<h2 class="my-4">
Topic:
<a href="#link-to-topic">{{ question.topic.name }}</a>
</h2>
<h2 class="my-4">Question:</h2>
<div style="box-shadow: 2px 3px 9px 4px rgba(0,0,0,0.04);">
<div class="q-container-show p-4">
<div class="row">
<div class="col-2 text-center">
<img src="{{ asset(question.askedBy.avatarUrl) }}" width="100" height="100" alt="Tisha avatar">
<div class="mt-3">
<small>
{% if question.isApproved %}
Asked <br>
{{ question.createdAt|ago }}
{% else %}
(unpublished)
{% endif %}
</small>
<form action="{{ path('app_question_vote', { slug: question.slug }) }}" method="POST">
<div class="vote-arrows vote-arrows-alt flex-fill pt-2" style="min-width: 90px;">
<button class="vote-up btn btn-link" name="direction" value="up"><i class="far fa-arrow-alt-circle-up"></i></button>
<button class="vote-down btn btn-link" name="direction" value="down"><i class="far fa-arrow-alt-circle-down"></i></button>
<span>{{ question.votesString }}</span>
</div>
</form>
</div>
</div>
<div class="col">
<div class="col">
<div class="d-flex justify-content-between">
<h1 class="q-title-show">{{ question.name }}</h1>
{% if is_granted('ROLE_ADMIN') %}
<a class="text-white" href="{{ ea_url()
.setController('App\\Controller\\Admin\\QuestionCrudController')
.setAction('edit')
.setEntityId(question.id)
}}">
<span class="fa fa-edit"></span>
</a>
{% endif %}
</div>
</div>
<div class="q-display p-3">
<i class="fa fa-quote-left mr-3"></i>
<p class="d-inline">{{ question.question }}</p>
<p class="pt-4"><strong>--{{ question.askedBy.fullName }}</strong></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-between my-4">
<h2 class="">Answers <span style="font-size:1.2rem;">({{ question.answers|length }})</span></h2>
<button class="btn btn-sm btn-secondary">Submit an Answer</button>
</div>
<ul class="list-unstyled">
{% for answer in question.answers %}
<li class="mb-4">
<div class="d-flex justify-content-center">
<div class="mr-2 pt-2">
<img src="{{ asset(answer.answeredBy.avatarUrl) }}" width="50" height="50" alt="Tisha avatar">
</div>
<div class="mr-3 pt-2">
{{ answer.answer }}
<p>-- {{ answer.answeredBy.fullName }}</p>
</div>
<div class="vote-arrows flex-fill pt-2 js-vote-arrows" style="min-width: 90px;">
<button class="vote-up btn btn-link" name="direction" value="up"><i class="far fa-arrow-alt-circle-up"></i></button>
<button class="vote-down btn btn-link" name="direction" value="down"><i class="far fa-arrow-alt-circle-down"></i></button>
<span>{{ answer.votesString }}</span>
</div>
</div>
</li>
{% else %}
<li class="mb-4">
<div class="d-flex justify-content-center">
Be the first to answer!
</div>
</li>
{% endfor %}
</ul>
</div>
{% endblock %}