fixing table component
This commit is contained in:
parent
84c590fd80
commit
ab3688c606
|
@ -26,3 +26,5 @@
|
||||||
@stack('scripts')
|
@stack('scripts')
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
'showViewModal' => false
|
'showViewModal' => false
|
||||||
])
|
])
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
<div class="card-header border-0 bg-transparent">
|
<div class="card-header border-0 bg-transparent">
|
||||||
<div class="d-flex justify-content-between align-items-center">
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0 fw-bold text-dark">{{ $pageTitle }}</h5>
|
<h5 class="mb-0 fw-bold text-dark">{{ $pageTitle }}</h5>
|
||||||
|
@ -81,7 +81,7 @@
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Edit Modal -->
|
<!-- Edit Modal -->
|
||||||
@if ($showEditModal)
|
@if ($showEditModal)
|
||||||
|
@ -142,6 +142,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
@if ($pageTitle === 'Locked Account')
|
||||||
|
<button type="button" class="btn btn-success" id="activateAccountBtn">Activate Account</button>
|
||||||
|
@endif
|
||||||
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Close</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -149,9 +152,8 @@
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<!-- CSS (same as your original, included for completeness) -->
|
<!-- CSS (unchanged from your original) -->
|
||||||
<style>
|
<style>
|
||||||
/* Your original CSS styles here */
|
|
||||||
.card,
|
.card,
|
||||||
.table,
|
.table,
|
||||||
.btn,
|
.btn,
|
||||||
|
@ -162,65 +164,43 @@
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
/* Font Styling */
|
|
||||||
.card,
|
|
||||||
.table,
|
|
||||||
.btn,
|
|
||||||
.form-control,
|
|
||||||
.input-group-text,
|
|
||||||
.modal-content {
|
|
||||||
font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-header h5,
|
.card-header h5,
|
||||||
.modal-title {
|
.modal-title {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table thead th {
|
.table thead th {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-label {
|
.form-label {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-header {
|
.card-header {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary {
|
.btn-primary {
|
||||||
background-color: #E74610;
|
background-color: #E74610;
|
||||||
border-color: #E74610;
|
border-color: #E74610;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary:hover {
|
.btn-primary:hover {
|
||||||
background-color: #E74610;
|
background-color: #E74610;
|
||||||
border-color: #E74610;
|
border-color: #E74610;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sortable {
|
.sortable {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sortable:hover {
|
.sortable:hover {
|
||||||
background-color: #f1f3f5;
|
background-color: #f1f3f5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table {
|
.table {
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
table-layout: auto;
|
table-layout: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table th,
|
.table th,
|
||||||
.table td {
|
.table td {
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
|
@ -229,76 +209,61 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table th:first-child,
|
.table th:first-child,
|
||||||
.table td:first-child {
|
.table td:first-child {
|
||||||
width: 40px;
|
width: 40px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table th:last-child,
|
.table th:last-child,
|
||||||
.table td:last-child {
|
.table td:last-child {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table td:nth-child(5),
|
.table td:nth-child(5),
|
||||||
.table th:nth-child(5) {
|
.table th:nth-child(5) {
|
||||||
width: 100px;
|
width: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table td:nth-child(6),
|
.table td:nth-child(6),
|
||||||
.table th:nth-child(6) {
|
.table th:nth-child(6) {
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table td:nth-child(7),
|
.table td:nth-child(7),
|
||||||
.table th:nth-child(7) {
|
.table th:nth-child(7) {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-btn {
|
.status-btn {
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
padding: 0.2rem 0.5rem;
|
padding: 0.2rem 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-menu-sm {
|
.dropdown-menu-sm {
|
||||||
min-width: 120px;
|
min-width: 120px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-item {
|
.dropdown-item {
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table thead .sortable i {
|
.table thead .sortable i {
|
||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-container {
|
.table-container {
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-content {
|
.modal-content {
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-header {
|
.modal-header {
|
||||||
border-bottom: 1px solid #e9ecef;
|
border-bottom: 1px solid #e9ecef;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-footer {
|
.modal-footer {
|
||||||
border-top: 1px solid #e9ecef;
|
border-top: 1px solid #e9ecef;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-control,
|
.form-control,
|
||||||
.form-select {
|
.form-select {
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-close-btn {
|
.modal-close-btn {
|
||||||
background: none;
|
background: none;
|
||||||
border: none;
|
border: none;
|
||||||
|
@ -309,120 +274,96 @@
|
||||||
top: 15px;
|
top: 15px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-close-btn:hover {
|
.modal-close-btn:hover {
|
||||||
color: #343a40;
|
color: #343a40;
|
||||||
}
|
}
|
||||||
|
.view-details p {
|
||||||
.view-user-details p {
|
|
||||||
margin-bottom: 0.75rem;
|
margin-bottom: 0.75rem;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
.view-details strong {
|
||||||
.view-user-details strong {
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 120px;
|
width: 120px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #343a40;
|
color: #343a40;
|
||||||
}
|
}
|
||||||
|
.view-details span {
|
||||||
.view-user-details span {
|
|
||||||
color: #495057;
|
color: #495057;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination-sm .page-link {
|
.pagination-sm .page-link {
|
||||||
padding: 0.25rem 0.5rem;
|
padding: 0.25rem 0.5rem;
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
border-color: #E74610;
|
border-color: #E74610;
|
||||||
color: #E74610;
|
color: #E74610;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination-sm .page-item.active .page-link {
|
.pagination-sm .page-item.active .page-link {
|
||||||
background-color: #E74610;
|
background-color: #E74610;
|
||||||
border-color: #E74610;
|
border-color: #E74610;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination-sm .page-link:hover {
|
.pagination-sm .page-link:hover {
|
||||||
background-color: #E74610;
|
background-color: #E74610;
|
||||||
border-color: #E74610;
|
border-color: #E74610;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination-sm .page-item.disabled .page-link {
|
.pagination-sm .page-item.disabled .page-link {
|
||||||
border-color: #dee2e6;
|
border-color: #dee2e6;
|
||||||
color: #6c757d;
|
color: #6c757d;
|
||||||
}
|
}
|
||||||
|
|
||||||
.edit-btn {
|
.edit-btn {
|
||||||
border-color: #E74610;
|
border-color: #E74610;
|
||||||
color: #E74610;
|
color: #E74610;
|
||||||
}
|
}
|
||||||
|
|
||||||
.edit-btn:hover {
|
.edit-btn:hover {
|
||||||
background-color: #E74610;
|
background-color: #E74610;
|
||||||
border-color: #E74610;
|
border-color: #E74610;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 576px) {
|
@media (max-width: 576px) {
|
||||||
.table {
|
.table {
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table thead th {
|
.table thead th {
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table th,
|
.table th,
|
||||||
.table td {
|
.table td {
|
||||||
padding: 0.3rem;
|
padding: 0.3rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-sm {
|
.btn-sm {
|
||||||
padding: 0.2rem 0.4rem;
|
padding: 0.2rem 0.4rem;
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-group-sm>.form-control {
|
.input-group-sm>.form-control {
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-btn {
|
.status-btn {
|
||||||
font-size: 0.65rem;
|
font-size: 0.65rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-item {
|
.dropdown-item {
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table thead .sortable i {
|
.table thead .sortable i {
|
||||||
font-size: 0.65rem;
|
font-size: 0.65rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination-sm .page-link {
|
.pagination-sm .page-link {
|
||||||
padding: 0.2rem 0.4rem;
|
padding: 0.2rem 0.4rem;
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table td:nth-child(6) {
|
.table td:nth-child(6) {
|
||||||
max-width: 150px;
|
max-width: 150px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-control,
|
.form-control,
|
||||||
.form-select {
|
.form-select {
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-close-btn {
|
.modal-close-btn {
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
.view-details p {
|
||||||
.view-user-details p {
|
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
}
|
}
|
||||||
|
.view-details strong {
|
||||||
.view-user-details strong {
|
|
||||||
width: 100px;
|
width: 100px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,7 +378,8 @@
|
||||||
showCheckboxes: {{ json_encode($showCheckboxes) }},
|
showCheckboxes: {{ json_encode($showCheckboxes) }},
|
||||||
showBatchDelete: {{ json_encode($showBatchDelete) }},
|
showBatchDelete: {{ json_encode($showBatchDelete) }},
|
||||||
showEditModal: {{ json_encode($showEditModal) }},
|
showEditModal: {{ json_encode($showEditModal) }},
|
||||||
showViewModal: {{ json_encode($showViewModal) }}
|
showViewModal: {{ json_encode($showViewModal) }},
|
||||||
|
pageTitle: @json($pageTitle)
|
||||||
};
|
};
|
||||||
|
|
||||||
const rowsPerPage = 5;
|
const rowsPerPage = 5;
|
||||||
|
@ -445,9 +387,11 @@
|
||||||
let filteredRows = [...tableConfig.data];
|
let filteredRows = [...tableConfig.data];
|
||||||
let originalRows = [...tableConfig.data].map(row => ({ ...row }));
|
let originalRows = [...tableConfig.data].map(row => ({ ...row }));
|
||||||
let sortDirection = {};
|
let sortDirection = {};
|
||||||
|
let currentRowId = null; // Track the row being viewed
|
||||||
|
|
||||||
function renderTable() {
|
function renderTable() {
|
||||||
const tableBody = document.getElementById('tableBody');
|
const tableBody = document.getElementById('tableBody');
|
||||||
|
if (!tableBody) return;
|
||||||
tableBody.innerHTML = '';
|
tableBody.innerHTML = '';
|
||||||
|
|
||||||
const start = (currentPage - 1) * rowsPerPage;
|
const start = (currentPage - 1) * rowsPerPage;
|
||||||
|
@ -488,7 +432,7 @@
|
||||||
</div>
|
</div>
|
||||||
</td>`;
|
</td>`;
|
||||||
} else {
|
} else {
|
||||||
rowHtml += `<td>${row[col.key]}</td>`;
|
rowHtml += `<td>${row[col.key] || ''}</td>`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -525,6 +469,7 @@
|
||||||
|
|
||||||
function renderPagination() {
|
function renderPagination() {
|
||||||
const pagination = document.getElementById('pagination');
|
const pagination = document.getElementById('pagination');
|
||||||
|
if (!pagination) return;
|
||||||
pagination.innerHTML = '';
|
pagination.innerHTML = '';
|
||||||
|
|
||||||
const pageCount = Math.ceil(filteredRows.length / rowsPerPage);
|
const pageCount = Math.ceil(filteredRows.length / rowsPerPage);
|
||||||
|
@ -571,17 +516,20 @@
|
||||||
|
|
||||||
function attachEventListeners() {
|
function attachEventListeners() {
|
||||||
// Search
|
// Search
|
||||||
document.getElementById('searchInput').addEventListener('input', function() {
|
const searchInput = document.getElementById('searchInput');
|
||||||
|
if (searchInput) {
|
||||||
|
searchInput.addEventListener('input', function() {
|
||||||
const searchTerm = this.value.toLowerCase();
|
const searchTerm = this.value.toLowerCase();
|
||||||
filteredRows = tableConfig.data.filter(row => {
|
filteredRows = tableConfig.data.filter(row => {
|
||||||
return Object.values(row).some(value =>
|
return Object.values(row).some(value =>
|
||||||
value.toString().toLowerCase().includes(searchTerm)
|
value && value.toString().toLowerCase().includes(searchTerm)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
currentPage = 1;
|
currentPage = 1;
|
||||||
renderTable();
|
renderTable();
|
||||||
renderPagination();
|
renderPagination();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Sort
|
// Sort
|
||||||
document.querySelectorAll('.sortable').forEach(header => {
|
document.querySelectorAll('.sortable').forEach(header => {
|
||||||
|
@ -596,12 +544,14 @@
|
||||||
icon.classList.add('fa-sort');
|
icon.classList.add('fa-sort');
|
||||||
});
|
});
|
||||||
const icon = this.querySelector('i');
|
const icon = this.querySelector('i');
|
||||||
|
if (icon) {
|
||||||
icon.classList.remove('fa-sort');
|
icon.classList.remove('fa-sort');
|
||||||
icon.classList.add(sortDirection[columnIndex] === 'asc' ? 'fa-sort-up' : 'fa-sort-down');
|
icon.classList.add(sortDirection[columnIndex] === 'asc' ? 'fa-sort-up' : 'fa-sort-down');
|
||||||
|
}
|
||||||
|
|
||||||
filteredRows.sort((a, b) => {
|
filteredRows.sort((a, b) => {
|
||||||
const aValue = a[key].toString().toLowerCase();
|
const aValue = (a[key] || '').toString().toLowerCase();
|
||||||
const bValue = b[key].toString().toLowerCase();
|
const bValue = (b[key] || '').toString().toLowerCase();
|
||||||
return sortDirection[columnIndex] === 'asc' ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
|
return sortDirection[columnIndex] === 'asc' ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -612,8 +562,10 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// Clear Filters
|
// Clear Filters
|
||||||
document.getElementById('clearFilters').addEventListener('click', function() {
|
const clearFilters = document.getElementById('clearFilters');
|
||||||
document.getElementById('searchInput').value = '';
|
if (clearFilters) {
|
||||||
|
clearFilters.addEventListener('click', function() {
|
||||||
|
if (searchInput) searchInput.value = '';
|
||||||
document.querySelectorAll('.sortable i').forEach(icon => {
|
document.querySelectorAll('.sortable i').forEach(icon => {
|
||||||
icon.classList.remove('fa-sort-up', 'fa-sort-down');
|
icon.classList.remove('fa-sort-up', 'fa-sort-down');
|
||||||
icon.classList.add('fa-sort');
|
icon.classList.add('fa-sort');
|
||||||
|
@ -624,6 +576,7 @@
|
||||||
renderTable();
|
renderTable();
|
||||||
renderPagination();
|
renderPagination();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Checkboxes
|
// Checkboxes
|
||||||
if (tableConfig.showCheckboxes) {
|
if (tableConfig.showCheckboxes) {
|
||||||
|
@ -665,7 +618,7 @@
|
||||||
|
|
||||||
renderTable();
|
renderTable();
|
||||||
renderPagination();
|
renderPagination();
|
||||||
document.getElementById('selectAll').checked = false;
|
if (selectAll) selectAll.checked = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -699,19 +652,23 @@
|
||||||
const userId = this.getAttribute('data-id');
|
const userId = this.getAttribute('data-id');
|
||||||
const user = filteredRows.find(row => row.id == userId);
|
const user = filteredRows.find(row => row.id == userId);
|
||||||
|
|
||||||
|
if (user) {
|
||||||
tableConfig.columns.forEach(col => {
|
tableConfig.columns.forEach(col => {
|
||||||
const input = document.getElementById(`edit${col.key.charAt(0).toUpperCase() + col.key.slice(1)}`);
|
const input = document.getElementById(`edit${col.key.charAt(0).toUpperCase() + col.key.slice(1)}`);
|
||||||
if (input) {
|
if (input) {
|
||||||
input.value = user[col.key];
|
input.value = user[col.key] || '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const modal = new bootstrap.Modal(document.getElementById('editModal'));
|
const modal = new bootstrap.Modal(document.getElementById('editModal'));
|
||||||
modal.show();
|
modal.show();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('updateBtn')?.addEventListener('click', function() {
|
const updateBtn = document.getElementById('updateBtn');
|
||||||
|
if (updateBtn) {
|
||||||
|
updateBtn.addEventListener('click', function() {
|
||||||
const userId = document.querySelector('.edit-btn[data-id]')?.getAttribute('data-id');
|
const userId = document.querySelector('.edit-btn[data-id]')?.getAttribute('data-id');
|
||||||
const user = filteredRows.find(row => row.id == userId);
|
const user = filteredRows.find(row => row.id == userId);
|
||||||
if (user) {
|
if (user) {
|
||||||
|
@ -727,26 +684,48 @@
|
||||||
renderTable();
|
renderTable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// View
|
// View
|
||||||
if (tableConfig.showViewModal) {
|
if (tableConfig.showViewModal) {
|
||||||
document.querySelectorAll('.view-btn').forEach(button => {
|
document.querySelectorAll('.view-btn').forEach(button => {
|
||||||
button.addEventListener('click', function(e) {
|
button.addEventListener('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const userId = this.getAttribute('data-id');
|
currentRowId = this.getAttribute('data-id');
|
||||||
const user = filteredRows.find(row => row.id == userId);
|
const user = filteredRows.find(row => row.id == currentRowId);
|
||||||
|
|
||||||
|
if (user) {
|
||||||
tableConfig.columns.forEach(col => {
|
tableConfig.columns.forEach(col => {
|
||||||
const span = document.getElementById(`view${col.key.charAt(0).toUpperCase() + col.key.slice(1)}`);
|
const span = document.getElementById(`view${col.key.charAt(0).toUpperCase() + col.key.slice(1)}`);
|
||||||
if (span) {
|
if (span) {
|
||||||
span.textContent = user[col.key];
|
span.textContent = user[col.key] || '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const modal = new bootstrap.Modal(document.getElementById('viewModal'));
|
const modal = new bootstrap.Modal(document.getElementById('viewModal'));
|
||||||
modal.show();
|
modal.show();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Activate Account for Locked Account page
|
||||||
|
if (tableConfig.pageTitle === 'Locked Account') {
|
||||||
|
const activateAccountBtn = document.getElementById('activateAccountBtn');
|
||||||
|
if (activateAccountBtn) {
|
||||||
|
activateAccountBtn.addEventListener('click', function() {
|
||||||
|
if (currentRowId) {
|
||||||
|
const user = filteredRows.find(row => row.id == currentRowId);
|
||||||
|
if (user) {
|
||||||
|
user.status = 'Active';
|
||||||
|
}
|
||||||
|
const modal = bootstrap.Modal.getInstance(document.getElementById('viewModal'));
|
||||||
|
modal.hide();
|
||||||
|
renderTable();
|
||||||
|
currentRowId = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
|
|
|
@ -5,10 +5,6 @@
|
||||||
@section('content')
|
@section('content')
|
||||||
@php
|
@php
|
||||||
$members = [
|
$members = [
|
||||||
['id' => 1, 'cardNumber' => '1234-5678-9012-3456', 'firstName' => 'John', 'lastName' => 'Doe', 'birthday' => '1990-05-15', 'cardType' => 'Gold', 'status' => 'Active'],
|
|
||||||
['id' => 2, 'cardNumber' => '9876-5432-1098-7654', 'firstName' => 'Jane', 'lastName' => 'Smith', 'birthday' => '1985-11-22', 'cardType' => 'Silver', 'status' => 'Inactive'],
|
|
||||||
['id' => 3, 'cardNumber' => '4567-8901-2345-6789', 'firstName' => 'Alice', 'lastName' => 'Johnson', 'birthday' => '1992-03-10', 'cardType' => 'Platinum', 'status' => 'Active'],
|
|
||||||
['id' => 4, 'cardNumber' => '3210-9876-5432-1098', 'firstName' => 'Bob', 'lastName' => 'Brown', 'birthday' => '1988-07-30', 'cardType' => 'Gold', 'status' => 'Active'],
|
|
||||||
['id' => 1, 'cardNumber' => '1234-5678-9012-3456', 'firstName' => 'John', 'lastName' => 'Doe', 'birthday' => '1990-05-15', 'cardType' => 'Gold', 'status' => 'Active'],
|
['id' => 1, 'cardNumber' => '1234-5678-9012-3456', 'firstName' => 'John', 'lastName' => 'Doe', 'birthday' => '1990-05-15', 'cardType' => 'Gold', 'status' => 'Active'],
|
||||||
['id' => 2, 'cardNumber' => '9876-5432-1098-7654', 'firstName' => 'Jane', 'lastName' => 'Smith', 'birthday' => '1985-11-22', 'cardType' => 'Silver', 'status' => 'Inactive'],
|
['id' => 2, 'cardNumber' => '9876-5432-1098-7654', 'firstName' => 'Jane', 'lastName' => 'Smith', 'birthday' => '1985-11-22', 'cardType' => 'Silver', 'status' => 'Inactive'],
|
||||||
['id' => 3, 'cardNumber' => '4567-8901-2345-6789', 'firstName' => 'Alice', 'lastName' => 'Johnson', 'birthday' => '1992-03-10', 'cardType' => 'Platinum', 'status' => 'Active'],
|
['id' => 3, 'cardNumber' => '4567-8901-2345-6789', 'firstName' => 'Alice', 'lastName' => 'Johnson', 'birthday' => '1992-03-10', 'cardType' => 'Platinum', 'status' => 'Active'],
|
||||||
|
|
|
@ -1,14 +1,33 @@
|
||||||
@extends('layouts.app')
|
@extends('layouts.app')
|
||||||
|
|
||||||
@section('page_title', 'Member Management')
|
@section('page_title', 'Locked Account')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="card" style="min-height: 500px;">
|
@php
|
||||||
<div class="card-header">
|
$members = [
|
||||||
<i class="fa-solid fa-users-gear" style="color:gray;"> Locked Accounts</i>
|
['id' => 1, 'cardNumber' => '1234-5678-9012-3456', 'firstName' => 'John', 'lastName' => 'Doe', 'birthday' => '1990-05-15', 'cardType' => 'Gold', 'status' => 'Inactive'],
|
||||||
</div>
|
['id' => 2, 'cardNumber' => '9876-5432-1098-7654', 'firstName' => 'Jane', 'lastName' => 'Smith', 'birthday' => '1985-11-22', 'cardType' => 'Silver', 'status' => 'Inactive'],
|
||||||
<div class="card-body">
|
['id' => 3, 'cardNumber' => '4567-8901-2345-6789', 'firstName' => 'Alice', 'lastName' => 'Johnson', 'birthday' => '1992-03-10', 'cardType' => 'Platinum', 'status' => 'Inactive'],
|
||||||
<p>This is the Locked Accounts page content.</p>
|
['id' => 4, 'cardNumber' => '3210-9876-5432-1098', 'firstName' => 'Bob', 'lastName' => 'Brown', 'birthday' => '1988-07-30', 'cardType' => 'Gold', 'status' => 'Inactive']
|
||||||
</div>
|
];
|
||||||
</div>
|
@endphp
|
||||||
|
|
||||||
|
@include('components.table-component', [
|
||||||
|
'pageTitle' => 'Locked Account',
|
||||||
|
'data' => $members,
|
||||||
|
'columns' => [
|
||||||
|
['name' => 'Card Number', 'key' => 'cardNumber', 'sortable' => true],
|
||||||
|
['name' => 'First Name', 'key' => 'firstName', 'sortable' => true],
|
||||||
|
['name' => 'Last Name', 'key' => 'lastName', 'sortable' => true],
|
||||||
|
['name' => 'Birthday', 'key' => 'birthday', 'sortable' => true],
|
||||||
|
['name' => 'Card Type', 'key' => 'cardType', 'sortable' => true],
|
||||||
|
['name' => 'Status', 'key' => 'status', 'sortable' => true]
|
||||||
|
],
|
||||||
|
'actions' => ['view'],
|
||||||
|
'showAddButton' => false,
|
||||||
|
'showCheckboxes' => false,
|
||||||
|
'showBatchDelete' => false,
|
||||||
|
'showEditModal' => false,
|
||||||
|
'showViewModal' => true
|
||||||
|
])
|
||||||
@endsection
|
@endsection
|
Loading…
Reference in New Issue