feat: make admin user edit page fields editable (username, email, name)
Some checks failed
Some checks failed
The admin-user-edit page had display-only fields for username, email, first name, and last name. Convert to editable form inputs with: - Dirty detection (unsaved changes indicator) - Only sends changed fields in PUT payload - Validation error display per field - Save button disabled when no changes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -71,39 +71,76 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Admin Info Card -->
|
||||
<!-- Admin Info Card (Editable) -->
|
||||
<div class="px-4 py-3 mb-6 bg-white rounded-lg shadow-md dark:bg-gray-800">
|
||||
<h3 class="mb-4 text-lg font-semibold text-gray-700 dark:text-gray-200">
|
||||
Admin Information
|
||||
</h3>
|
||||
<div class="grid gap-6 md:grid-cols-2">
|
||||
<!-- Left Column -->
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<span class="text-sm text-gray-600 dark:text-gray-400">User ID</span>
|
||||
<p class="text-gray-800 dark:text-gray-200 font-medium" x-text="adminUser?.id"></p>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-sm text-gray-600 dark:text-gray-400">Username</span>
|
||||
<p class="text-gray-800 dark:text-gray-200 font-medium" x-text="adminUser?.username"></p>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-sm text-gray-600 dark:text-gray-400">Email</span>
|
||||
<p class="text-gray-800 dark:text-gray-200 font-medium" x-text="adminUser?.email"></p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Right Column -->
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<span class="text-sm text-gray-600 dark:text-gray-400">First Name</span>
|
||||
<p class="text-gray-800 dark:text-gray-200 font-medium" x-text="adminUser?.first_name || '-'"></p>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-sm text-gray-600 dark:text-gray-400">Last Name</span>
|
||||
<p class="text-gray-800 dark:text-gray-200 font-medium" x-text="adminUser?.last_name || '-'"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h3 class="text-lg font-semibold text-gray-700 dark:text-gray-200">
|
||||
Admin Information
|
||||
</h3>
|
||||
<span class="text-xs text-gray-500 dark:text-gray-400" x-text="'ID: ' + adminUser?.id"></span>
|
||||
</div>
|
||||
<form @submit.prevent="saveProfile()">
|
||||
<div class="grid gap-6 md:grid-cols-2">
|
||||
<!-- Left Column -->
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Username</label>
|
||||
<input
|
||||
type="text"
|
||||
x-model="editForm.username"
|
||||
class="block w-full text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple form-input"
|
||||
required
|
||||
minlength="3"
|
||||
>
|
||||
<p x-show="errors.username" x-text="errors.username" class="mt-1 text-xs text-red-600 dark:text-red-400"></p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Email</label>
|
||||
<input
|
||||
type="email"
|
||||
x-model="editForm.email"
|
||||
class="block w-full text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple form-input"
|
||||
required
|
||||
>
|
||||
<p x-show="errors.email" x-text="errors.email" class="mt-1 text-xs text-red-600 dark:text-red-400"></p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Right Column -->
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">First Name</label>
|
||||
<input
|
||||
type="text"
|
||||
x-model="editForm.first_name"
|
||||
class="block w-full text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple form-input"
|
||||
placeholder="First name"
|
||||
>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Last Name</label>
|
||||
<input
|
||||
type="text"
|
||||
x-model="editForm.last_name"
|
||||
class="block w-full text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple form-input"
|
||||
placeholder="Last name"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center justify-end mt-6 gap-3">
|
||||
<span x-show="profileDirty" class="text-xs text-orange-600 dark:text-orange-400">Unsaved changes</span>
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="saving || !profileDirty"
|
||||
class="flex items-center px-4 py-2 text-sm font-medium text-white bg-purple-600 rounded-lg hover:bg-purple-700 focus:outline-none disabled:opacity-50 transition-colors">
|
||||
<span x-show="!saving">Save Changes</span>
|
||||
<span x-show="saving" class="flex items-center">
|
||||
<span x-html="$icon('spinner', 'w-4 h-4 mr-2')"></span>
|
||||
Saving...
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Platform Assignments Card (Only for Platform Admins) -->
|
||||
|
||||
Reference in New Issue
Block a user