Inventur/templates/table_owned_modals.html.tera
Johannes Randerath 61708e5199 Sharing tables readonly with other users
- Added sharing feature for table owners to share their tables with
  other registered users.
- Fixed a bug where the wrong entries would be deleted or modified when
  searching or filtering.
2024-09-01 20:17:14 +02:00

66 lines
3.3 KiB
Plaintext

{% block modal_share_table %}
<!-- Share table -->
<div class="modal fade" id="share_table_modal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5">
Share table
</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" onclick="$( '#form_share_table' ).trigger('reset');"></button>
</div>
<div class="modal-body">
<form action="/table/share" method="post" id="form_share_table" onreset="$('.2benabled').prop('disabled', false);">
<input name="tblid" value="{{ tblid }}" hidden>
{% for user in shared %}
<div class="row py-1">
<div class="col-auto">
<input value="{{ user.username }}" readonly id="form_share_table_user_{{ user.id }}" class="form-control 2benabled" />
<input value="{{ user.id }}" name="sharees" hidden />
</div>
<div class="col-auto form-check form-check-inline pt-2">
<label for="form_share_table_ro_{{ user.id }}" class="form-check-label"> Read only </label>
<input id="form_share_table_ro_{{ user.id }}" type="checkbox" class="form-check-input 2benabled" {% if user.readonly %}checked{% endif %} onchange="$('#form_share_table_action_ro_{{ user.id }}').val($(this).is(':checked'));" />
</div>
<div class="col-auto">
<input id="form_share_table_action_ro_{{ user.id }}" name="readonly" value="{{ user.readonly }}" hidden>
<input id="form_share_table_action_del_{{ user.id }}" name="delete" value="false" hidden>
<button id="form_share_table_delete_button_{{ user.id }}" class="btn btn-outline-danger 2benabled" type="button" onclick="$('#form_share_table_action_del_{{ user.id }}').val(true); $('#form_share_table_ro_{{ user.id }}').prop('disabled', true); $('#form_share_table_user_{{ user.id }}').prop('disabled', true); $('#form_share_table_delete_button_{{ user.id }}').prop('disabled', true);"><i class="bi bi-trash3"></i></button>
</div>
</div>
{% endfor %}
<div class="row py-1">
<div class="col-auto">
<input id="form_share_table_new_user_input" placeholder="User" class="form-control" onchange="query_users($(this).val());" autofocus autocomplete="off" />
<input id="form_share_table_new_user_id" name="new_user" hidden>
<div class="card text-bg-light mt-2">
<ul class="list-group list-group-flush" id="form_share_table_select_new_user">
<!-- users to select from -->
</ul>
</div>
</div>
<div class="col-auto form-check form-check-inline pt-2">
<label for="form_share_table_new_ro">Read-only</label>
<input name="readonly" type="checkbox" class="form-check-input" checked />
</div>
<div class="col-auto">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<div class="row justify-content-betwen">
<div class="col-auto">
</div>
<div class="col-auto">
<button class="btn btn-secondary" data-bs-dismiss="modal" onclick="$('#form_share_table').trigger('reset');"><i class="bi bi-x"></i></button>
<button class="btn btn-primary" onclick="$('#form_share_table').trigger('submit').trigger('reset');"><i class="bi bi-check-lg"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock modal_share_table %}