Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bootstrap grid for staff evaluation #1889

Merged
merged 11 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 47 additions & 51 deletions evap/staff/templates/staff_evaluation_textanswers_section.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,60 @@
<div class="card-body">
{% for result in results %}
<p>{{ result.question.text }}</p>
<table class="table table-striped{% if not forloop.last %} mb-4{% endif %}">
<thead>
<tr>
<th style="width: 75%">{% trans 'Text answer' %}</th>
<th style="width: 5%"></th>
<th style="width: 15%">{% trans 'Decision' %}</th>
<th style="width: 5%">{% trans 'Flag' %}</th>
</tr>
</thead>
<tbody>
{% for answer in result.answers %}
<tr id="{{ answer.id }}">
<td class="text-answer">
{{ answer.answer|linebreaksbr }}
{% if answer.original_answer %}
<br />
<span class="textanswer-original">({{ answer.original_answer|linebreaksbr }})</span>
{% endif %}
</td>
<td>
{% if user.is_manager %}
<a class="btn btn-sm btn-outline-secondary" href="{% url 'staff:evaluation_textanswer_edit' answer.id %}"><span class="fas fa-pencil"></a>
{% endif %}
</td>
<td>
<form class="full-update-textanswer-form" method="POST" action="{% url 'staff:evaluation_textanswers_update_publish' %}">
{% csrf_token %}
<div class="grid-striped container{% if not forloop.last %} mb-4{% endif %}">
<div class="row textanswer-review-grid-row fw-bold">
<div data-col="answer">{% trans 'Text answer' %}</div>
<div data-col="edit"></div>
<div data-col="review">{% trans 'Decision' %}</div>
<div data-col="flag">{% trans 'Flag' %}</div>
</div>
{% for answer in result.answers %}
<div class="row textanswer-review-grid-row" id="{{ answer.id }}">
<div data-col="answer" class="text-answer col">
{{ answer.answer|linebreaksbr }}
{% if answer.original_answer %}
<br />
<span class="textanswer-original">({{ answer.original_answer|linebreaksbr }})</span>
{% endif %}
</div>
<div data-col="edit">
{% if user.is_manager %}
<a class="btn btn-sm btn-outline-secondary" href="{% url 'staff:evaluation_textanswer_edit' answer.id %}"><span class="fas fa-pencil"></a>
{% endif %}
</div>
<div data-col="review">
<form class="full-update-textanswer-form" method="POST" action="{% url 'staff:evaluation_textanswers_update_publish' %}">
{% csrf_token %}

<input type="hidden" name="answer_id" value="{{ answer.id }}" />
<input type="hidden" name="answer_id" value="{{ answer.id }}" />

<div class="btn-group btn-group-sm" role="group">
<input type="radio" class="btn-check" name="action" value="publish" id="{{ answer.id }}-radio-publish" autocomplete="off" {% if answer.will_be_public %}checked{% endif %}>
<label class="btn btn-outline-primary" for="{{ answer.id }}-radio-publish">{% trans 'Publish' %}</label>
<div class="btn-group btn-group-sm" role="group">
<input type="radio" class="btn-check" name="action" value="publish" id="{{ answer.id }}-radio-publish" autocomplete="off" {% if answer.will_be_public %}checked{% endif %}>
<label class="btn btn-outline-primary" for="{{ answer.id }}-radio-publish">{% trans 'Publish' %}</label>

<input type="radio" class="btn-check" name="action" value="make_private" id="{{ answer.id }}-radio-private" autocomplete="off" {% if answer.will_be_private %}checked{% endif %} {% if not contributor %}disabled{% endif %}>
<label class="btn btn-outline-primary" for="{{ answer.id }}-radio-private">{% trans 'Private' %}</label>
<input type="radio" class="btn-check" name="action" value="make_private" id="{{ answer.id }}-radio-private" autocomplete="off" {% if answer.will_be_private %}checked{% endif %} {% if not contributor %}disabled{% endif %}>
<label class="btn btn-outline-primary" for="{{ answer.id }}-radio-private">{% trans 'Private' %}</label>

<input type="radio" class="btn-check" name="action" value="unreview" id="{{ answer.id }}-radio-undecided" autocomplete="off" {% if not answer.is_reviewed %}checked{% endif %}>
<label class="btn btn-outline-primary" for="{{ answer.id }}-radio-undecided">{% trans 'Undecided' %}</label>
<input type="radio" class="btn-check" name="action" value="unreview" id="{{ answer.id }}-radio-undecided" autocomplete="off" {% if not answer.is_reviewed %}checked{% endif %}>
<label class="btn btn-outline-primary" for="{{ answer.id }}-radio-undecided">{% trans 'Undecided' %}</label>

<input type="radio" class="btn-check" name="action" value="delete" id="{{ answer.id }}-radio-delete" autocomplete="off" {% if answer.will_be_deleted %}checked{% endif %}>
<label class="btn btn-outline-primary" for="{{ answer.id }}-radio-delete">{% trans 'Delete' %}</label>
</div>
</form>
</td>
<td class="text-center">
<form class="full-textanswer-flag-form" method="POST" action="{% url 'staff:evaluation_textanswers_update_flag' %}">
{% csrf_token %}
<input type="radio" class="btn-check" name="action" value="delete" id="{{ answer.id }}-radio-delete" autocomplete="off" {% if answer.will_be_deleted %}checked{% endif %}>
<label class="btn btn-outline-primary" for="{{ answer.id }}-radio-delete">{% trans 'Delete' %}</label>
</div>
</form>
</div>
<div data-col="flag" class="text-center">
<form class="full-textanswer-flag-form" method="POST" action="{% url 'staff:evaluation_textanswers_update_flag' %}">
{% csrf_token %}

<input type="hidden" name="answer_id" value="{{ answer.id }}" />
<input type="hidden" name="answer_id" value="{{ answer.id }}" />

{% include "staff_evaluation_textanswer_flag_radios.html" with is_initially_flagged=answer.is_flagged id=answer.id %}
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% include "staff_evaluation_textanswer_flag_radios.html" with is_initially_flagged=answer.is_flagged id=answer.id %}
</form>
</div>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
</div>
Expand Down
19 changes: 18 additions & 1 deletion evap/static/scss/components/_grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
background-color: $table-striped-bg;
}

// CSS Grid needs it the exact other way around as the title also has the row class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you missing a word here? this comment is hard to read.

.grid-striped .row:nth-of-type(even) {
background-color: $table-striped-bg;
}

.lcr-left {
flex: 1;
}
Expand Down Expand Up @@ -122,7 +127,19 @@
}
}

@each $col in name, semester, responsible, participants, result {
.textanswer-review-grid-row {
@extend %grid-row;

grid:
"answer edit review flag"
/ auto 2rem 285px 4.5rem;

min-height: 0;
padding: 0.5rem;
gap: 1rem;
}

@each $col in name, semester, responsible, participants, result, answer, edit, review, flag {
[data-col=#{$col}] {
grid-area: $col;
}
Expand Down