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:
2026-01-24 21:36:31 +01:00
parent 011744966b
commit a0e6833a75
2 changed files with 28 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
{% extends "admin/base.html" %} {% extends "admin/base.html" %}
{% from 'shared/macros/alerts.html' import loading_state %} {% from 'shared/macros/alerts.html' import loading_state %}
{% from 'shared/macros/headers.html' import edit_page_header %} {% from 'shared/macros/headers.html' import edit_page_header %}
{% from 'shared/macros/modals.html' import confirm_modal %}
{% block title %}Edit Admin User{% endblock %} {% block title %}Edit Admin User{% endblock %}
@@ -252,6 +253,18 @@
</div> </div>
</div> </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 %} {% endblock %}
{% block extra_scripts %} {% block extra_scripts %}

View File

@@ -23,6 +23,10 @@ function adminUserEditPage() {
availablePlatforms: [], availablePlatforms: [],
selectedPlatformId: null, selectedPlatformId: null,
// Confirmation modal state
showRemovePlatformModal: false,
platformToRemove: null,
// Initialize // Initialize
async init() { async init() {
adminUserEditLog.info('=== ADMIN USER EDIT PAGE INITIALIZING ==='); adminUserEditLog.info('=== ADMIN USER EDIT PAGE INITIALIZING ===');
@@ -237,22 +241,23 @@ function adminUserEditPage() {
} }
}, },
// Remove platform from admin // Show confirmation modal for platform removal
async removePlatform(platformId) { removePlatform(platformId) {
const platform = this.adminUser.platforms.find(p => p.id === platformId);
const platformName = platform ? platform.name : platformId;
// Validate: platform admin must have at least one platform // Validate: platform admin must have at least one platform
if (this.adminUser.platforms.length <= 1) { if (this.adminUser.platforms.length <= 1) {
Utils.showToast('Platform admin must be assigned to at least one platform', 'error'); Utils.showToast('Platform admin must be assigned to at least one platform', 'error');
return; return;
} }
if (!confirm(`Are you sure you want to remove "${platformName}" from this admin?`)) { this.platformToRemove = this.adminUser.platforms.find(p => p.id === platformId);
adminUserEditLog.info('Platform removal cancelled by user'); this.showRemovePlatformModal = true;
return; },
}
// Confirm and execute platform removal
async confirmRemovePlatform() {
if (!this.platformToRemove) return;
const platformId = this.platformToRemove.id;
adminUserEditLog.info('Removing platform:', platformId); adminUserEditLog.info('Removing platform:', platformId);
this.saving = true; this.saving = true;
@@ -275,6 +280,7 @@ function adminUserEditPage() {
Utils.showToast(error.message || 'Failed to remove platform', 'error'); Utils.showToast(error.message || 'Failed to remove platform', 'error');
} finally { } finally {
this.saving = false; this.saving = false;
this.platformToRemove = null;
} }
}, },