feat(#161): admin peut créer gestionnaire et administrateur.
Assouplit POST /gestionnaires, PATCH /gestionnaires/:id et POST /users/admin (+ check createAdmin) pour ADMINISTRATEUR. Masque « Ajouter » staff sur le dashboard gestionnaire. Tests droits Roles + createAdmin. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -62,7 +62,10 @@ class _GestionnaireDashboardScreenState extends State<GestionnaireDashboardScree
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: UserManagementPanel(showAdministrateursTab: false),
|
||||
child: UserManagementPanel(
|
||||
showAdministrateursTab: false,
|
||||
allowStaffAccountCreation: false,
|
||||
),
|
||||
),
|
||||
const AppFooter(),
|
||||
],
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/// Création comptes staff (gestionnaire / admin) — ticket #161.
|
||||
bool canCreateStaffAccounts(String? role) {
|
||||
final r = (role ?? '').trim().toLowerCase();
|
||||
return r == 'administrateur' || r == 'super_admin';
|
||||
}
|
||||
|
||||
/// Droits d’affichage poubelle — tickets #154 / #160.
|
||||
bool canDeleteMetier(String? role) {
|
||||
final r = (role ?? '').trim().toLowerCase();
|
||||
|
||||
@@ -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