feat(#161): admin peut créer gestionnaire et administrateur (squash develop).
Ouvre POST/PATCH /gestionnaires et POST /users/admin aux administrateurs (en plus du super_admin). Garde-fou front : pas de création staff sur le dashboard gestionnaire.
This commit is contained in:
@@ -15,9 +15,13 @@ class UserManagementPanel extends StatefulWidget {
|
||||
/// Afficher l'onglet Administrateurs (sinon sans Administrateurs).
|
||||
final bool showAdministrateursTab;
|
||||
|
||||
/// Création gestionnaire / admin (#161). False pour le dashboard gestionnaire.
|
||||
final bool allowStaffAccountCreation;
|
||||
|
||||
const UserManagementPanel({
|
||||
super.key,
|
||||
this.showAdministrateursTab = true,
|
||||
this.allowStaffAccountCreation = true,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -86,6 +90,15 @@ class _UserManagementPanelState extends State<UserManagementPanel> {
|
||||
|
||||
bool get _isDossiersTab => _subIndex == 0;
|
||||
|
||||
bool get _isStaffAccountsTab =>
|
||||
_subIndex == 4 || (widget.showAdministrateursTab && _subIndex == 5);
|
||||
|
||||
bool get _canShowAddButton {
|
||||
if (_isDossiersTab) return false;
|
||||
if (_isStaffAccountsTab && !widget.allowStaffAccountCreation) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
String _searchHintForTab() {
|
||||
switch (_subIndex) {
|
||||
case 0:
|
||||
@@ -293,7 +306,8 @@ class _UserManagementPanelState extends State<UserManagementPanel> {
|
||||
searchTooltip: _searchTooltipForTab(),
|
||||
filterControl: _subBarFilterControl(),
|
||||
// Pas de « Créer » sur l’onglet Dossiers (#153).
|
||||
onAddPressed: _isDossiersTab ? null : _handleAddPressed,
|
||||
// Pas de création staff pour le dashboard gestionnaire (#161).
|
||||
onAddPressed: _canShowAddButton ? _handleAddPressed : null,
|
||||
addLabel: 'Ajouter',
|
||||
subTabCount: labels.length,
|
||||
tabLabels: labels,
|
||||
@@ -305,6 +319,9 @@ class _UserManagementPanelState extends State<UserManagementPanel> {
|
||||
|
||||
Future<void> _handleAddPressed() async {
|
||||
// 1 Parents, 2 Enfants, 3 AM, 4 Gestionnaires, 5 Admin
|
||||
if (_isStaffAccountsTab && !widget.allowStaffAccountCreation) {
|
||||
return;
|
||||
}
|
||||
if (_subIndex == 1) {
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
|
||||
Reference in New Issue
Block a user