allow to edit username (#4559)
This commit is contained in:
@@ -309,15 +309,18 @@ final class ProfileController extends AbstractController
|
||||
|
||||
private function createEditForm(User $user): FormInterface
|
||||
{
|
||||
$currentUser = $this->getUser();
|
||||
|
||||
return $this->createForm(
|
||||
UserEditType::class,
|
||||
$user,
|
||||
[
|
||||
'action' => $this->generateUrl('user_profile_edit', ['username' => $user->getUserIdentifier()]),
|
||||
'method' => 'POST',
|
||||
'include_active_flag' => ($user->getId() !== $this->getUser()->getId()),
|
||||
'include_active_flag' => $user !== $currentUser,
|
||||
'include_preferences' => true,
|
||||
'include_supervisor' => $this->isGranted('supervisor', $user),
|
||||
'include_username' => $currentUser->isSuperAdmin() && $currentUser !== $user,
|
||||
'include_password_reset' => $this->isGranted('password', $user),
|
||||
]
|
||||
);
|
||||
|
||||
@@ -42,6 +42,14 @@ class UserEditType extends AbstractType
|
||||
$user = $options['data'];
|
||||
}
|
||||
|
||||
if ($options['include_username']) {
|
||||
$builder->add('username', TextType::class, [
|
||||
'label' => 'user_identifier',
|
||||
'help' => 'user_identifier.help',
|
||||
'required' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
$builder->add('alias', TextType::class, [
|
||||
'label' => 'alias',
|
||||
'required' => false,
|
||||
@@ -117,6 +125,7 @@ class UserEditType extends AbstractType
|
||||
'include_active_flag' => true,
|
||||
'include_preferences' => true,
|
||||
'include_supervisor' => true,
|
||||
'include_username' => false,
|
||||
'include_password_reset' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<div class="col-auto" data-toggle="tooltip" title="{{ 'id'|trans }}: {{ user.id }}">
|
||||
{{ widgets.user_avatar(user, false, 'avatar-lg') }}
|
||||
</div>
|
||||
<div class="col" style="min-width: 100px">
|
||||
<div class="col" style="min-width: 100px"{% block user_title_box_attributes %}{% endblock %}>
|
||||
<h4 class="card-title m-0">{{ widgets.username(user) }}</h4>
|
||||
{% if user.title is not empty %}
|
||||
<div class="text-body-secondary">
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
{% extends 'user/form.html.twig' %}
|
||||
|
||||
{% block user_title_box_attributes %}
|
||||
{% if form.username is defined %}
|
||||
ondblclick="document.getElementById('user_edit_username_hidden').style.display = 'flex'"
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block form_content %}
|
||||
|
||||
{% form_theme form 'form/horizontal.html.twig' %}
|
||||
@@ -9,6 +15,13 @@
|
||||
<fieldset class="form-fieldset form-fieldset-light">
|
||||
{{ form_row(form.alias) }}
|
||||
{{ form_row(form.email) }}
|
||||
{% if form.username is defined %}
|
||||
{% set styleUsername = 'display:none' %}
|
||||
{% if form.username.vars.errors|length > 0 %}
|
||||
{% set styleUsername = '' %}
|
||||
{% endif %}
|
||||
{{ form_row(form.username, {row_attr: {id: 'user_edit_username_hidden', style: styleUsername}}) }}
|
||||
{% endif %}
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="form-fieldset form-fieldset-light">
|
||||
|
||||
@@ -1693,6 +1693,14 @@
|
||||
<source>unpaid_vacation</source>
|
||||
<target>Unbezahlter Urlaub</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="q59lI2y" resname="user_identifier">
|
||||
<source>user_identifier</source>
|
||||
<target>Benutzer ID</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="uqv2Lrv" resname="user_identifier.help">
|
||||
<source>user_identifier.help</source>
|
||||
<target>Die eindeutige Benutzerkennung wird zur Authentifizierung und bei Exporten verwendet</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
||||
@@ -1693,6 +1693,14 @@
|
||||
<source>unpaid_vacation</source>
|
||||
<target>Unpaid holidays</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="q59lI2y" resname="user_identifier">
|
||||
<source>user_identifier</source>
|
||||
<target>User ID</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="uqv2Lrv" resname="user_identifier.help">
|
||||
<source>user_identifier.help</source>
|
||||
<target>The unique user identifier is used for authentication and in exports</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
||||
Reference in New Issue
Block a user