Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
addb06a61a |
No files matched your search
+3
-5
@@ -6,7 +6,6 @@ import 'package:flux/core/theme/theme.dart';
|
||||
import 'package:flux/features/home/dashboard_daily_ricontatti/blocs/dashboard_daily_ricontatti_cubit.dart';
|
||||
import 'package:flux/features/home/dashboard_daily_ricontatti/blocs/dashboard_daily_ricontatti_state.dart';
|
||||
import 'package:flux/features/home/dashboard_daily_ricontatti/models/staff_daily_ricontatti_summary.dart';
|
||||
import 'package:flux/features/master_data/staff/models/staff_member_model.dart';
|
||||
import 'package:flux/features/operations/models/operation_type.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
@@ -16,12 +15,11 @@ class DashboardDailyRicontattiCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Visibile solo ai manager o admin
|
||||
// Visibile a chi ha qualifica Manager o Titolare (o Admin di sistema)
|
||||
final staff = context.watch<SessionCubit>().state.currentStaffMember;
|
||||
final isManager = staff?.systemRole == SystemRole.manager ||
|
||||
staff?.systemRole == SystemRole.admin;
|
||||
final canView = staff?.canViewRicontattiFocus ?? false;
|
||||
|
||||
if (!isManager) {
|
||||
if (!canView) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
|
||||
@@ -77,15 +77,35 @@ class StaffMemberModel extends Equatable {
|
||||
);
|
||||
}
|
||||
|
||||
/// Esclude da ricontatti e target operativi i profili non addetti (manager e tester) o disattivati
|
||||
bool get isExcludedFromRicontattiFocus {
|
||||
if (!isActive) return true;
|
||||
/// Indica se il collaboratore ha la qualifica di Manager o Titolare (tramite jobTitle)
|
||||
bool get isManagerOrTitolare {
|
||||
final title = (jobTitle ?? '').trim().toLowerCase();
|
||||
if (title.contains('manager') || title.contains('tester')) return true;
|
||||
if (systemRole == SystemRole.manager || systemRole == SystemRole.admin) return true;
|
||||
return title.contains('manager') || title.contains('titolare');
|
||||
}
|
||||
|
||||
/// Discriminante per vedere o meno il Focus Ricontatti: Manager e Titolare (o Admin di sistema)
|
||||
bool get canViewRicontattiFocus {
|
||||
if (isManagerOrTitolare) return true;
|
||||
if (systemRole == SystemRole.admin) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Discriminante per non comparire tra gli utenti "controllati" (addetti):
|
||||
/// Manager, Titolari, Tester o collaboratori disattivati
|
||||
bool get isExcludedFromControlledStaff {
|
||||
if (!isActive) return true;
|
||||
final title = (jobTitle ?? '').trim().toLowerCase();
|
||||
if (title.contains('manager') ||
|
||||
title.contains('titolare') ||
|
||||
title.contains('tester')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Alias retrocompatibile
|
||||
bool get isExcludedFromRicontattiFocus => isExcludedFromControlledStaff;
|
||||
|
||||
factory StaffMemberModel.empty() {
|
||||
return const StaffMemberModel(
|
||||
companyId: '',
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
name: flux
|
||||
description: "Gestione attività negozio di telefonia"
|
||||
publish_to: 'none'
|
||||
version: 2.1.2+76
|
||||
version: 2.1.3+77
|
||||
|
||||
environment:
|
||||
sdk: ^3.11.3
|
||||
|
||||
+33
-24
@@ -123,45 +123,54 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('StaffMemberModel.isExcludedFromRicontattiFocus', () {
|
||||
test('excludes manager and tester by qualification jobTitle', () {
|
||||
group('StaffMemberModel jobTitle discriminants', () {
|
||||
test('canViewRicontattiFocus identifies Manager and Titolare by jobTitle', () {
|
||||
final manager = StaffMemberModel.empty().copyWith(jobTitle: 'Manager');
|
||||
final titolare = StaffMemberModel.empty().copyWith(jobTitle: 'Titolare');
|
||||
final storeManager = StaffMemberModel.empty().copyWith(jobTitle: 'Store Manager');
|
||||
final tester = StaffMemberModel.empty().copyWith(jobTitle: 'Tester');
|
||||
final betaTester = StaffMemberModel.empty().copyWith(jobTitle: 'BETA TESTER');
|
||||
|
||||
expect(manager.isExcludedFromRicontattiFocus, isTrue);
|
||||
expect(storeManager.isExcludedFromRicontattiFocus, isTrue);
|
||||
expect(tester.isExcludedFromRicontattiFocus, isTrue);
|
||||
expect(betaTester.isExcludedFromRicontattiFocus, isTrue);
|
||||
});
|
||||
|
||||
test('excludes manager by systemRole and inactive members', () {
|
||||
final roleManager = StaffMemberModel.empty().copyWith(
|
||||
jobTitle: 'Addetto',
|
||||
systemRole: SystemRole.manager,
|
||||
final addetto = StaffMemberModel.empty().copyWith(
|
||||
jobTitle: 'Addetto Vendite',
|
||||
systemRole: SystemRole.user,
|
||||
);
|
||||
final roleAdmin = StaffMemberModel.empty().copyWith(
|
||||
jobTitle: 'Addetto',
|
||||
final admin = StaffMemberModel.empty().copyWith(
|
||||
jobTitle: 'Tecnico',
|
||||
systemRole: SystemRole.admin,
|
||||
);
|
||||
|
||||
expect(manager.canViewRicontattiFocus, isTrue);
|
||||
expect(titolare.canViewRicontattiFocus, isTrue);
|
||||
expect(storeManager.canViewRicontattiFocus, isTrue);
|
||||
expect(addetto.canViewRicontattiFocus, isFalse);
|
||||
expect(admin.canViewRicontattiFocus, isTrue);
|
||||
});
|
||||
|
||||
test('excludes Manager, Titolare, Tester from controlled staff', () {
|
||||
final manager = StaffMemberModel.empty().copyWith(jobTitle: 'Manager');
|
||||
final titolare = StaffMemberModel.empty().copyWith(jobTitle: 'Titolare');
|
||||
final tester = StaffMemberModel.empty().copyWith(jobTitle: 'Tester');
|
||||
final betaTester = StaffMemberModel.empty().copyWith(jobTitle: 'BETA TESTER');
|
||||
final inactive = StaffMemberModel.empty().copyWith(
|
||||
jobTitle: 'Addetto',
|
||||
isActive: false,
|
||||
);
|
||||
|
||||
expect(roleManager.isExcludedFromRicontattiFocus, isTrue);
|
||||
expect(roleAdmin.isExcludedFromRicontattiFocus, isTrue);
|
||||
expect(inactive.isExcludedFromRicontattiFocus, isTrue);
|
||||
expect(manager.isExcludedFromControlledStaff, isTrue);
|
||||
expect(titolare.isExcludedFromControlledStaff, isTrue);
|
||||
expect(tester.isExcludedFromControlledStaff, isTrue);
|
||||
expect(betaTester.isExcludedFromControlledStaff, isTrue);
|
||||
expect(inactive.isExcludedFromControlledStaff, isTrue);
|
||||
});
|
||||
|
||||
test('includes standard active addetti', () {
|
||||
final addetto = StaffMemberModel.empty().copyWith(
|
||||
test('addetto with systemRole manager is still controlled staff', () {
|
||||
// systemRole indica permessi app, jobTitle indica il ruolo operativo in negozio
|
||||
final addettoWithAdminPerms = StaffMemberModel.empty().copyWith(
|
||||
jobTitle: 'Addetto Vendite',
|
||||
systemRole: SystemRole.user,
|
||||
systemRole: SystemRole.manager,
|
||||
isActive: true,
|
||||
);
|
||||
expect(addetto.isExcludedFromRicontattiFocus, isFalse);
|
||||
expect(addettoWithAdminPerms.isExcludedFromControlledStaff, isFalse);
|
||||
expect(addettoWithAdminPerms.isManagerOrTitolare, isFalse);
|
||||
expect(addettoWithAdminPerms.canViewRicontattiFocus, isFalse);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user