fix: use confirm_modal macro instead of browser confirm for platform removal
Replaced the native browser confirm() dialog with the styled confirm_modal macro for a consistent UI experience when removing platform assignments from admin users. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% from 'shared/macros/alerts.html' import loading_state %}
|
||||
{% from 'shared/macros/headers.html' import edit_page_header %}
|
||||
{% from 'shared/macros/modals.html' import confirm_modal %}
|
||||
|
||||
{% block title %}Edit Admin User{% endblock %}
|
||||
|
||||
@@ -252,6 +253,18 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Remove Platform Confirmation Modal -->
|
||||
{{ confirm_modal(
|
||||
'removePlatformModal',
|
||||
'Remove Platform',
|
||||
'Are you sure you want to remove this platform from this admin?',
|
||||
'confirmRemovePlatform()',
|
||||
'showRemovePlatformModal',
|
||||
'Remove',
|
||||
'Cancel',
|
||||
'warning'
|
||||
) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
|
||||
@@ -23,6 +23,10 @@ function adminUserEditPage() {
|
||||
availablePlatforms: [],
|
||||
selectedPlatformId: null,
|
||||
|
||||
// Confirmation modal state
|
||||
showRemovePlatformModal: false,
|
||||
platformToRemove: null,
|
||||
|
||||
// Initialize
|
||||
async init() {
|
||||
adminUserEditLog.info('=== ADMIN USER EDIT PAGE INITIALIZING ===');
|
||||
@@ -237,22 +241,23 @@ function adminUserEditPage() {
|
||||
}
|
||||
},
|
||||
|
||||
// Remove platform from admin
|
||||
async removePlatform(platformId) {
|
||||
const platform = this.adminUser.platforms.find(p => p.id === platformId);
|
||||
const platformName = platform ? platform.name : platformId;
|
||||
|
||||
// Show confirmation modal for platform removal
|
||||
removePlatform(platformId) {
|
||||
// Validate: platform admin must have at least one platform
|
||||
if (this.adminUser.platforms.length <= 1) {
|
||||
Utils.showToast('Platform admin must be assigned to at least one platform', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm(`Are you sure you want to remove "${platformName}" from this admin?`)) {
|
||||
adminUserEditLog.info('Platform removal cancelled by user');
|
||||
return;
|
||||
}
|
||||
this.platformToRemove = this.adminUser.platforms.find(p => p.id === platformId);
|
||||
this.showRemovePlatformModal = true;
|
||||
},
|
||||
|
||||
// Confirm and execute platform removal
|
||||
async confirmRemovePlatform() {
|
||||
if (!this.platformToRemove) return;
|
||||
|
||||
const platformId = this.platformToRemove.id;
|
||||
adminUserEditLog.info('Removing platform:', platformId);
|
||||
this.saving = true;
|
||||
|
||||
@@ -275,6 +280,7 @@ function adminUserEditPage() {
|
||||
Utils.showToast(error.message || 'Failed to remove platform', 'error');
|
||||
} finally {
|
||||
this.saving = false;
|
||||
this.platformToRemove = null;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user