Skip to content

Commit 316adda

Browse files
committed
refactor(frontend): Use for-else for placeholders on show_role page.
1 parent a2e51ad commit 316adda

1 file changed

Lines changed: 21 additions & 25 deletions

File tree

templates/roles/show_role.html

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -140,29 +140,27 @@
140140
</tr>
141141
</thead>
142142
<tbody>
143-
<!-- Placeholder -->
144-
{% if users.len() == 0 %}
143+
{% for user in users %}
145144
<tr>
146-
<td colspan="4">No users mapped yet</td>
145+
<!-- Name -->
146+
<td data-label="Name">
147+
<a href="/users/{{ user.username }}">{{ user.username }}</a>
148+
</td>
149+
150+
<!-- Remove button -->
151+
<td>
152+
<form action="/roles/{{ role.id }}/users/{{ user.id }}" method="POST">
153+
<input type="hidden" name="_method" value="delete"/>
154+
<button class="button is-danger is-small" type="submit">x</button>
155+
</form>
156+
</td>
147157
</tr>
148158
{% else %}
149-
{% for user in users %}
150-
<tr>
151-
<!-- Name -->
152-
<td data-label="Name">
153-
<a href="/users/{{ user.username }}">{{ user.username }}</a>
154-
</td>
155-
156-
<!-- Remove button -->
157-
<td>
158-
<form action="/roles/{{ role.id }}/users/{{ user.id }}" method="POST">
159-
<input type="hidden" name="_method" value="delete"/>
160-
<button class="button is-danger is-small" type="submit">x</button>
161-
</form>
162-
</td>
163-
</tr>
164-
{% endfor %}
165-
{% endif %}
159+
<!-- Placeholder row -->
160+
<tr>
161+
<td colspan="4">No users mapped yet</td>
162+
</tr>
163+
{% endfor %}
166164
</tbody>
167165
</table>
168166
</div>
@@ -208,14 +206,12 @@
208206
</form>
209207
</td>
210208
</tr>
211-
{% endfor %}
212-
213-
<!-- Placeholder -->
214-
{% if clients.len() == 0 %}
209+
{% else %}
210+
<!-- Placeholder row -->
215211
<tr>
216212
<td colspan="4">No clients mapped yet</td>
217213
</tr>
218-
{% endif %}
214+
{% endfor %}
219215
</tbody>
220216
</table>
221217
</div>

0 commit comments

Comments
 (0)