1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-01 08:26:03 +00:00
webvirtcloud/instances/templates/add_instance_owner_block.html
catborise aefe551450 feat(ui): the owner and VM lists of the ownership forms are searchable
The VM page's Add owner and a user's Add VM page listed every user and
every VM in a plain drop-down: with 800 users and 300 VMs one was found
by scrolling. They now have a search box (Tom Select, already used by the
create form), through searchable_select.js for a select with
data-searchable.

The box loses focus once an item is chosen: focused, it is a line taller,
and on a phone the tap on Save shrank it and moved the button away from
under the finger, so the first tap did nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
2026-11-10 09:21:25 +03:00

35 lines
2.2 KiB
HTML

{% load i18n %}
{% load bootstrap_icons %}
{% if request.user.is_superuser %}
<button type="button" class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#addInstanceOwner">{% bs_icon 'plus' %} {% trans "Add owner" %}</button>
<div class="modal fade" id="addInstanceOwner" tabindex="-1" role="dialog" aria-labelledby="addInstanceOwnerLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addInstanceOwnerLabel">{% trans "Add owner" %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="{% trans "Close" %}"></button>
</div>
<div class="modal-body">
<form id="add-owner-form" method="post" action="{% url 'instances:add_owner' instance.id %}" role="form" aria-label="Add instance owner form">{% csrf_token %}
{# users who are not owners yet; a superuser can use every VM #}
{% if users %}
<label class="form-label" for="add-owner-user">{% trans "User" %}</label>
<select class="form-select" name="user_id" id="add-owner-user" data-searchable>
{% for user in users %}
<option value="{{ user.id }}">{{ user.username }}</option>
{% endfor %}
</select>
{% else %}
<p class="mb-0">{% trans "Every user who is not an administrator is already an owner." %}</p>
{% endif %}
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
<button type="submit" class="btn btn-primary" form="add-owner-form"{% if not users %} disabled{% endif %}>{% trans "Add" %}</button>
</div>
</div> <!-- /.modal-content -->
</div> <!-- /.modal-dialog -->
</div> <!-- /.modal -->
{% endif %}