fix "x"
This commit is contained in:
71
LOCAL_ACCESS.md
Normal file
71
LOCAL_ACCESS.md
Normal file
@@ -0,0 +1,71 @@
|
||||
# Dùng AccManager qua mạng nội bộ khi tên miền hết hạn
|
||||
|
||||
Máy chủ hiện tại vẫn chạy tại `172.20.235.176`. Có thể truy cập tạm bằng cách ánh xạ tên `accrobot.pnkr.asia` tới IP này trong file `hosts` của từng máy Windows. Trình duyệt vẫn mở `https://accrobot.pnkr.asia`, nhưng kết nối trực tiếp tới máy chủ trong LAN, không cần DNS công cộng của tên miền.
|
||||
|
||||
Ứng dụng, dữ liệu SQL Server, tài khoản và cấu hình Docker hiện tại được giữ nguyên. Máy sử dụng cần kết nối mạng nội bộ hoặc VPN có đường tới `172.20.235.176`.
|
||||
|
||||
## Thiết lập trên máy Windows
|
||||
|
||||
1. Mở Start, tìm **Notepad**, bấm chuột phải và chọn **Run as administrator**.
|
||||
2. Trong Notepad chọn **File → Open**, đổi bộ lọc thành **All files**, rồi mở:
|
||||
|
||||
```text
|
||||
C:\Windows\System32\drivers\etc\hosts
|
||||
```
|
||||
|
||||
3. Thêm dòng sau vào cuối file rồi lưu. Nếu đã có dòng đang hoạt động cho đúng tên `accrobot.pnkr.asia`, sửa IP của dòng đó thay vì thêm trùng. Ghi lại IP cũ để hoàn tác; giữ nguyên các dòng của tên khác.
|
||||
|
||||
```text
|
||||
172.20.235.176 accrobot.pnkr.asia # AccManager temporary LAN
|
||||
```
|
||||
|
||||
File phải được lưu đúng tên `hosts`, không thêm đuôi `.txt`.
|
||||
|
||||
4. Mở PowerShell hoặc Command Prompt với quyền Administrator và chạy:
|
||||
|
||||
```powershell
|
||||
ipconfig /flushdns
|
||||
```
|
||||
|
||||
5. Đóng rồi mở lại trình duyệt, truy cập **https://accrobot.pnkr.asia** và đăng nhập như bình thường.
|
||||
|
||||
Thực hiện trên từng máy cần dùng. Nếu cần áp dụng cho nhiều máy, quản trị mạng có thể tạo bản ghi DNS nội bộ tương đương, với điều kiện các máy sử dụng DNS nội bộ đó.
|
||||
|
||||
## Kiểm tra
|
||||
|
||||
Sau khi sửa `hosts`, chạy trong PowerShell:
|
||||
|
||||
```powershell
|
||||
curl.exe --noproxy "*" --fail --show-error --connect-timeout 5 --max-time 15 https://accrobot.pnkr.asia/api/health
|
||||
```
|
||||
|
||||
Kết quả mong đợi có `"status":"ok"`. Mở trang đăng nhập và đăng nhập bằng tài khoản hiện có để kiểm tra phiên làm việc.
|
||||
|
||||
Nếu chưa truy cập được, kiểm tra máy đang ở đúng LAN/VPN, dòng `hosts` không bị chú thích bằng `#` ở đầu, file không có đuôi `.txt`, rồi xóa cache DNS và mở lại trình duyệt. Nếu máy sử dụng proxy web, cần cho địa chỉ này đi trực tiếp qua LAN.
|
||||
|
||||
### Kết quả kiểm tra ngày 10/09/2026
|
||||
|
||||
- `https://accrobot.pnkr.asia/api/health` qua IP `172.20.235.176` trả HTTP 200, `status: ok`.
|
||||
- Trang `/pages/login.html` qua cùng đường kết nối trả HTTP 200.
|
||||
- Xác minh TLS thành công; chứng chỉ cho `accrobot.pnkr.asia` hết hạn **29/10/2026 lúc 09:56:58 (giờ Việt Nam)**.
|
||||
- Chưa kiểm tra đăng nhập bằng tài khoản người dùng. Phiên hỗ trợ không có quyền ghi file `hosts`, nên ánh xạ chưa được áp dụng tự động.
|
||||
|
||||
Có thể kiểm tra đường kết nối trước khi sửa `hosts` bằng lệnh sau; lệnh chỉ áp dụng ánh xạ cho riêng lần gọi này:
|
||||
|
||||
```powershell
|
||||
curl.exe --noproxy "*" --fail --show-error --connect-timeout 5 --max-time 15 --resolve accrobot.pnkr.asia:443:172.20.235.176 https://accrobot.pnkr.asia/api/health
|
||||
```
|
||||
|
||||
## Vì sao vẫn mở tên web thay vì gõ IP vào trình duyệt?
|
||||
|
||||
Ánh xạ `hosts` sử dụng IP nội bộ để kết nối, đồng thời giữ tên HTTPS mà reverse proxy, chứng chỉ và cookie đăng nhập đang dùng. Truy cập bằng `https://172.20.235.176` không khớp tên chứng chỉ. Truy cập `http://172.20.235.176:3000` gặp cấu hình bắt buộc HTTPS và cookie Secure của ứng dụng hiện tại.
|
||||
|
||||
Không cần sửa `.env`, chuyển `NODE_ENV` sang development, build image, khởi động lại container hay chuyển cơ sở dữ liệu cho phương án này.
|
||||
|
||||
## Hoàn tác sau khi gia hạn tên miền
|
||||
|
||||
1. Khi tên miền đã gia hạn và DNS công cộng hoạt động lại, mở file `hosts` với quyền Administrator.
|
||||
2. Xóa riêng dòng có chú thích `# AccManager temporary LAN`; nếu đã sửa dòng có sẵn, khôi phục nội dung cũ.
|
||||
3. Chạy `ipconfig /flushdns`, đóng rồi mở lại trình duyệt và truy cập địa chỉ web như trước.
|
||||
|
||||
Ánh xạ chỉ giải quyết việc phân giải tên miền. Chứng chỉ HTTPS vẫn cần còn hạn; hoàn tất gia hạn hoặc bố trí chứng chỉ phù hợp trước mốc hết hạn nêu trên.
|
||||
@@ -51,6 +51,7 @@ Thay vì lưu rải rác tài khoản ứng dụng ở nhiều nơi, AccManager
|
||||
## Tài liệu liên quan
|
||||
|
||||
- Hướng dẫn triển khai: [DEPLOYMENT_GUIDE.md](DEPLOYMENT_GUIDE.md)
|
||||
- Dùng tạm trong mạng nội bộ khi tên miền hết hạn: [LOCAL_ACCESS.md](LOCAL_ACCESS.md)
|
||||
|
||||
## Cau hinh email xac thuc dang ky
|
||||
|
||||
|
||||
136
public/js/app.js
136
public/js/app.js
@@ -2182,10 +2182,7 @@ class AccountManager {
|
||||
}
|
||||
|
||||
setupEventListeners() {
|
||||
// Modal close buttons
|
||||
document.querySelectorAll('[data-close-modal]').forEach(btn => {
|
||||
btn.addEventListener('click', () => this.closeModals());
|
||||
});
|
||||
this.setupModalCloseListeners();
|
||||
|
||||
// Close with Escape key
|
||||
document.addEventListener('keydown', (e) => {
|
||||
@@ -2336,30 +2333,12 @@ class AccountManager {
|
||||
confirmAssetRequestDeleteBtn.dataset.boundClick = 'true';
|
||||
}
|
||||
|
||||
document.querySelectorAll('.cancel-asset-request-delete-confirm').forEach(btn => {
|
||||
if (btn.dataset.boundClick === 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
btn.addEventListener('click', () => this.resolveAssetRequestDeleteConfirm(false));
|
||||
btn.dataset.boundClick = 'true';
|
||||
});
|
||||
|
||||
const confirmBulkAssetDeleteBtn = document.getElementById('confirmBulkAssetDeleteBtn');
|
||||
if (confirmBulkAssetDeleteBtn && confirmBulkAssetDeleteBtn.dataset.boundClick !== 'true') {
|
||||
confirmBulkAssetDeleteBtn.addEventListener('click', () => this.resolveBulkAssetDeleteConfirm(true));
|
||||
confirmBulkAssetDeleteBtn.dataset.boundClick = 'true';
|
||||
}
|
||||
|
||||
document.querySelectorAll('.cancel-bulk-asset-delete-confirm').forEach(btn => {
|
||||
if (btn.dataset.boundClick === 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
btn.addEventListener('click', () => this.resolveBulkAssetDeleteConfirm(false));
|
||||
btn.dataset.boundClick = 'true';
|
||||
});
|
||||
|
||||
this.setupAssetBorrowRequestModalListeners();
|
||||
|
||||
const assetDepartmentForm = document.getElementById('assetDepartmentForm');
|
||||
@@ -2396,14 +2375,6 @@ class AccountManager {
|
||||
btn.dataset.boundClick = 'true';
|
||||
});
|
||||
|
||||
// Close when clicking backdrop outside modal content
|
||||
document.querySelectorAll('.modal-backdrop').forEach(backdrop => {
|
||||
backdrop.addEventListener('click', (evt) => {
|
||||
if (evt.target === backdrop) {
|
||||
this.closeModals();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
updateAccountDisplay() {
|
||||
@@ -5250,7 +5221,7 @@ class AccountManager {
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded ${selectedStatusMeta.className}">${selectedStatusMeta.label}</span>
|
||||
</div>
|
||||
</div>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeAssetBorrowDetailsModal()" title="Đóng">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="assetBorrowDetailsModal" title="Đóng">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -5273,20 +5244,12 @@ class AccountManager {
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-4 border-t border-slate-100 bg-white flex justify-end">
|
||||
<button type="button" class="px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg hover:bg-slate-50" onclick="closeAssetBorrowDetailsModal()">Đóng</button>
|
||||
<button type="button" class="px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg hover:bg-slate-50" data-close-modal="assetBorrowDetailsModal">Đóng</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const modal = document.getElementById('assetBorrowDetailsModal');
|
||||
if (modal) {
|
||||
modal.addEventListener('click', event => {
|
||||
if (event.target === modal) {
|
||||
closeAssetBorrowDetailsModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setupAssetBorrowPagerListeners() {
|
||||
@@ -10827,6 +10790,53 @@ class AccountManager {
|
||||
document.getElementById('appModal').classList.add('open');
|
||||
}
|
||||
|
||||
setupModalCloseListeners() {
|
||||
if (this.modalCloseListenersBound) return;
|
||||
|
||||
// Modals are loaded asynchronously and some forms are recreated on each open.
|
||||
// Delegate clicks so both work without inline handlers blocked by CSP.
|
||||
document.addEventListener('click', event => {
|
||||
const closeButton = event.target.closest?.('[data-close-modal]');
|
||||
if (closeButton) {
|
||||
event.preventDefault();
|
||||
const modalId = closeButton.dataset.closeModal
|
||||
|| closeButton.closest('.modal-backdrop')?.id;
|
||||
if (modalId) this.closeModal(modalId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.target.classList?.contains('modal-backdrop')) {
|
||||
this.closeModal(event.target.id);
|
||||
}
|
||||
});
|
||||
this.modalCloseListenersBound = true;
|
||||
}
|
||||
|
||||
closeModal(modalId) {
|
||||
// These dialogs also own temporary state, child dialogs, or pending promises.
|
||||
const closeHandlers = {
|
||||
consumableBorrowRequestModal: closeConsumableBorrowRequestModal,
|
||||
consumableBorrowRequestsModal: closeConsumableBorrowRequestsModal,
|
||||
consumableRequestRejectModal: closeConsumableRequestRejectModal,
|
||||
consumableReturnModal: closeConsumableReturnModal,
|
||||
bulkDeleteAssetsConfirmModal: closeBulkDeleteAssetsConfirmModal,
|
||||
assetBorrowRequestModal: closeAssetBorrowRequestModal,
|
||||
assetPendingRequestsModal: closeAssetPendingRequestsModal,
|
||||
assetRequestDeleteConfirmModal: closeAssetRequestDeleteConfirmModal,
|
||||
userModal: closeUserModal,
|
||||
roleModal: closeRoleModal,
|
||||
userDetailsModal: closeUserDetailsModal,
|
||||
profileModal: closeProfileModal,
|
||||
notificationComposerModal: () => document.getElementById('notificationComposerModal')?.remove()
|
||||
};
|
||||
|
||||
if (Object.hasOwn(closeHandlers, modalId)) {
|
||||
closeHandlers[modalId]();
|
||||
} else {
|
||||
document.getElementById(modalId)?.classList.remove('open');
|
||||
}
|
||||
}
|
||||
|
||||
closeModals() {
|
||||
if (this.pendingAssetRequestDeleteConfirmResolver) {
|
||||
this.resolveAssetRequestDeleteConfirm(false);
|
||||
@@ -10834,10 +10844,9 @@ class AccountManager {
|
||||
if (this.pendingBulkAssetDeleteConfirmResolver) {
|
||||
this.resolveBulkAssetDeleteConfirm(false);
|
||||
}
|
||||
document.querySelectorAll('.modal-backdrop').forEach(modal => {
|
||||
modal.classList.remove('open');
|
||||
document.querySelectorAll('.modal-backdrop.open').forEach(modal => {
|
||||
this.closeModal(modal.id);
|
||||
});
|
||||
document.getElementById('notificationComposerModal')?.remove();
|
||||
this.pendingConsumableRequestRejectId = undefined;
|
||||
}
|
||||
|
||||
@@ -10926,7 +10935,7 @@ class AccountManager {
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3">
|
||||
<button type="button" onclick="closeProfileModal()" class="flex-1 px-4 py-2 bg-outline/10 hover:bg-outline/20 rounded-lg transition-colors">Cancel</button>
|
||||
<button type="button" data-close-modal="profileModal" class="flex-1 px-4 py-2 bg-outline/10 hover:bg-outline/20 rounded-lg transition-colors">Cancel</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary font-bold rounded-lg transition-colors">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -10950,14 +10959,6 @@ class AccountManager {
|
||||
|
||||
this.setupProfilePasswordToggles();
|
||||
|
||||
const modal = document.getElementById('profileModal');
|
||||
if (modal) {
|
||||
modal.addEventListener('click', (e) => {
|
||||
if (e.target === modal) {
|
||||
closeProfileModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setupProfilePasswordToggles() {
|
||||
@@ -11336,7 +11337,7 @@ class AccountManager {
|
||||
<textarea id="roleDescription" placeholder="Describe this role permissions" class="w-full px-3 py-2 border border-outline-variant/30 rounded-lg bg-surface-container-low dark:bg-slate-800 min-h-[90px]"></textarea>
|
||||
</div>
|
||||
<div class="flex gap-3 pt-2">
|
||||
<button type="button" onclick="closeRoleModal()" class="flex-1 px-4 py-2 bg-outline/10 hover:bg-outline/20 rounded-lg transition-colors">Cancel</button>
|
||||
<button type="button" data-close-modal="roleModal" class="flex-1 px-4 py-2 bg-outline/10 hover:bg-outline/20 rounded-lg transition-colors">Cancel</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary font-bold rounded-lg transition-colors">Save Role</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -11359,14 +11360,6 @@ class AccountManager {
|
||||
form.addEventListener('submit', (e) => this.saveRole(e));
|
||||
}
|
||||
|
||||
const modal = document.getElementById('roleModal');
|
||||
if (modal) {
|
||||
modal.addEventListener('click', function(e) {
|
||||
if (e.target === this) {
|
||||
closeRoleModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async saveRole(e) {
|
||||
@@ -11456,7 +11449,7 @@ class AccountManager {
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex gap-3 pt-4">
|
||||
<button type="button" onclick="closeUserModal()" class="flex-1 px-4 py-2 bg-outline/10 hover:bg-outline/20 rounded-lg transition-colors">Cancel</button>
|
||||
<button type="button" data-close-modal="userModal" class="flex-1 px-4 py-2 bg-outline/10 hover:bg-outline/20 rounded-lg transition-colors">Cancel</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary font-bold rounded-lg transition-colors">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -11494,15 +11487,6 @@ class AccountManager {
|
||||
});
|
||||
}
|
||||
|
||||
// Close on backdrop click
|
||||
const modal = document.getElementById('userModal');
|
||||
if (modal) {
|
||||
modal.addEventListener('click', function(e) {
|
||||
if (e.target === this) {
|
||||
closeUserModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async saveUser(e, userId) {
|
||||
@@ -11633,7 +11617,7 @@ class AccountManager {
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-3 pt-2">
|
||||
<button type="button" onclick="closeUserDetailsModal()" class="flex-1 px-4 py-2 bg-outline/10 hover:bg-outline/20 rounded-lg transition-colors">Close</button>
|
||||
<button type="button" data-close-modal="userDetailsModal" class="flex-1 px-4 py-2 bg-outline/10 hover:bg-outline/20 rounded-lg transition-colors">Close</button>
|
||||
<button type="button" id="userDetailEditBtn" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary font-bold rounded-lg transition-colors">Edit</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -11659,7 +11643,6 @@ class AccountManager {
|
||||
const createdDateEl = document.getElementById('userDetailCreatedDate');
|
||||
const lastLoginEl = document.getElementById('userDetailLastLogin');
|
||||
const editBtn = document.getElementById('userDetailEditBtn');
|
||||
const detailsModal = document.getElementById('userDetailsModal');
|
||||
|
||||
if (usernameEl) usernameEl.textContent = user?.Username || '-';
|
||||
if (fullNameEl) fullNameEl.textContent = user?.FullName || '-';
|
||||
@@ -11675,13 +11658,6 @@ class AccountManager {
|
||||
});
|
||||
}
|
||||
|
||||
if (detailsModal) {
|
||||
detailsModal.addEventListener('click', function(e) {
|
||||
if (e.target === this) {
|
||||
closeUserDetailsModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async deleteUserConfirm(userId) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Add New Account</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeAccountModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="accountModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -27,7 +27,7 @@
|
||||
<input type="password" id="accountPassword" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3" required placeholder="********">
|
||||
</div>
|
||||
<div class="flex gap-3 pt-4">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeAccountModal()">Cancel</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="accountModal">Cancel</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Save Account</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -39,7 +39,7 @@
|
||||
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Account Details</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeViewAccountModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="viewAccountModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -66,7 +66,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-3 pt-4">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeViewAccountModal()">Close</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="viewAccountModal">Close</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold edit-account-from-view">Edit</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -83,7 +83,7 @@
|
||||
<div class="p-6">
|
||||
<p class="text-sm text-slate-600 mb-6">Are you sure you want to delete the account for <strong id="deleteAccountUsername">-</strong>? This action cannot be undone.</p>
|
||||
<div class="flex gap-3">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeDeleteAccountModal()">Cancel</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="deleteAccountModal">Cancel</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-bold confirm-delete-account">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -95,7 +95,7 @@
|
||||
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Add New Application</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeAppModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="appModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -129,7 +129,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex gap-3 pt-4">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeAppModal()">Cancel</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="appModal">Cancel</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Save Application</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -141,7 +141,7 @@
|
||||
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Application Details</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeViewAppModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="viewAppModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -174,7 +174,7 @@
|
||||
<div id="viewAppStatus" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3 bg-slate-50 text-slate-600">-</div>
|
||||
</div>
|
||||
<div class="flex gap-3 pt-4">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeViewAppModal()">Close</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="viewAppModal">Close</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold edit-app-from-view">Edit</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -191,7 +191,7 @@
|
||||
<div class="p-6">
|
||||
<p class="text-sm text-slate-600 mb-6">Are you sure you want to delete <strong id="deleteAppName">-</strong>? This action cannot be undone.</p>
|
||||
<div class="flex gap-3">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeDeleteAppModal()">Cancel</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="deleteAppModal">Cancel</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-bold confirm-delete-app">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -203,7 +203,7 @@
|
||||
<div class="modal-content w-full max-w-2xl bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4 flex flex-col" style="max-height: calc(100vh - 2rem);">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Biểu mẫu tài sản</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeAssetModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="assetModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -293,7 +293,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-3 pt-2 sticky bottom-0 bg-white pb-1">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeAssetModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="assetModal">Hủy</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Lưu tài sản</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -305,7 +305,7 @@
|
||||
<div class="modal-content bg-white rounded-2xl shadow-2xl w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col">
|
||||
<div class="flex items-center justify-between px-6 py-4 border-b border-slate-100">
|
||||
<h3 class="text-base font-extrabold text-slate-900" id="consumableModalTitle">Thêm vật tư tiêu hao</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeConsumableModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="consumableModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -367,7 +367,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-3 pt-2">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeConsumableModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="consumableModal">Hủy</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Lưu vật tư</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -385,7 +385,7 @@
|
||||
</div>
|
||||
<p class="text-sm text-slate-600 mb-6">Bạn có chắc muốn xóa vật tư <strong id="deleteConsumableName">-</strong>? Hành động này không thể hoàn tác.</p>
|
||||
<div class="flex gap-3">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeDeleteConsumableModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="deleteConsumableModal">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-bold confirm-delete-consumable">Xóa</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -396,7 +396,7 @@
|
||||
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 id="consumableExportModalTitle" class="text-base font-extrabold text-slate-900">Mượn / xuất vật tư tiêu hao</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeConsumableExportModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="consumableExportModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -448,7 +448,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-3 pt-2">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeConsumableExportModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="consumableExportModal">Hủy</button>
|
||||
<button id="consumableExportSubmitBtn" type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Xác nhận mượn</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -460,7 +460,7 @@
|
||||
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-visible m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Tạo đơn mượn vật tư tiêu hao</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeConsumableBorrowRequestModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="consumableBorrowRequestModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -522,7 +522,7 @@
|
||||
</div>
|
||||
<p class="text-xs text-slate-500">Tồn kho chỉ được trừ sau khi Asset/Admin chấp nhận đơn.</p>
|
||||
<div class="flex gap-3 pt-2">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeConsumableBorrowRequestModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="consumableBorrowRequestModal">Hủy</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Gửi đơn mượn</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -537,7 +537,7 @@
|
||||
<h3 id="consumableBorrowRequestsModalTitle" class="text-base font-extrabold text-slate-900">Đơn mượn vật tư của tôi</h3>
|
||||
<p id="consumableBorrowRequestsModalSubtitle" class="text-xs text-slate-500 mt-0.5">Theo dõi trạng thái các đơn đã gửi.</p>
|
||||
</div>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeConsumableBorrowRequestsModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="consumableBorrowRequestsModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -575,7 +575,7 @@
|
||||
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 id="consumableRequestRejectModalTitle" class="text-base font-extrabold text-slate-900">Từ chối đơn vật tư</h3>
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeConsumableRequestRejectModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="consumableRequestRejectModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -586,7 +586,7 @@
|
||||
<textarea id="consumableRequestRejectReasonInput" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3 h-24 resize-none" placeholder="Nhập lý do để người tạo đơn biết..." required></textarea>
|
||||
</div>
|
||||
<div class="flex gap-3">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg hover:bg-slate-50" onclick="closeConsumableRequestRejectModal()">Đóng</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg hover:bg-slate-50" data-close-modal="consumableRequestRejectModal">Đóng</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-bold">Xác nhận từ chối</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -598,7 +598,7 @@
|
||||
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 id="consumableReturnModalTitle" class="text-base font-extrabold text-slate-900">Hoàn trả vật tư về kho</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeConsumableReturnModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="consumableReturnModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -632,7 +632,7 @@
|
||||
</div>
|
||||
<p id="consumableReturnHelpText" class="text-xs text-slate-500">Khi xác nhận, số lượng này sẽ được cộng lại vào tồn kho ngay.</p>
|
||||
<div class="flex gap-3 pt-2">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeConsumableReturnModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="consumableReturnModal">Hủy</button>
|
||||
<button id="consumableReturnSubmitBtn" type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Xác nhận trả kho</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -644,7 +644,7 @@
|
||||
<div class="modal-content w-full max-w-6xl bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4 flex flex-col" style="max-height: calc(100vh - 2rem);">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Lịch sử mượn / xuất / trả vật tư</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeConsumableExportHistoryModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="consumableExportHistoryModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -684,7 +684,7 @@
|
||||
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Xuất tài sản</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeBorrowAssetModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="borrowAssetModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -729,7 +729,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-3 pt-2">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeBorrowAssetModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="borrowAssetModal">Hủy</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Xác nhận xuất</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -741,7 +741,7 @@
|
||||
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Hỏng / Thanh lý tài sản</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeAssetDamageModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="assetDamageModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -789,7 +789,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-3 pt-2">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeAssetDamageModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="assetDamageModal">Hủy</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-bold">Xác nhận</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -801,7 +801,7 @@
|
||||
<div class="modal-content w-full max-w-6xl bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4 flex flex-col" style="max-height: calc(100vh - 2rem);">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Lịch sử xuất tài sản</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeAssetExportHistoryModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="assetExportHistoryModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -837,7 +837,7 @@
|
||||
<div class="modal-content w-full max-w-6xl bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4 flex flex-col" style="max-height: calc(100vh - 2rem);">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Tài sản hỏng / thanh lý</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeAssetDamageHistoryModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="assetDamageHistoryModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -876,7 +876,7 @@
|
||||
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-visible m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 id="assetBorrowRequestModalTitle" class="text-base font-extrabold text-slate-900">Tạo đơn mượn tài sản</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeAssetBorrowRequestModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="assetBorrowRequestModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -941,7 +941,7 @@
|
||||
<textarea id="assetBorrowNoteInput" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3 h-20 resize-none" placeholder="Nhập ghi chú (nếu có)"></textarea>
|
||||
</div>
|
||||
<div class="flex gap-3 pt-2">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeAssetBorrowRequestModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="assetBorrowRequestModal">Hủy</button>
|
||||
<button type="submit" id="assetBorrowRequestSubmitBtn" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Tạo đơn mượn</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -953,7 +953,7 @@
|
||||
<div class="modal-content w-full max-w-6xl bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4 flex flex-col" style="max-height: calc(100vh - 2rem);">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Đơn chờ xử lý</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeAssetPendingRequestsModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="assetPendingRequestsModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -986,7 +986,7 @@
|
||||
<div class="p-6">
|
||||
<p id="assetRequestDeleteConfirmMessage" class="text-sm text-slate-600 mb-6">Bạn có chắc muốn thực hiện thao tác này?</p>
|
||||
<div class="flex gap-3">
|
||||
<button type="button" class="cancel-asset-request-delete-confirm flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg">Đóng</button>
|
||||
<button type="button" data-close-modal="assetRequestDeleteConfirmModal" class="cancel-asset-request-delete-confirm flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg">Đóng</button>
|
||||
<button type="button" id="confirmAssetRequestDeleteBtn" class="flex-1 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-bold">Xóa đơn</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -998,7 +998,7 @@
|
||||
<div class="modal-content w-full max-w-lg bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Từ chối đơn</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeAssetRequestRejectModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="assetRequestRejectModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -1009,7 +1009,7 @@
|
||||
<textarea id="assetRequestRejectReasonInput" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3 h-24 resize-none" placeholder="Nhập lý do từ chối..." required></textarea>
|
||||
</div>
|
||||
<div class="flex gap-3">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeAssetRequestRejectModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="assetRequestRejectModal">Hủy</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-bold">Xác nhận từ chối</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -1021,13 +1021,13 @@
|
||||
<div class="modal-content w-full max-w-2xl bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4 flex flex-col" style="max-height: calc(100vh - 2rem);">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900">Chi tiết tài sản</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeViewAssetModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="viewAssetModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
<div id="assetDetailsContent" class="p-6 grid grid-cols-1 md:grid-cols-2 gap-3 text-sm text-slate-700 overflow-y-auto"></div>
|
||||
<div class="p-6 pt-3 flex gap-3 border-t border-slate-100 bg-white">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeViewAssetModal()">Đóng</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="viewAssetModal">Đóng</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold edit-asset-from-view">Sửa</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1043,7 +1043,7 @@
|
||||
<div class="p-6">
|
||||
<p class="text-sm text-slate-600 mb-6">Bạn có chắc muốn xóa tài sản <strong id="deleteAssetName">-</strong>? Hành động này không thể hoàn tác.</p>
|
||||
<div class="flex gap-3">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeDeleteAssetModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="deleteAssetModal">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-bold confirm-delete-asset">Xóa</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1063,7 +1063,7 @@
|
||||
Số lượng: <strong id="bulkDeleteAssetsConfirmCount">0</strong> tài sản
|
||||
</div>
|
||||
<div class="flex gap-3">
|
||||
<button type="button" class="cancel-bulk-asset-delete-confirm flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeBulkDeleteAssetsConfirmModal()">Hủy</button>
|
||||
<button type="button" class="cancel-bulk-asset-delete-confirm flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="bulkDeleteAssetsConfirmModal">Hủy</button>
|
||||
<button type="button" id="confirmBulkAssetDeleteBtn" class="flex-1 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-bold">Xóa</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1075,7 +1075,7 @@
|
||||
<div class="modal-content w-full max-w-md bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900" id="assetDepartmentModalTitle">Thêm phòng ban</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeAssetDepartmentModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="assetDepartmentModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -1085,7 +1085,7 @@
|
||||
<input type="text" id="assetDepartmentNameInput" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3" required placeholder="Ví dụ: Kỹ thuật">
|
||||
</div>
|
||||
<div class="flex gap-3">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeAssetDepartmentModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="assetDepartmentModal">Hủy</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Lưu</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -1102,7 +1102,7 @@
|
||||
<div class="p-6">
|
||||
<p class="text-sm text-slate-600 mb-6">Bạn có chắc muốn xóa phòng ban <strong id="deleteAssetDepartmentName">-</strong>? Các tài sản đang gắn phòng ban này sẽ được để trống phòng ban.</p>
|
||||
<div class="flex gap-3">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeDeleteAssetDepartmentModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="deleteAssetDepartmentModal">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-bold confirm-delete-asset-department">Xóa</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1114,7 +1114,7 @@
|
||||
<div class="modal-content w-full max-w-md bg-white rounded-xl shadow-2xl border border-slate-200 overflow-hidden m-4">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50">
|
||||
<h3 class="text-base font-extrabold text-slate-900" id="assetProjectModalTitle">Thêm dự án</h3>
|
||||
<button class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" onclick="closeAssetProjectModal()">
|
||||
<button type="button" class="p-1.5 rounded-lg hover:bg-slate-200 text-slate-400 transition-colors" data-close-modal="assetProjectModal">
|
||||
<span class="material-symbols-outlined">close</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -1124,7 +1124,7 @@
|
||||
<input type="text" id="assetProjectNameInput" class="w-full border border-slate-200 rounded-lg text-sm py-2.5 px-3" required placeholder="Ví dụ: AGV">
|
||||
</div>
|
||||
<div class="flex gap-3">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeAssetProjectModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="assetProjectModal">Hủy</button>
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-primary hover:bg-primary-dim text-on-primary rounded-lg text-xs font-bold">Lưu</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -1141,7 +1141,7 @@
|
||||
<div class="p-6">
|
||||
<p class="text-sm text-slate-600 mb-6">Bạn có chắc muốn xóa dự án <strong id="deleteAssetProjectName">-</strong>? Các tài sản đang gắn dự án này sẽ được để trống dự án.</p>
|
||||
<div class="flex gap-3">
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" onclick="closeDeleteAssetProjectModal()">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 text-xs font-bold text-slate-600 border border-slate-200 rounded-lg" data-close-modal="deleteAssetProjectModal">Hủy</button>
|
||||
<button type="button" class="flex-1 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-bold confirm-delete-asset-project">Xóa</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -425,6 +425,6 @@
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script src="../js/app.js?v=20260806-5"></script>
|
||||
<script src="../js/app.js?v=20260915-1"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
240
test/modal-close.test.js
Normal file
240
test/modal-close.test.js
Normal file
@@ -0,0 +1,240 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const vm = require('node:vm');
|
||||
|
||||
const appSource = fs.readFileSync(path.join(__dirname, '../public/js/app.js'), 'utf8');
|
||||
|
||||
// A small DOM fixture lets the actual event handler and cleanup methods run
|
||||
// without starting authentication, network requests, or the application itself.
|
||||
function createFixture() {
|
||||
const elements = [];
|
||||
const listeners = new Map();
|
||||
class Element {
|
||||
constructor({ id = '', classes = [], dataset = {}, parent = null } = {}) {
|
||||
this.id = id;
|
||||
this.dataset = dataset;
|
||||
this.parentElement = parent;
|
||||
this.children = [];
|
||||
this.value = '';
|
||||
this.isConnected = true;
|
||||
const names = new Set(classes);
|
||||
this.classList = {
|
||||
contains: name => names.has(name),
|
||||
add: (...added) => added.forEach(name => names.add(name)),
|
||||
remove: (...removed) => removed.forEach(name => names.delete(name))
|
||||
};
|
||||
if (parent) parent.children.push(this);
|
||||
elements.push(this);
|
||||
}
|
||||
matches(selector) {
|
||||
if (selector === '[data-close-modal]') return 'closeModal' in this.dataset;
|
||||
if (selector.startsWith('.')) {
|
||||
return selector.slice(1).split('.').every(name => this.classList.contains(name));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
closest(selector) {
|
||||
return this.matches(selector) ? this : this.parentElement?.closest(selector) || null;
|
||||
}
|
||||
getAttribute(name) {
|
||||
return name === 'data-close-modal' ? this.dataset.closeModal ?? null : null;
|
||||
}
|
||||
remove() {
|
||||
this.isConnected = false;
|
||||
this.children.forEach(child => child.remove());
|
||||
}
|
||||
set innerHTML(value) {
|
||||
assert.equal(value, '', 'The fixture only supports clearing an existing container');
|
||||
this.children.forEach(child => child.remove());
|
||||
this.children = [];
|
||||
}
|
||||
get innerHTML() {
|
||||
return this.children.length ? '<dialog />' : '';
|
||||
}
|
||||
}
|
||||
const document = {
|
||||
addEventListener(type, handler) {
|
||||
if (!listeners.has(type)) listeners.set(type, []);
|
||||
listeners.get(type).push(handler);
|
||||
},
|
||||
getElementById: id => elements.find(node => node.id === id && node.isConnected) || null,
|
||||
querySelectorAll: selector => elements.filter(node => node.isConnected && node.matches(selector)),
|
||||
contains: node => node.isConnected
|
||||
};
|
||||
const context = vm.createContext({
|
||||
document,
|
||||
Element,
|
||||
HTMLElement: Element,
|
||||
window: { fetch: async () => { throw new Error('Unexpected network request'); } },
|
||||
console
|
||||
});
|
||||
vm.runInContext(`${appSource}\napp = Object.create(AccountManager.prototype); globalThis.manager = app;`, context);
|
||||
const add = options => new Element(options);
|
||||
const modal = (id, parent) => add({ id, parent, classes: ['modal-backdrop', 'open'] });
|
||||
function dispatch(type, target, properties = {}) {
|
||||
const event = {
|
||||
target,
|
||||
defaultPrevented: false,
|
||||
preventDefault() { this.defaultPrevented = true; },
|
||||
stopPropagation() {},
|
||||
...properties
|
||||
};
|
||||
(listeners.get(type) || []).forEach(handler => handler(event));
|
||||
return event;
|
||||
}
|
||||
return { manager: context.manager, document, listeners, add, modal, dispatch };
|
||||
}
|
||||
|
||||
test('close buttons work after asynchronous modal insertion, including clicks on the icon', async () => {
|
||||
const fixture = createFixture();
|
||||
fixture.manager.setupModalCloseListeners();
|
||||
await Promise.resolve(); // modals.html is fetched after listeners are installed.
|
||||
const parent = fixture.modal('accountModal');
|
||||
const other = fixture.modal('assetModal');
|
||||
const button = fixture.add({ parent, dataset: { closeModal: 'accountModal' } });
|
||||
const icon = fixture.add({ parent: button });
|
||||
|
||||
const event = fixture.dispatch('click', icon);
|
||||
|
||||
assert.equal(parent.classList.contains('open'), false);
|
||||
assert.equal(other.classList.contains('open'), true);
|
||||
assert.equal(event.defaultPrevented, true);
|
||||
|
||||
parent.classList.add('open');
|
||||
fixture.dispatch('click', button);
|
||||
assert.equal(parent.classList.contains('open'), false);
|
||||
});
|
||||
|
||||
test('repeated setup installs one modal close handler', () => {
|
||||
const fixture = createFixture();
|
||||
fixture.manager.setupModalCloseListeners();
|
||||
fixture.manager.setupModalCloseListeners();
|
||||
const target = fixture.add({ dataset: { closeModal: 'accountModal' } });
|
||||
const closed = [];
|
||||
fixture.manager.closeModal = id => closed.push(id);
|
||||
|
||||
fixture.dispatch('click', target);
|
||||
|
||||
assert.deepEqual(closed, ['accountModal']);
|
||||
assert.equal(fixture.listeners.get('click').length, 1);
|
||||
});
|
||||
|
||||
test('backdrop clicks close their dialog, while clicks inside the form leave it open', () => {
|
||||
const fixture = createFixture();
|
||||
fixture.manager.setupModalCloseListeners();
|
||||
const modal = fixture.modal('assetModal');
|
||||
const other = fixture.modal('accountModal');
|
||||
const content = fixture.add({ parent: modal });
|
||||
const input = fixture.add({ parent: content });
|
||||
|
||||
fixture.dispatch('click', input);
|
||||
assert.equal(modal.classList.contains('open'), true);
|
||||
fixture.dispatch('click', modal);
|
||||
assert.equal(modal.classList.contains('open'), false);
|
||||
assert.equal(other.classList.contains('open'), true);
|
||||
});
|
||||
|
||||
test('canceling destructive confirmations resolves false exactly once', async () => {
|
||||
for (const [modalId, resolverField] of [
|
||||
['assetRequestDeleteConfirmModal', 'pendingAssetRequestDeleteConfirmResolver'],
|
||||
['bulkDeleteAssetsConfirmModal', 'pendingBulkAssetDeleteConfirmResolver']
|
||||
]) {
|
||||
const fixture = createFixture();
|
||||
fixture.manager.setupModalCloseListeners();
|
||||
const modal = fixture.modal(modalId);
|
||||
const button = fixture.add({ parent: modal, dataset: { closeModal: modalId } });
|
||||
const resolutions = [];
|
||||
const pending = new Promise(resolve => {
|
||||
fixture.manager[resolverField] = value => {
|
||||
resolutions.push(value);
|
||||
resolve(value);
|
||||
};
|
||||
});
|
||||
|
||||
fixture.dispatch('click', button);
|
||||
fixture.dispatch('click', button);
|
||||
|
||||
assert.equal(await pending, false);
|
||||
assert.deepEqual(resolutions, [false]);
|
||||
assert.equal(fixture.manager[resolverField], undefined);
|
||||
assert.equal(modal.classList.contains('open'), false);
|
||||
}
|
||||
});
|
||||
|
||||
test('closing consumable rejection and return dialogs clears pending input state', () => {
|
||||
const fixture = createFixture();
|
||||
const rejectModal = fixture.modal('consumableRequestRejectModal');
|
||||
const idInput = fixture.add({ id: 'consumableRequestRejectIdInput', parent: rejectModal });
|
||||
const reasonInput = fixture.add({ id: 'consumableRequestRejectReasonInput', parent: rejectModal });
|
||||
idInput.value = '42';
|
||||
reasonInput.value = 'Previous reason';
|
||||
fixture.manager.pendingConsumableRequestRejectId = 42;
|
||||
fixture.manager.closeModal(rejectModal.id);
|
||||
assert.equal(rejectModal.classList.contains('open'), false);
|
||||
assert.equal(idInput.value, '');
|
||||
assert.equal(reasonInput.value, '');
|
||||
assert.equal(fixture.manager.pendingConsumableRequestRejectId, undefined);
|
||||
|
||||
const returnModal = fixture.modal('consumableReturnModal');
|
||||
fixture.manager.pendingConsumableReturnHistoryId = 99;
|
||||
fixture.manager.closeModal(returnModal.id);
|
||||
assert.equal(returnModal.classList.contains('open'), false);
|
||||
assert.equal(fixture.manager.pendingConsumableReturnHistoryId, undefined);
|
||||
});
|
||||
|
||||
test('closing dynamic user, role, profile and detail dialogs clears their containers', () => {
|
||||
for (const modalId of ['userModal', 'roleModal', 'profileModal', 'userDetailsModal']) {
|
||||
const fixture = createFixture();
|
||||
fixture.manager.setupModalCloseListeners();
|
||||
const container = fixture.add({ id: `${modalId}Container` });
|
||||
const modal = fixture.modal(modalId, container);
|
||||
const button = fixture.add({ parent: modal, dataset: { closeModal: modalId } });
|
||||
|
||||
fixture.dispatch('click', button);
|
||||
|
||||
assert.equal(container.innerHTML, '', modalId);
|
||||
assert.equal(fixture.document.getElementById(modalId), null, modalId);
|
||||
}
|
||||
});
|
||||
|
||||
test('Escape closes dialogs through their cleanup handlers', () => {
|
||||
const fixture = createFixture();
|
||||
for (const method of [
|
||||
'updateAccountDisplay', 'setupAccountRowListeners', 'setupFilters',
|
||||
'setupResponsiveShell', 'closeMobileNav', 'closeNotificationPopover'
|
||||
]) fixture.manager[method] = () => {};
|
||||
fixture.manager.setupEventListeners();
|
||||
const confirmation = fixture.modal('bulkDeleteAssetsConfirmModal');
|
||||
let resolution;
|
||||
fixture.manager.pendingBulkAssetDeleteConfirmResolver = value => { resolution = value; };
|
||||
const container = fixture.add({ id: 'profileModalContainer' });
|
||||
fixture.modal('profileModal', container);
|
||||
const notification = fixture.modal('notificationComposerModal');
|
||||
|
||||
fixture.dispatch('keydown', null, { key: 'Escape' });
|
||||
|
||||
assert.equal(confirmation.classList.contains('open'), false);
|
||||
assert.equal(resolution, false);
|
||||
assert.equal(container.innerHTML, '');
|
||||
assert.equal(notification.isConnected, false);
|
||||
});
|
||||
|
||||
test('closing a missing modal is harmless', () => {
|
||||
const fixture = createFixture();
|
||||
assert.doesNotThrow(() => fixture.manager.closeModal('alreadyRemovedModal'));
|
||||
});
|
||||
|
||||
test('static and dynamic modal close controls avoid inline scripts and form submission', () => {
|
||||
for (const relativePath of ['public/modals.html', 'public/pages/index.html', 'public/js/app.js']) {
|
||||
const source = fs.readFileSync(path.join(__dirname, '..', relativePath), 'utf8');
|
||||
assert.doesNotMatch(source, /\bonclick\s*=\s*["'][^"']*\bclose\w*Modal\s*\(/i, relativePath);
|
||||
const closeButtons = [...source.matchAll(/<button\b[^>]*\bdata-close-modal\s*=\s*["'][^"']+["'][^>]*>/g)];
|
||||
if (relativePath !== 'public/pages/index.html') assert.ok(closeButtons.length > 0, relativePath);
|
||||
for (const [button] of closeButtons) {
|
||||
assert.match(button, /\btype\s*=\s*["']button["']/, `${relativePath}: ${button}`);
|
||||
assert.doesNotMatch(button, /\bonclick\s*=/, `${relativePath}: ${button}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -127,6 +127,7 @@ test('security headers and no-store API caching are enabled', async () => {
|
||||
|
||||
assert.equal(response.status, 200);
|
||||
assert.match(response.headers.get('content-security-policy') || '', /default-src 'self'/);
|
||||
assert.match(response.headers.get('content-security-policy') || '', /script-src-attr 'none'/);
|
||||
assert.equal(response.headers.get('x-powered-by'), null);
|
||||
assert.equal(response.headers.get('cache-control'), 'no-store');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user