fixx 01
This commit is contained in:
@@ -66,6 +66,7 @@ class AccountManager {
|
||||
this.pendingAssetRequestRejectId = undefined;
|
||||
this.assetBorrowAutoRefreshTimer = undefined;
|
||||
this.pendingAssetRequestDeleteConfirmResolver = undefined;
|
||||
this.pendingBulkAssetDeleteConfirmResolver = undefined;
|
||||
}
|
||||
|
||||
configureNotifications() {
|
||||
@@ -1228,6 +1229,21 @@ class AccountManager {
|
||||
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');
|
||||
@@ -3358,6 +3374,42 @@ class AccountManager {
|
||||
}
|
||||
}
|
||||
|
||||
resolveBulkAssetDeleteConfirm(confirmed) {
|
||||
const modal = document.getElementById('bulkDeleteAssetsConfirmModal');
|
||||
if (modal) {
|
||||
modal.classList.remove('open');
|
||||
}
|
||||
|
||||
const resolver = this.pendingBulkAssetDeleteConfirmResolver;
|
||||
this.pendingBulkAssetDeleteConfirmResolver = undefined;
|
||||
if (typeof resolver === 'function') {
|
||||
resolver(Boolean(confirmed));
|
||||
}
|
||||
}
|
||||
|
||||
async confirmBulkAssetDelete(selectedCount) {
|
||||
const modal = document.getElementById('bulkDeleteAssetsConfirmModal');
|
||||
const messageNode = document.getElementById('bulkDeleteAssetsConfirmMessage');
|
||||
const countNode = document.getElementById('bulkDeleteAssetsConfirmCount');
|
||||
|
||||
if (!modal || !messageNode || !countNode) {
|
||||
return window.confirm(`Bạn có chắc muốn xóa ${selectedCount} tài sản đã chọn?`);
|
||||
}
|
||||
|
||||
countNode.textContent = String(selectedCount);
|
||||
messageNode.textContent = `Bạn có chắc muốn xóa ${selectedCount} tài sản đã chọn?`;
|
||||
|
||||
if (this.pendingBulkAssetDeleteConfirmResolver) {
|
||||
this.resolveBulkAssetDeleteConfirm(false);
|
||||
}
|
||||
|
||||
modal.classList.add('open');
|
||||
|
||||
return new Promise(resolve => {
|
||||
this.pendingBulkAssetDeleteConfirmResolver = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
async confirmAssetRequestDelete(message, confirmButtonText = 'Xóa đơn') {
|
||||
const modal = document.getElementById('assetRequestDeleteConfirmModal');
|
||||
const messageNode = document.getElementById('assetRequestDeleteConfirmMessage');
|
||||
@@ -3580,7 +3632,7 @@ class AccountManager {
|
||||
</div>
|
||||
<button id="bulkDeleteAssetsBtn" class="border border-red-200 text-red-600 px-3 py-1.5 rounded-md text-[11px] font-bold flex items-center gap-1.5 transition-colors ${(selectedCount === 0 || !canManageAssets) ? 'opacity-50 cursor-not-allowed' : 'hover:bg-red-50'}" ${(selectedCount === 0 || !canManageAssets) ? 'disabled' : ''}>
|
||||
<span class="material-symbols-outlined text-base">delete_sweep</span>
|
||||
Xóa dã chọn (<span id="selectedAssetCount">${selectedCount}</span>)
|
||||
Xóa đã chọn (<span id="selectedAssetCount">${selectedCount}</span>)
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -3897,7 +3949,7 @@ class AccountManager {
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmed = window.confirm(`Bạn có chắc mudn xóa ${selectedIds.length} tài sản dã chọn?`);
|
||||
const confirmed = await this.confirmBulkAssetDelete(selectedIds.length);
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
@@ -6148,6 +6200,9 @@ class AccountManager {
|
||||
if (this.pendingAssetRequestDeleteConfirmResolver) {
|
||||
this.resolveAssetRequestDeleteConfirm(false);
|
||||
}
|
||||
if (this.pendingBulkAssetDeleteConfirmResolver) {
|
||||
this.resolveBulkAssetDeleteConfirm(false);
|
||||
}
|
||||
document.querySelectorAll('.modal-backdrop').forEach(modal => {
|
||||
modal.classList.remove('open');
|
||||
});
|
||||
@@ -7058,6 +7113,9 @@ function closeAllModals() {
|
||||
if (app?.pendingAssetRequestDeleteConfirmResolver) {
|
||||
app.resolveAssetRequestDeleteConfirm(false);
|
||||
}
|
||||
if (app?.pendingBulkAssetDeleteConfirmResolver) {
|
||||
app.resolveBulkAssetDeleteConfirm(false);
|
||||
}
|
||||
document.querySelectorAll('.modal-backdrop').forEach(modal => {
|
||||
modal.classList.remove('open');
|
||||
});
|
||||
@@ -7099,6 +7157,18 @@ function closeDeleteAssetModal() {
|
||||
document.getElementById('deleteAssetModal').classList.remove('open');
|
||||
}
|
||||
|
||||
function closeBulkDeleteAssetsConfirmModal() {
|
||||
if (app?.pendingBulkAssetDeleteConfirmResolver) {
|
||||
app.resolveBulkAssetDeleteConfirm(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const modal = document.getElementById('bulkDeleteAssetsConfirmModal');
|
||||
if (modal) {
|
||||
modal.classList.remove('open');
|
||||
}
|
||||
}
|
||||
|
||||
function closeBorrowAssetModal() {
|
||||
const modal = document.getElementById('borrowAssetModal');
|
||||
if (modal) {
|
||||
|
||||
Reference in New Issue
Block a user