fix: replace all native confirm() dialogs with styled modal macros
Some checks failed
Some checks failed
Migrated ~68 native browser confirm() calls across 74 files to use the project's confirm_modal/confirm_modal_dynamic Jinja2 macros, providing consistent styled confirmation dialogs instead of plain browser popups. Modules updated: core, tenancy, cms, marketplace, messaging, billing, customers, orders, cart. Uses danger/warning/info variants and double-confirm pattern for destructive delete operations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,9 @@ function adminUserDetailPage() {
|
||||
error: null,
|
||||
userId: null,
|
||||
currentUserId: null,
|
||||
showToggleStatusModal: false,
|
||||
showDeleteModal: false,
|
||||
showDeleteFinalModal: false,
|
||||
|
||||
// Initialize
|
||||
async init() {
|
||||
@@ -116,11 +119,6 @@ function adminUserDetailPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm(`Are you sure you want to ${action} "${this.adminUser.username}"?`)) {
|
||||
adminUserDetailLog.info('Status toggle cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/admin-users/${this.userId}/status`;
|
||||
@@ -142,6 +140,12 @@ function adminUserDetailPage() {
|
||||
}
|
||||
},
|
||||
|
||||
// Intermediate step for double-confirm delete
|
||||
confirmDeleteStep() {
|
||||
adminUserDetailLog.info('First delete confirmation accepted, showing final confirmation');
|
||||
this.showDeleteFinalModal = true;
|
||||
},
|
||||
|
||||
// Delete admin user
|
||||
async deleteAdminUser() {
|
||||
adminUserDetailLog.info('Delete admin user requested:', this.userId);
|
||||
@@ -152,17 +156,6 @@ function adminUserDetailPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm(`Are you sure you want to delete admin user "${this.adminUser.username}"?\n\nThis action cannot be undone.`)) {
|
||||
adminUserDetailLog.info('Delete cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
// Second confirmation for safety
|
||||
if (!confirm(`FINAL CONFIRMATION\n\nAre you absolutely sure you want to delete "${this.adminUser.username}"?`)) {
|
||||
adminUserDetailLog.info('Delete cancelled by user (second confirmation)');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/admin-users/${this.userId}`;
|
||||
|
||||
@@ -26,6 +26,10 @@ function adminUserEditPage() {
|
||||
// Confirmation modal state
|
||||
showRemovePlatformModal: false,
|
||||
platformToRemove: null,
|
||||
showToggleSuperAdminModal: false,
|
||||
showToggleStatusModal: false,
|
||||
showDeleteModal: false,
|
||||
showDeleteFinalModal: false,
|
||||
|
||||
// Initialize
|
||||
async init() {
|
||||
@@ -149,11 +153,6 @@ function adminUserEditPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm(`Are you sure you want to ${action} super admin "${this.adminUser.username}"?`)) {
|
||||
adminUserEditLog.info('Super admin toggle cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/admin-users/${this.userId}/super-admin`;
|
||||
@@ -192,11 +191,6 @@ function adminUserEditPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm(`Are you sure you want to ${action} "${this.adminUser.username}"?`)) {
|
||||
adminUserEditLog.info('Status toggle cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/admin-users/${this.userId}/status`;
|
||||
@@ -298,6 +292,12 @@ function adminUserEditPage() {
|
||||
this.selectedPlatformId = null;
|
||||
},
|
||||
|
||||
// Intermediate step for double-confirm delete
|
||||
confirmDeleteStep() {
|
||||
adminUserEditLog.info('First delete confirmation accepted, showing final confirmation');
|
||||
this.showDeleteFinalModal = true;
|
||||
},
|
||||
|
||||
// Delete admin user
|
||||
async deleteAdminUser() {
|
||||
adminUserEditLog.info('Delete admin user requested:', this.userId);
|
||||
@@ -308,17 +308,6 @@ function adminUserEditPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm(`Are you sure you want to delete admin user "${this.adminUser.username}"?\n\nThis action cannot be undone.`)) {
|
||||
adminUserEditLog.info('Delete cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
// Second confirmation for safety
|
||||
if (!confirm(`FINAL CONFIRMATION\n\nAre you absolutely sure you want to delete "${this.adminUser.username}"?`)) {
|
||||
adminUserEditLog.info('Delete cancelled by user (second confirmation)');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/admin-users/${this.userId}`;
|
||||
|
||||
@@ -17,6 +17,9 @@ function adminUsersPage() {
|
||||
loading: false,
|
||||
error: null,
|
||||
currentUserId: null,
|
||||
showDeleteModal: false,
|
||||
showDeleteFinalModal: false,
|
||||
adminToDelete: null,
|
||||
filters: {
|
||||
search: '',
|
||||
is_super_admin: '',
|
||||
@@ -286,6 +289,12 @@ function adminUsersPage() {
|
||||
window.location.href = `/admin/admin-users/${admin.id}/edit`;
|
||||
},
|
||||
|
||||
// Intermediate step for double-confirm delete
|
||||
confirmDeleteStep() {
|
||||
adminUsersLog.info('First delete confirmation accepted, showing final confirmation');
|
||||
this.showDeleteFinalModal = true;
|
||||
},
|
||||
|
||||
async deleteAdminUser(admin) {
|
||||
adminUsersLog.warn('Delete admin user requested:', admin.username);
|
||||
|
||||
@@ -295,17 +304,6 @@ function adminUsersPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm(`Are you sure you want to delete admin user "${admin.username}"?\n\nThis action cannot be undone.`)) {
|
||||
adminUsersLog.info('Delete cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
// Second confirmation for safety
|
||||
if (!confirm(`FINAL CONFIRMATION\n\nAre you absolutely sure you want to delete "${admin.username}"?`)) {
|
||||
adminUsersLog.info('Delete cancelled by user (second confirmation)');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = `/admin/admin-users/${admin.id}`;
|
||||
window.LogConfig.logApiCall('DELETE', url, null, 'request');
|
||||
|
||||
@@ -16,6 +16,10 @@ function adminMerchantDetail() {
|
||||
error: null,
|
||||
merchantId: null,
|
||||
|
||||
// Modal state
|
||||
showDeleteMerchantModal: false,
|
||||
showDeleteMerchantFinalModal: false,
|
||||
|
||||
// Subscription state
|
||||
platforms: [],
|
||||
subscriptions: [],
|
||||
@@ -239,8 +243,8 @@ function adminMerchantDetail() {
|
||||
return formatted;
|
||||
},
|
||||
|
||||
// Delete merchant
|
||||
async deleteMerchant() {
|
||||
// Prompt delete merchant (first step of double confirm)
|
||||
promptDeleteMerchant() {
|
||||
merchantDetailLog.info('Delete merchant requested:', this.merchantId);
|
||||
|
||||
if (this.merchant?.store_count > 0) {
|
||||
@@ -248,17 +252,16 @@ function adminMerchantDetail() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm(`Are you sure you want to delete merchant "${this.merchant.name}"?\n\nThis action cannot be undone.`)) {
|
||||
merchantDetailLog.info('Delete cancelled by user');
|
||||
return;
|
||||
}
|
||||
this.showDeleteMerchantModal = true;
|
||||
},
|
||||
|
||||
// Second confirmation for safety
|
||||
if (!confirm(`FINAL CONFIRMATION\n\nAre you absolutely sure you want to delete "${this.merchant.name}"?`)) {
|
||||
merchantDetailLog.info('Delete cancelled by user (second confirmation)');
|
||||
return;
|
||||
}
|
||||
// Confirm first step, show final confirmation
|
||||
confirmDeleteMerchantStep() {
|
||||
this.showDeleteMerchantFinalModal = true;
|
||||
},
|
||||
|
||||
// Delete merchant
|
||||
async deleteMerchant() {
|
||||
try {
|
||||
const url = `/admin/merchants/${this.merchantId}?confirm=true`;
|
||||
window.LogConfig.logApiCall('DELETE', url, null, 'request');
|
||||
|
||||
@@ -18,6 +18,12 @@ function adminMerchantEdit() {
|
||||
saving: false,
|
||||
merchantId: null,
|
||||
|
||||
// Modal state
|
||||
showToggleVerificationModal: false,
|
||||
showToggleActiveModal: false,
|
||||
showDeleteMerchantModal: false,
|
||||
showDeleteMerchantFinalModal: false,
|
||||
|
||||
// Transfer ownership state
|
||||
showTransferOwnershipModal: false,
|
||||
transferring: false,
|
||||
@@ -166,11 +172,6 @@ function adminMerchantEdit() {
|
||||
const action = this.merchant.is_verified ? 'unverify' : 'verify';
|
||||
merchantEditLog.info(`Toggle verification: ${action}`);
|
||||
|
||||
if (!confirm(`Are you sure you want to ${action} this merchant?`)) {
|
||||
merchantEditLog.info('Verification toggle cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/merchants/${this.merchantId}/verification`;
|
||||
@@ -199,11 +200,6 @@ function adminMerchantEdit() {
|
||||
const action = this.merchant.is_active ? 'deactivate' : 'activate';
|
||||
merchantEditLog.info(`Toggle active status: ${action}`);
|
||||
|
||||
if (!confirm(`Are you sure you want to ${action} this merchant?\n\nThis will affect all stores under this merchant.`)) {
|
||||
merchantEditLog.info('Active status toggle cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/merchants/${this.merchantId}/status`;
|
||||
@@ -343,8 +339,8 @@ function adminMerchantEdit() {
|
||||
this.userSearchResults = [];
|
||||
},
|
||||
|
||||
// Delete merchant
|
||||
async deleteMerchant() {
|
||||
// Prompt delete merchant (first step of double confirm)
|
||||
promptDeleteMerchant() {
|
||||
merchantEditLog.info('=== DELETING MERCHANT ===');
|
||||
|
||||
if (this.merchant.store_count > 0) {
|
||||
@@ -352,16 +348,17 @@ function adminMerchantEdit() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm(`Are you sure you want to delete merchant "${this.merchant.name}"?\n\nThis action cannot be undone.`)) {
|
||||
merchantEditLog.info('Merchant deletion cancelled by user');
|
||||
return;
|
||||
}
|
||||
this.showDeleteMerchantModal = true;
|
||||
},
|
||||
|
||||
// Double confirmation for critical action
|
||||
if (!confirm(`FINAL CONFIRMATION: Delete "${this.merchant.name}"?\n\nThis will permanently delete the merchant and all its data.`)) {
|
||||
merchantEditLog.info('Merchant deletion cancelled at final confirmation');
|
||||
return;
|
||||
}
|
||||
// Confirm first step, show final confirmation
|
||||
confirmDeleteMerchantStep() {
|
||||
this.showDeleteMerchantFinalModal = true;
|
||||
},
|
||||
|
||||
// Delete merchant
|
||||
async deleteMerchant() {
|
||||
merchantEditLog.info('=== DELETING MERCHANT (confirmed) ===');
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
|
||||
@@ -16,6 +16,9 @@ function merchantUserDetailPage() {
|
||||
saving: false,
|
||||
error: null,
|
||||
userId: null,
|
||||
showToggleStatusModal: false,
|
||||
showDeleteModal: false,
|
||||
showDeleteFinalModal: false,
|
||||
|
||||
// Initialize
|
||||
async init() {
|
||||
@@ -100,11 +103,6 @@ function merchantUserDetailPage() {
|
||||
const action = this.merchantUser.is_active ? 'deactivate' : 'activate';
|
||||
merchantUserDetailLog.info(`Toggle status: ${action}`);
|
||||
|
||||
if (!confirm(`Are you sure you want to ${action} "${this.merchantUser.full_name || this.merchantUser.username}"?`)) {
|
||||
merchantUserDetailLog.info('Status toggle cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/users/${this.userId}/status`;
|
||||
@@ -126,21 +124,16 @@ function merchantUserDetailPage() {
|
||||
}
|
||||
},
|
||||
|
||||
// Intermediate step for double-confirm delete
|
||||
confirmDeleteStep() {
|
||||
merchantUserDetailLog.info('First delete confirmation accepted, showing final confirmation');
|
||||
this.showDeleteFinalModal = true;
|
||||
},
|
||||
|
||||
// Delete user
|
||||
async deleteUser() {
|
||||
merchantUserDetailLog.info('Delete user requested:', this.userId);
|
||||
|
||||
if (!confirm(`Are you sure you want to delete "${this.merchantUser.full_name || this.merchantUser.username}"?\n\nThis action cannot be undone.`)) {
|
||||
merchantUserDetailLog.info('Delete cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
// Second confirmation for safety
|
||||
if (!confirm(`FINAL CONFIRMATION\n\nAre you absolutely sure you want to delete "${this.merchantUser.full_name || this.merchantUser.username}"?`)) {
|
||||
merchantUserDetailLog.info('Delete cancelled by user (second confirmation)');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/users/${this.userId}`;
|
||||
|
||||
@@ -16,6 +16,11 @@ function merchantUsersPage() {
|
||||
merchantUsers: [],
|
||||
loading: false,
|
||||
error: null,
|
||||
showToggleStatusModal: false,
|
||||
showDeleteModal: false,
|
||||
showDeleteFinalModal: false,
|
||||
userToToggle: null,
|
||||
userToDelete: null,
|
||||
filters: {
|
||||
search: '',
|
||||
is_active: ''
|
||||
@@ -230,11 +235,6 @@ function merchantUsersPage() {
|
||||
const action = user.is_active ? 'deactivate' : 'activate';
|
||||
merchantUsersLog.info(`Toggle status: ${action} for user`, user.username);
|
||||
|
||||
if (!confirm(`Are you sure you want to ${action} "${user.full_name || user.username || user.email}"?`)) {
|
||||
merchantUsersLog.info('Status toggle cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = `/admin/users/${user.id}/status`;
|
||||
window.LogConfig.logApiCall('PUT', url, null, 'request');
|
||||
@@ -254,21 +254,16 @@ function merchantUsersPage() {
|
||||
}
|
||||
},
|
||||
|
||||
// Intermediate step for double-confirm delete
|
||||
confirmDeleteStep() {
|
||||
merchantUsersLog.info('First delete confirmation accepted, showing final confirmation');
|
||||
this.showDeleteFinalModal = true;
|
||||
},
|
||||
|
||||
// Delete user
|
||||
async deleteUser(user) {
|
||||
merchantUsersLog.warn('Delete user requested:', user.username);
|
||||
|
||||
if (!confirm(`Are you sure you want to delete "${user.full_name || user.username || user.email}"?\n\nThis action cannot be undone.`)) {
|
||||
merchantUsersLog.info('Delete cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
// Second confirmation for safety
|
||||
if (!confirm(`FINAL CONFIRMATION\n\nAre you absolutely sure you want to delete "${user.full_name || user.username || user.email}"?`)) {
|
||||
merchantUsersLog.info('Delete cancelled by user (second confirmation)');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = `/admin/users/${user.id}`;
|
||||
window.LogConfig.logApiCall('DELETE', url, null, 'request');
|
||||
|
||||
@@ -26,6 +26,10 @@ function adminMerchants() {
|
||||
loading: false,
|
||||
error: null,
|
||||
|
||||
// Modal state
|
||||
showDeleteMerchantModal: false,
|
||||
merchantToDelete: null,
|
||||
|
||||
// Search and filters
|
||||
filters: {
|
||||
search: '',
|
||||
@@ -192,23 +196,19 @@ function adminMerchants() {
|
||||
window.location.href = `/admin/merchants/${merchantId}/edit`;
|
||||
},
|
||||
|
||||
// Delete merchant
|
||||
async deleteMerchant(merchant) {
|
||||
// Prompt delete merchant modal
|
||||
promptDeleteMerchant(merchant) {
|
||||
if (merchant.store_count > 0) {
|
||||
merchantsLog.warn('Cannot delete merchant with stores');
|
||||
Utils.showToast(`Cannot delete "${merchant.name}" because it has ${merchant.store_count} store(s). Please delete or reassign the stores first.`, 'warning');
|
||||
return;
|
||||
}
|
||||
this.merchantToDelete = merchant;
|
||||
this.showDeleteMerchantModal = true;
|
||||
},
|
||||
|
||||
const confirmed = confirm(
|
||||
`Are you sure you want to delete "${merchant.name}"?\n\nThis action cannot be undone.`
|
||||
);
|
||||
|
||||
if (!confirmed) {
|
||||
merchantsLog.info('Delete cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete merchant
|
||||
async deleteMerchant(merchant) {
|
||||
try {
|
||||
merchantsLog.info('Deleting merchant:', merchant.id);
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ function adminPlatformMenuConfig(platformCode) {
|
||||
error: null,
|
||||
successMessage: null,
|
||||
saving: false,
|
||||
showShowAllModal: false,
|
||||
showHideAllModal: false,
|
||||
|
||||
// Data
|
||||
platform: null,
|
||||
@@ -160,10 +162,6 @@ function adminPlatformMenuConfig(platformCode) {
|
||||
},
|
||||
|
||||
async showAll() {
|
||||
if (!confirm(I18n.t('tenancy.confirmations.show_all_menu_items'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
this.error = null;
|
||||
this.successMessage = null;
|
||||
@@ -186,10 +184,6 @@ function adminPlatformMenuConfig(platformCode) {
|
||||
},
|
||||
|
||||
async resetToDefaults() {
|
||||
if (!confirm(I18n.t('tenancy.confirmations.hide_all_menu_items'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
this.error = null;
|
||||
this.successMessage = null;
|
||||
|
||||
@@ -15,6 +15,8 @@ function adminPlatformModules(platformCode) {
|
||||
error: null,
|
||||
successMessage: null,
|
||||
saving: false,
|
||||
showEnableAllModal: false,
|
||||
showDisableOptionalModal: false,
|
||||
|
||||
// Data
|
||||
platform: null,
|
||||
@@ -176,10 +178,6 @@ function adminPlatformModules(platformCode) {
|
||||
},
|
||||
|
||||
async enableAll() {
|
||||
if (!confirm(I18n.t('tenancy.confirmations.enable_all_modules'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
this.error = null;
|
||||
this.successMessage = null;
|
||||
@@ -207,10 +205,6 @@ function adminPlatformModules(platformCode) {
|
||||
},
|
||||
|
||||
async disableOptional() {
|
||||
if (!confirm(I18n.t('tenancy.confirmations.disable_optional_modules'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
this.error = null;
|
||||
this.successMessage = null;
|
||||
|
||||
@@ -17,6 +17,8 @@ function adminStoreDetail() {
|
||||
loading: false,
|
||||
error: null,
|
||||
storeCode: null,
|
||||
showDeleteStoreModal: false,
|
||||
showDeleteStoreFinalModal: false,
|
||||
|
||||
// Initialize
|
||||
async init() {
|
||||
@@ -143,21 +145,20 @@ function adminStoreDetail() {
|
||||
return 'bg-green-500';
|
||||
},
|
||||
|
||||
// Prompt delete store (first step of double confirm)
|
||||
promptDeleteStore() {
|
||||
detailLog.info('Delete store requested:', this.storeCode);
|
||||
this.showDeleteStoreModal = true;
|
||||
},
|
||||
|
||||
// Confirm first step, show final confirmation
|
||||
confirmDeleteStoreStep() {
|
||||
detailLog.info('First delete confirmation accepted, showing final confirmation');
|
||||
this.showDeleteStoreFinalModal = true;
|
||||
},
|
||||
|
||||
// Delete store
|
||||
async deleteStore() {
|
||||
detailLog.info('Delete store requested:', this.storeCode);
|
||||
|
||||
if (!confirm(`Are you sure you want to delete store "${this.store.name}"?\n\nThis action cannot be undone and will delete:\n- All products\n- All orders\n- All customers\n- All team members`)) {
|
||||
detailLog.info('Delete cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
// Second confirmation for safety
|
||||
if (!confirm(`FINAL CONFIRMATION\n\nType the store code to confirm: ${this.store.store_code}\n\nAre you absolutely sure?`)) {
|
||||
detailLog.info('Delete cancelled by user (second confirmation)');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = `/admin/stores/${this.storeCode}?confirm=true`;
|
||||
window.LogConfig.logApiCall('DELETE', url, null, 'request');
|
||||
@@ -189,4 +190,4 @@ function adminStoreDetail() {
|
||||
};
|
||||
}
|
||||
|
||||
detailLog.info('Store detail module loaded');
|
||||
detailLog.info('Store detail module loaded');
|
||||
|
||||
@@ -18,6 +18,10 @@ function adminStoreEdit() {
|
||||
loadingStore: false,
|
||||
saving: false,
|
||||
storeCode: null,
|
||||
showToggleVerificationModal: false,
|
||||
showToggleActiveModal: false,
|
||||
showDeleteStoreModal: false,
|
||||
showDeleteStoreFinalModal: false,
|
||||
|
||||
// Initialize
|
||||
async init() {
|
||||
@@ -166,11 +170,6 @@ function adminStoreEdit() {
|
||||
const action = this.store.is_verified ? 'unverify' : 'verify';
|
||||
editLog.info(`Toggle verification: ${action}`);
|
||||
|
||||
if (!confirm(`Are you sure you want to ${action} this store?`)) {
|
||||
editLog.info('Verification toggle cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/stores/${this.storeCode}/verification`;
|
||||
@@ -199,11 +198,6 @@ function adminStoreEdit() {
|
||||
const action = this.store.is_active ? 'deactivate' : 'activate';
|
||||
editLog.info(`Toggle active status: ${action}`);
|
||||
|
||||
if (!confirm(`Are you sure you want to ${action} this store?\n\nThis will affect their operations.`)) {
|
||||
editLog.info('Active status toggle cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/stores/${this.storeCode}/status`;
|
||||
@@ -227,22 +221,20 @@ function adminStoreEdit() {
|
||||
}
|
||||
},
|
||||
|
||||
// Prompt delete store (first step of double confirm)
|
||||
promptDeleteStore() {
|
||||
editLog.info('Delete store requested');
|
||||
this.showDeleteStoreModal = true;
|
||||
},
|
||||
|
||||
// Confirm first step, show final confirmation
|
||||
confirmDeleteStoreStep() {
|
||||
editLog.info('First delete confirmation accepted, showing final confirmation');
|
||||
this.showDeleteStoreFinalModal = true;
|
||||
},
|
||||
|
||||
// Delete store
|
||||
async deleteStore() {
|
||||
editLog.info('Delete store requested');
|
||||
|
||||
const storeName = this.store?.name || this.storeCode;
|
||||
if (!confirm(`Are you sure you want to delete "${storeName}"?\n\n⚠️ WARNING: This will permanently delete:\n• All products\n• All orders\n• All customers\n• All team members\n\nThis action cannot be undone!`)) {
|
||||
editLog.info('Delete cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
// Double confirmation for safety
|
||||
if (!confirm(`FINAL CONFIRMATION\n\nType OK to permanently delete "${storeName}" and ALL associated data.`)) {
|
||||
editLog.info('Delete cancelled at final confirmation');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/stores/${this.storeCode}?confirm=true`;
|
||||
@@ -311,4 +303,4 @@ function adminStoreEdit() {
|
||||
};
|
||||
}
|
||||
|
||||
editLog.info('Store edit module loaded');
|
||||
editLog.info('Store edit module loaded');
|
||||
|
||||
@@ -31,6 +31,7 @@ function adminStoreTheme() {
|
||||
loading: true,
|
||||
saving: false,
|
||||
error: null,
|
||||
showResetThemeModal: false,
|
||||
|
||||
// Theme data structure matching StoreTheme model
|
||||
themeData: {
|
||||
@@ -272,10 +273,6 @@ function adminStoreTheme() {
|
||||
},
|
||||
|
||||
async resetTheme() {
|
||||
if (!confirm(I18n.t('tenancy.confirmations.reset_theme'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
themeLog.warn('Resetting theme to default');
|
||||
this.saving = true;
|
||||
|
||||
@@ -332,4 +329,4 @@ function adminStoreTheme() {
|
||||
// MODULE LOADED
|
||||
// ============================================================================
|
||||
|
||||
themeLog.info('Store theme editor module loaded');
|
||||
themeLog.info('Store theme editor module loaded');
|
||||
|
||||
@@ -25,6 +25,8 @@ function adminStores() {
|
||||
},
|
||||
loading: false,
|
||||
error: null,
|
||||
showDeleteStoreModal: false,
|
||||
storeToDelete: null,
|
||||
|
||||
// Search and filters
|
||||
filters: {
|
||||
@@ -283,15 +285,15 @@ function adminStores() {
|
||||
window.location.href = url;
|
||||
},
|
||||
|
||||
// Prompt delete store
|
||||
promptDeleteStore(store) {
|
||||
storesLog.info('Delete store requested:', store.store_code);
|
||||
this.storeToDelete = store;
|
||||
this.showDeleteStoreModal = true;
|
||||
},
|
||||
|
||||
// Delete store
|
||||
async deleteStore(store) {
|
||||
storesLog.info('Delete store requested:', store.store_code);
|
||||
|
||||
if (!confirm(`Are you sure you want to delete store "${store.name}"?\n\nThis action cannot be undone.`)) {
|
||||
storesLog.info('Delete cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = `/admin/stores/${store.store_code}`;
|
||||
window.LogConfig.logApiCall('DELETE', url, null, 'request');
|
||||
@@ -329,4 +331,4 @@ function adminStores() {
|
||||
};
|
||||
}
|
||||
|
||||
storesLog.info('Stores module loaded');
|
||||
storesLog.info('Stores module loaded');
|
||||
|
||||
@@ -16,6 +16,9 @@ function adminUserDetail() {
|
||||
saving: false,
|
||||
error: null,
|
||||
userId: null,
|
||||
showToggleStatusModal: false,
|
||||
showDeleteModal: false,
|
||||
showDeleteFinalModal: false,
|
||||
|
||||
// Initialize
|
||||
async init() {
|
||||
@@ -97,11 +100,6 @@ function adminUserDetail() {
|
||||
const action = this.user.is_active ? 'deactivate' : 'activate';
|
||||
userDetailLog.info(`Toggle status: ${action}`);
|
||||
|
||||
if (!confirm(`Are you sure you want to ${action} ${this.user.username}?`)) {
|
||||
userDetailLog.info('Status toggle cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/users/${this.userId}/status`;
|
||||
@@ -123,6 +121,12 @@ function adminUserDetail() {
|
||||
}
|
||||
},
|
||||
|
||||
// Intermediate step for double-confirm delete
|
||||
confirmDeleteStep() {
|
||||
userDetailLog.info('First delete confirmation accepted, showing final confirmation');
|
||||
this.showDeleteFinalModal = true;
|
||||
},
|
||||
|
||||
// Delete user
|
||||
async deleteUser() {
|
||||
userDetailLog.info('Delete user requested:', this.userId);
|
||||
@@ -132,17 +136,6 @@ function adminUserDetail() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm(`Are you sure you want to delete "${this.user.username}"?\n\nThis action cannot be undone.`)) {
|
||||
userDetailLog.info('Delete cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
// Second confirmation for safety
|
||||
if (!confirm(`FINAL CONFIRMATION\n\nAre you absolutely sure you want to delete "${this.user.username}"?`)) {
|
||||
userDetailLog.info('Delete cancelled by user (second confirmation)');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/users/${this.userId}`;
|
||||
|
||||
@@ -17,6 +17,9 @@ function adminUserEdit() {
|
||||
loadingUser: false,
|
||||
saving: false,
|
||||
userId: null,
|
||||
showToggleStatusModal: false,
|
||||
showDeleteModal: false,
|
||||
showDeleteFinalModal: false,
|
||||
|
||||
// Initialize
|
||||
async init() {
|
||||
@@ -154,11 +157,6 @@ function adminUserEdit() {
|
||||
const action = this.user.is_active ? 'deactivate' : 'activate';
|
||||
userEditLog.info(`Toggle status: ${action}`);
|
||||
|
||||
if (!confirm(`Are you sure you want to ${action} ${this.user.username}?`)) {
|
||||
userEditLog.info('Status toggle cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/users/${this.userId}/status`;
|
||||
@@ -180,6 +178,12 @@ function adminUserEdit() {
|
||||
}
|
||||
},
|
||||
|
||||
// Intermediate step for double-confirm delete
|
||||
confirmDeleteStep() {
|
||||
userEditLog.info('First delete confirmation accepted, showing final confirmation');
|
||||
this.showDeleteFinalModal = true;
|
||||
},
|
||||
|
||||
// Delete user
|
||||
async deleteUser() {
|
||||
userEditLog.info('=== DELETING USER ===');
|
||||
@@ -189,17 +193,6 @@ function adminUserEdit() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm(`Are you sure you want to delete user "${this.user.username}"?\n\nThis action cannot be undone.`)) {
|
||||
userEditLog.info('User deletion cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
// Double confirmation for critical action
|
||||
if (!confirm(`FINAL CONFIRMATION: Delete "${this.user.username}"?\n\nThis will permanently delete the user.`)) {
|
||||
userEditLog.info('User deletion cancelled at final confirmation');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
try {
|
||||
const url = `/admin/users/${this.userId}`;
|
||||
|
||||
@@ -16,6 +16,10 @@ function adminUsers() {
|
||||
users: [],
|
||||
loading: false,
|
||||
error: null,
|
||||
showToggleStatusModal: false,
|
||||
showDeleteModal: false,
|
||||
userToToggle: null,
|
||||
userToDelete: null,
|
||||
filters: {
|
||||
search: '',
|
||||
role: '',
|
||||
@@ -171,15 +175,15 @@ function adminUsers() {
|
||||
// Load statistics
|
||||
async loadStats() {
|
||||
usersLog.info('Loading user statistics...');
|
||||
|
||||
|
||||
try {
|
||||
const url = '/admin/users/stats';
|
||||
window.LogConfig.logApiCall('GET', url, null, 'request');
|
||||
|
||||
|
||||
const response = await apiClient.get(url); // ✅ Fixed: lowercase apiClient
|
||||
|
||||
|
||||
window.LogConfig.logApiCall('GET', url, response, 'response');
|
||||
|
||||
|
||||
if (response) {
|
||||
this.stats = response;
|
||||
usersLog.debug('Stats loaded:', this.stats);
|
||||
@@ -242,23 +246,18 @@ function adminUsers() {
|
||||
async toggleUserStatus(user) {
|
||||
const action = user.is_active ? 'deactivate' : 'activate';
|
||||
usersLog.info(`Toggle user status: ${action}`, user.username);
|
||||
|
||||
if (!confirm(`Are you sure you want to ${action} ${user.username}?`)) {
|
||||
usersLog.info('Status toggle cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = `/admin/users/${user.id}/status`;
|
||||
window.LogConfig.logApiCall('PUT', url, { is_active: !user.is_active }, 'request');
|
||||
|
||||
|
||||
await apiClient.put(url, { // ✅ Fixed: lowercase apiClient
|
||||
is_active: !user.is_active
|
||||
});
|
||||
|
||||
|
||||
Utils.showToast(`User ${action}d successfully`, 'success');
|
||||
usersLog.info(`User ${action}d successfully`);
|
||||
|
||||
|
||||
await this.loadUsers();
|
||||
await this.loadStats();
|
||||
} catch (error) {
|
||||
@@ -269,21 +268,16 @@ function adminUsers() {
|
||||
|
||||
async deleteUser(user) {
|
||||
usersLog.warn('Delete user requested:', user.username);
|
||||
|
||||
if (!confirm(`Are you sure you want to delete ${user.username}? This action cannot be undone.`)) {
|
||||
usersLog.info('Delete cancelled by user');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = `/admin/users/${user.id}`;
|
||||
window.LogConfig.logApiCall('DELETE', url, null, 'request');
|
||||
|
||||
|
||||
await apiClient.delete(url); // ✅ Fixed: lowercase apiClient
|
||||
|
||||
|
||||
Utils.showToast(I18n.t('tenancy.messages.user_deleted_successfully'), 'success');
|
||||
usersLog.info('User deleted successfully');
|
||||
|
||||
|
||||
await this.loadUsers();
|
||||
await this.loadStats();
|
||||
} catch (error) {
|
||||
@@ -299,4 +293,4 @@ function adminUsers() {
|
||||
};
|
||||
}
|
||||
|
||||
usersLog.info('Users module loaded');
|
||||
usersLog.info('Users module loaded');
|
||||
|
||||
Reference in New Issue
Block a user