first push
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
{% extends 'layouts/main-layout.html' %}
|
||||
{% block content %}
|
||||
<div class="page-heading">
|
||||
<div class="page-title">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6 order-md-1 order-last">
|
||||
<h3>角色</h3>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 order-md-2 order-first">
|
||||
<nav aria-label="breadcrumb" class="breadcrumb-header float-start float-lg-end">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="/">Dashboard</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Roles</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<section class="section">
|
||||
<!-- Add Modal -->
|
||||
<div>
|
||||
<button type="button" class="btn btn-sm btn-outline-info my-3"
|
||||
hx-get="{% url 'roles:add' %}" hx-target="#add-role-modal-content"
|
||||
data-bs-toggle="modal" data-bs-target="#add-role-modal">添加角色</button>
|
||||
|
||||
<div class="modal fade text-left" id="add-role-modal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="myModalLabel160" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div id="add-role-modal-content" class="modal-content" hx-target="this"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- update modal -->
|
||||
<div class="modal fade text-left" id="update-role-modal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="myModalLabel160" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div id="update-role-modal-content" class="modal-content" hx-target="this"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
{% if page_object %}
|
||||
<div class="d-flex justify-content-end my-2 gap-2">
|
||||
<input name="search_text" type="search" class='dataTable-input' autocomplete="off" placeholder='Search here...'
|
||||
hx-get="{% url 'roles:search' page_object.number %}" hx-trigger="keyup changed delay:500ms, search" hx-target="#search_result">
|
||||
</div>
|
||||
{% endif %}
|
||||
<table class="table table-hover" id="table1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>序号</th>
|
||||
<th>角色</th>
|
||||
<th>权限</th>
|
||||
<th>状态</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% if page_object %}
|
||||
<tbody id="search_result">
|
||||
{% for role in page_object %}
|
||||
<tr>
|
||||
<td>{{page_object.start_index|add:forloop.counter0}}</td>
|
||||
<td>{{role.related_name}}</td>
|
||||
<td>
|
||||
<div class="badges" style="display:grid; grid-template-columns: auto auto auto auto; gap: 5px; ">
|
||||
{% for permission in role.permissions.all %}
|
||||
{% if 'add' in permission.name %}
|
||||
<span class="badge bg-primary">{{permission.name}}</span>
|
||||
{% elif 'view' in permission.name %}
|
||||
<span class="badge bg-success">{{permission.name}}</span>
|
||||
{% elif 'edit' in permission.name %}
|
||||
<span class="badge bg-info">{{permission.name}}</span>
|
||||
{% elif 'delete' in permission.name %}
|
||||
<span class="badge bg-danger">{{permission.name}}</span>
|
||||
{% else %}
|
||||
<span class="badge bg-warning">{{permission.name}}</span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="form-check form-switch">
|
||||
<input
|
||||
class="form-check-input"
|
||||
hx-post="{% url 'roles:status' role.name %}"
|
||||
hx-headers='{"X-CSRFToken":"{{ csrf_token }}"}'
|
||||
type="checkbox" {% if role.status %} checked {% endif %}
|
||||
style="cursor: pointer;"
|
||||
>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
|
||||
<button class="btn btn-info" hx-get="{% url 'roles:update' role.name %}" hx-target="#update-role-modal-content" data-bs-toggle="modal" data-bs-target="#update-role-modal"><i class="bi bi-pencil-square"></i></a></button>
|
||||
<form action="{% url 'roles:delete' role.name %}" method="post" onsubmit="return confirm('Are you sure you want to delete this?')">
|
||||
{% csrf_token %}
|
||||
<button type="submit" value="Delete" class="btn btn-sm btn-danger"><i class="bi bi-trash3-fill"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
{% else %}
|
||||
<div class="alert alert-info" role="alert">
|
||||
暂无记录
|
||||
</div>
|
||||
{% endif %}
|
||||
</table>
|
||||
{% include 'commons/pagination.html' %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
{% endblock content%}
|
||||
Reference in New Issue
Block a user