first push

This commit is contained in:
2025-05-23 14:44:12 +08:00
commit abefd1b19b
817 changed files with 580289 additions and 0 deletions
+791
View File
@@ -0,0 +1,791 @@
<div class="modal-content">
<div class="modal-header bg-dark">
<h5
class="modal-title white w-100 text-center"
id="myModalLabel160"
>
添加角色
</h5>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<form hx-post="{{request.path}}" novalidate>
{% csrf_token %}
<div class="modal-body">
<div class="row">
<div class="form-group">
<label for="name" class="form-label">角色</label>
{{form.related_name}}
{% for error in form.related_name.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
<div class="form-group">
<h6 class="my-3">为角色分配权限</h6>
<table class="table mb-0" id="dataTable-1">
<thead>
<tr>
<th>
<input
type="checkbox"
class="align-middle checkbox_middle form-check-input"
name="checkall"
id="checkall"
/>
</th>
<th>模块</th>
<th>权限</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Vendors"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Vendors"
>供应商</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Vendors"
id="view_vendor"
name="permissions[]"
type="checkbox"
value="view_vendor"
/>
<label
for="view_vendor"
class="form-label font-weight-500"
>查看</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Vendors"
id="add_vendor"
name="permissions[]"
type="checkbox"
value="add_vendor"
/>
<label
for="add_vendor"
class="form-label font-weight-500"
>添加</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Vendors"
id="edit_vendor"
name="permissions[]"
type="checkbox"
value="edit_vendor"
/>
<label
for="edit_vendor"
class="form-label font-weight-500"
>编辑</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Vendors"
id="delete_vendor"
name="permissions[]"
type="checkbox"
value="delete_vendor"
/>
<label
for="delete_vendor"
class="form-label font-weight-500"
>删除</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Products"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Products"
>产品</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Products"
id="view_product"
name="permissions[]"
type="checkbox"
value="view_product"
/>
<label
for="view_product"
class="form-label font-weight-500"
>查看</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Products"
id="add_product"
name="permissions[]"
type="checkbox"
value="add_product"
/>
<label
for="add_product"
class="form-label font-weight-500"
>添加</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Products"
id="edit_product"
name="permissions[]"
type="checkbox"
value="edit_product"
/>
<label
for="edit_product"
class="form-label font-weight-500"
>编辑</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Products"
id="delete_product"
name="permissions[]"
type="checkbox"
value="delete_product"
/>
<label
for="delete_product"
class="form-label font-weight-500"
>删除</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="users"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="users"
>用户</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_users"
id="view_users"
name="permissions[]"
type="checkbox"
value="view_users"
/>
<label
for="view_users"
class="form-label font-weight-500"
>查看</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_users"
id="add_users"
name="permissions[]"
type="checkbox"
value="add_users"
/>
<label
for="add_users"
class="form-label font-weight-500"
>添加</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_users"
id="edit_users"
name="permissions[]"
type="checkbox"
value="edit_users"
/>
<label
for="edit_users"
class="form-label font-weight-500"
>编辑</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_users"
id="delete_users"
name="permissions[]"
type="checkbox"
value="delete_users"
/>
<label
for="delete_users"
class="form-label font-weight-500"
>删除</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Assets"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Assets"
>资产</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assets"
id="view_asset"
name="permissions[]"
type="checkbox"
value="view_asset"
/>
<label
for="view_asset"
class="form-label font-weight-500"
>查看</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assets"
id="add_asset"
name="permissions[]"
type="checkbox"
value="add_asset"
/>
<label
for="add_asset"
class="form-label font-weight-500"
>添加</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assets"
id="edit_asset"
name="permissions[]"
type="checkbox"
value="edit_asset"
/>
<label
for="edit_asset"
class="form-label font-weight-500"
>编辑</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assets"
id="delete_asset"
name="permissions[]"
type="checkbox"
value="delete_asset"
/>
<label
for="delete_asset"
class="form-label font-weight-500"
>删除</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Assign_Assets"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Assign_Assets"
>分配资产</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assign_Assets"
id="add_assign_asset"
name="permissions[]"
type="checkbox"
value="add_assign_asset"
/>
<label
for="add_assign_asset"
class="form-label font-weight-500"
>添加</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assign_Assets"
id="reassign_assign_asset"
name="permissions[]"
type="checkbox"
value="reassign_assign_asset"
/>
<label
for="reassign_assign_asset"
class="form-label font-weight-500"
>重新分配</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assign_Assets"
id="delete_assign_asset"
name="permissions[]"
type="checkbox"
value="delete_assign_asset"
/>
<label
for="delete_assign_asset"
class="form-label font-weight-500"
>取消分配</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Locations"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Locations"
>位置</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Locations"
id="view_location"
name="permissions[]"
type="checkbox"
value="view_location"
/>
<label
for="view_location"
class="form-label font-weight-500"
>查看</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Locations"
id="add_location"
name="permissions[]"
type="checkbox"
value="add_location"
/>
<label
for="add_location"
class="form-label font-weight-500"
>添加</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Locations"
id="edit_location"
name="permissions[]"
type="checkbox"
value="edit_location"
/>
<label
for="edit_location"
class="form-label font-weight-500"
>编辑</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Locations"
id="delete_location"
name="permissions[]"
type="checkbox"
value="delete_location"
/>
<label
for="delete_location"
class="form-label font-weight-500"
>删除</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Departments"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Departments"
>部门</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Departments"
id="add_department"
name="permissions[]"
type="checkbox"
value="add_department"
/>
<label
for="add_department"
class="form-label font-weight-500"
>添加</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Departments"
id="edit_department"
name="permissions[]"
type="checkbox"
value="edit_department"
/>
<label
for="edit_department"
class="form-label font-weight-500"
>编辑</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Departments"
id="delete_department"
name="permissions[]"
type="checkbox"
value="delete_department"
/>
<label
for="delete_department"
class="form-label font-weight-500"
>删除</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Product_type"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Product_type"
>产品类型</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Product_type"
id="add_product_type"
name="permissions[]"
type="checkbox"
value="add_product_type"
/>
<label
for="add_product_type"
class="form-label font-weight-500"
>添加</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Product_type"
id="edit_product_type"
name="permissions[]"
type="checkbox"
value="edit_product_type"
/>
<label
for="edit_product_type"
class="form-label font-weight-500"
>编辑</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Product_type"
id="delete_product_type"
name="permissions[]"
type="checkbox"
value="delete_product_type"
/>
<label
for="delete_product_type"
class="form-label font-weight-500"
>删除</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Product_category"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Product_category"
>产品类别</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Product_category"
id="add_product_category"
name="permissions[]"
type="checkbox"
value="add_product_category"
/>
<label
for="add_product_category"
class="form-label font-weight-500"
>添加</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Product_category"
id="edit_product_category"
name="permissions[]"
type="checkbox"
value="edit_product_category"
/>
<label
for="edit_product_category"
class="form-label font-weight-500"
>编辑</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Product_category"
id="delete_product_category"
name="permissions[]"
type="checkbox"
value="delete_product_category"
/>
<label
for="delete_product_category"
class="form-label font-weight-500"
>删除</label
><br />
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-sm btn-light-secondary"
data-bs-dismiss="modal"
>
<i class="bx bx-x d-block d-sm-none"></i>
<span class="d-none d-sm-block">关闭</span>
</button>
<button type="submit" class="btn btn-sm btn-info ml-1"
onclick="this.innerHTML = `<span class='spinner-grow spinner-grow-sm' role='status' aria-hidden='true'></span> Saving...`;"
>
<i class="bx bx-check d-block d-sm-none"></i>
<span class="d-none d-sm-block">保存</span>
</button>
</div>
</form>
<script>
$(document).ready(function () {
$("#checkall").click(function () {
$("input:checkbox")
.not(this)
.prop("checked", this.checked);
});
$(".ischeck").click(function () {
var ischeck = $(this).data("id");
$(".isscheck_" + ischeck).prop("checked", this.checked);
});
});
</script>
</div>
<script>
htmx.on("htmx:beforeSwap", (e) => {
if (e.detail.target.id == "add-role-modal-content" && !e.detail.xhr.response) {
location.reload()
}
})
</script>
+117
View File
@@ -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%}
+53
View File
@@ -0,0 +1,53 @@
{% if page_object %}
{% for role in page_object %}
<tr>
<td>
{% if page_object.start_index %}
{{page_object.start_index|add:forloop.counter0}}
{% else %}
{{forloop.counter}}
{% endif %}
</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 %}
{% else %}
<td colspan="8" class="text-center"> No record found related to your search keyword</td>
{% endif %}
+813
View File
@@ -0,0 +1,813 @@
<div class="modal-header bg-dark">
<h5 class="modal-title white w-100 text-center" id="myModalLabel160">Update Role
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close">
</button>
</div>
<form hx-post="{{request.path}}" novalidate>
{% csrf_token %}
<div class="modal-body">
<div class="row">
<div class="form-group">
<label for="name" class="form-label">Role</label>
{{form.related_name}}
{% for error in form.related_name.errors %}
<small class="text-danger mb-3">{{ error }}</small>
{% endfor %}
</div>
<div class="form-group">
<h6 class="my-3">Assign Permission to Roles</h6>
<table class="table mb-0" id="dataTable-1">
<thead>
<tr>
<th>
<input
type="checkbox"
class="align-middle checkbox_middle form-check-input"
name="checkallfield"
id="checkallfield"
/>
</th>
<th>Module</th>
<th>Permissions</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Vendors"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Vendors"
>Vendors</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Vendors"
id="view_vendor"
name="permissions[]"
type="checkbox"
value="view_vendor"
{% if 'view_vendor' in permissions %} checked {% endif %}
/>
<label
for="view_vendor"
class="form-label font-weight-500"
>View</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Vendors"
id="add_vendor"
name="permissions[]"
type="checkbox"
value="add_vendor"
{% if 'add_vendor' in permissions %} checked {% endif %}
/>
<label
for="add_vendor"
class="form-label font-weight-500"
>Add</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Vendors"
id="edit_vendor"
name="permissions[]"
type="checkbox"
value="edit_vendor"
{% if 'edit_vendor' in permissions %} checked {% endif %}
/>
<label
for="edit_vendor"
class="form-label font-weight-500"
>Edit</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Vendors"
id="delete_vendor"
name="permissions[]"
type="checkbox"
value="delete_vendor"
{% if 'delete_vendor' in permissions %} checked {% endif %}
/>
<label
for="delete_vendor"
class="form-label font-weight-500"
>Delete</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Products"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Products"
>Products</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Products"
id="view_product"
name="permissions[]"
type="checkbox"
value="view_product"
{% if 'view_product' in permissions %} checked {% endif %}
/>
<label
for="view_product"
class="form-label font-weight-500"
>View</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Products"
id="add_product"
name="permissions[]"
type="checkbox"
value="add_product"
{% if 'add_product' in permissions %} checked {% endif %}
/>
<label
for="add_product"
class="form-label font-weight-500"
>Add</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Products"
id="edit_product"
name="permissions[]"
type="checkbox"
value="edit_product"
{% if 'edit_product' in permissions %} checked {% endif %}
/>
<label
for="edit_product"
class="form-label font-weight-500"
>Edit</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Products"
id="delete_product"
name="permissions[]"
type="checkbox"
value="delete_product"
{% if 'delete_product' in permissions %} checked {% endif %}
/>
<label
for="delete_product"
class="form-label font-weight-500"
>Delete</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="users"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="users"
>Users</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_users"
id="view_users"
name="permissions[]"
type="checkbox"
value="view_users"
{% if 'view_users' in permissions %} checked {% endif %}
/>
<label
for="view_users"
class="form-label font-weight-500"
>View</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_users"
id="add_users"
name="permissions[]"
type="checkbox"
value="add_users"
{% if 'add_users' in permissions %} checked {% endif %}
/>
<label
for="add_users"
class="form-label font-weight-500"
>Add</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_users"
id="edit_users"
name="permissions[]"
type="checkbox"
value="edit_users"
{% if 'edit_users' in permissions %} checked {% endif %}
/>
<label
for="edit_users"
class="form-label font-weight-500"
>Edit</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_users"
id="delete_users"
name="permissions[]"
type="checkbox"
value="delete_users"
{% if 'delete_users' in permissions %} checked {% endif %}
/>
<label
for="delete_users"
class="form-label font-weight-500"
>Delete</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Assets"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Assets"
>Assets</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assets"
id="view_asset"
name="permissions[]"
type="checkbox"
value="view_asset"
{% if 'view_asset' in permissions %} checked {% endif %}
/>
<label
for="view_asset"
class="form-label font-weight-500"
>View</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assets"
id="add_asset"
name="permissions[]"
type="checkbox"
value="add_asset"
{% if 'add_asset' in permissions %} checked {% endif %}
/>
<label
for="add_asset"
class="form-label font-weight-500"
>Add</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assets"
id="edit_asset"
name="permissions[]"
type="checkbox"
value="edit_asset"
{% if 'edit_asset' in permissions %} checked {% endif %}
/>
<label
for="edit_asset"
class="form-label font-weight-500"
>Edit</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assets"
id="delete_asset"
name="permissions[]"
type="checkbox"
value="delete_asset"
{% if 'delete_asset' in permissions %} checked {% endif %}
/>
<label
for="delete_asset"
class="form-label font-weight-500"
>Delete</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Assign_Assets"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Assign_Assets"
>Assign Assets</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assign_Assets"
id="add_assign_asset"
name="permissions[]"
type="checkbox"
value="add_assign_asset"
{% if 'add_assign_asset' in permissions %} checked {% endif %}
/>
<label
for="add_assign_asset"
class="form-label font-weight-500"
>Add</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assign_Assets"
id="reassign_assign_asset"
name="permissions[]"
type="checkbox"
value="reassign_assign_asset"
{% if 'reassign_assign_asset' in permissions %} checked {% endif %}
/>
<label
for="reassign_assign_asset"
class="form-label font-weight-500"
>Reassign</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Assign_Assets"
id="delete_assign_asset"
name="permissions[]"
type="checkbox"
value="delete_assign_asset"
{% if 'delete_assign_asset' in permissions %} checked {% endif %}
/>
<label
for="delete_assign_asset"
class="form-label font-weight-500"
>Unassign</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Locations"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Locations"
>Locations</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Locations"
id="view_location"
name="permissions[]"
type="checkbox"
value="view_location"
{% if 'view_location' in permissions %} checked {% endif %}
/>
<label
for="view_location"
class="form-label font-weight-500"
>View</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Locations"
id="add_location"
name="permissions[]"
type="checkbox"
value="add_location"
{% if 'add_location' in permissions %} checked {% endif %}
/>
<label
for="add_location"
class="form-label font-weight-500"
>Add</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Locations"
id="edit_location"
name="permissions[]"
type="checkbox"
value="edit_location"
{% if 'edit_location' in permissions %} checked {% endif %}
/>
<label
for="edit_location"
class="form-label font-weight-500"
>Edit</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Locations"
id="delete_location"
name="permissions[]"
type="checkbox"
value="delete_location"
{% if 'delete_location' in permissions %} checked {% endif %}
/>
<label
for="delete_location"
class="form-label font-weight-500"
>Delete</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Departments"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Departments"
>Departments</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Departments"
id="add_department"
name="permissions[]"
type="checkbox"
value="add_department"
{% if 'add_department' in permissions %} checked {% endif %}
/>
<label
for="add_department"
class="form-label font-weight-500"
>Add</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Departments"
id="edit_department"
name="permissions[]"
type="checkbox"
value="edit_department"
{% if 'edit_department' in permissions %} checked {% endif %}
/>
<label
for="edit_department"
class="form-label font-weight-500"
>Edit</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Departments"
id="delete_department"
name="permissions[]"
type="checkbox"
value="delete_department"
{% if 'delete_department' in permissions %} checked {% endif %}
/>
<label
for="delete_department"
class="form-label font-weight-500"
>Delete</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Product_type"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Product_type"
>Product Types</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Product_type"
id="add_product_type"
name="permissions[]"
type="checkbox"
value="add_product_type"
{% if 'add_product_type' in permissions %} checked {% endif %}
/>
<label
for="add_product_type"
class="form-label font-weight-500"
>Add</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Product_type"
id="edit_product_type"
name="permissions[]"
type="checkbox"
value="edit_product_type"
{% if 'edit_product_type' in permissions %} checked {% endif %}
/>
<label
for="edit_product_type"
class="form-label font-weight-500"
>Edit</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Product_type"
id="delete_product_type"
name="permissions[]"
type="checkbox"
value="delete_product_type"
{% if 'delete_product_type' in permissions %} checked {% endif %}
/>
<label
for="delete_product_type"
class="form-label font-weight-500"
>Delete</label
><br />
</div>
</div>
</td>
</tr>
<tr>
<td>
<input
type="checkbox"
class="align-middle ischeck form-check-input"
name="checkall"
data-id="Product_category"
/>
</td>
<td>
<label
class="ischeck form-label"
data-id="Product_category"
>Product Categories</label
>
</td>
<td>
<div class="row">
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Product_category"
id="add_product_category"
name="permissions[]"
type="checkbox"
value="add_product_category"
{% if 'add_product_category' in permissions %} checked {% endif %}
/>
<label
for="add_product_category"
class="form-label font-weight-500"
>Add</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Product_category"
id="edit_product_category"
name="permissions[]"
type="checkbox"
value="edit_product_category"
{% if 'edit_product_category' in permissions %} checked {% endif %}
/>
<label
for="edit_product_category"
class="form-label font-weight-500"
>Edit</label
><br />
</div>
<div
class="col-md-3 custom-control custom-checkbox"
>
<input
class="form-check-input isscheck isscheck_Product_category"
id="delete_product_category"
name="permissions[]"
type="checkbox"
value="delete_product_category"
{% if 'delete_product_category' in permissions %} checked {% endif %}
/>
<label
for="delete_product_category"
class="form-label font-weight-500"
>Delete</label
><br />
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-sm btn-light-secondary"
data-bs-dismiss="modal"
>
<i class="bx bx-x d-block d-sm-none"></i>
<span class="d-none d-sm-block">Close</span>
</button>
<button type="submit" class="btn btn-sm btn-info ml-1"
onclick="this.innerHTML = `<span class='spinner-grow spinner-grow-sm' role='status' aria-hidden='true'></span> Saving...`;"
>
<i class="bx bx-check d-block d-sm-none"></i>
<span class="d-none d-sm-block">Save</span>
</button>
</div>
</form>
<script>
htmx.on("htmx:beforeSwap", (e) => {
if (e.detail.target.id == "update-role-modal-content" && !e.detail.xhr.response) {
location.reload()
}
})
$(document).ready(function () {
$("#checkallfield").click(function () {
$("input:checkbox")
.not(this)
.prop("checked", this.checked);
});
$(".ischeck").click(function () {
var ischeck = $(this).data("id");
$(".isscheck_" + ischeck).prop("checked", this.checked);
});
});
</script>