oc-front/lib/core/services/perms_service.dart
2024-11-08 13:59:22 +01:00

56 lines
1.7 KiB
Dart

enum Perms {
SEARCH_INTERNAL,// ignore: constant_identifier_names
SEARCH_EXTERNAL, // ignore: constant_identifier_names
WORKSPACE_SHARE,// ignore: constant_identifier_names
WORKFLOW_CREATE, // ignore: constant_identifier_names
WORKFLOW_EDIT, // ignore: constant_identifier_names
WORKFLOW_DELETE, // ignore: constant_identifier_names
WORKFLOW_BOOKING, // ignore: constant_identifier_names
WORKFLOW_SHARE, // ignore: constant_identifier_names
COLLABORATIVE_AREA_CREATE, // ignore: constant_identifier_names
COLLABORATIVE_AREA_EDIT, // ignore: constant_identifier_names
COLLABORATIVE_AREA_DELETE, // ignore: constant_identifier_names
}
Map<Perms, String> perms = {
Perms.SEARCH_INTERNAL: 'Search Internal',
Perms.SEARCH_EXTERNAL: 'Search External',
Perms.WORKSPACE_SHARE: 'Workspace Share',
Perms.WORKFLOW_CREATE: 'Workflow Create',
Perms.WORKFLOW_EDIT: 'Workflow Edit',
Perms.WORKFLOW_DELETE: 'Workflow Delete',
Perms.WORKFLOW_BOOKING: 'Workflow Booking',
Perms.WORKFLOW_SHARE: 'Workflow Share',
};
class PermsService {
static const Map<Perms, bool> _perms = {
Perms.SEARCH_INTERNAL: true,
Perms.SEARCH_EXTERNAL: true,
Perms.WORKSPACE_SHARE: true,
Perms.WORKFLOW_CREATE: true,
Perms.WORKFLOW_EDIT: true,
Perms.WORKFLOW_DELETE: true,
Perms.WORKFLOW_BOOKING: true,
Perms.WORKFLOW_SHARE: true,
Perms.COLLABORATIVE_AREA_CREATE: true,
Perms.COLLABORATIVE_AREA_EDIT: false,
Perms.COLLABORATIVE_AREA_DELETE: false,
};
static final PermsService _instance = PermsService._internal();
factory PermsService() => _instance;
PermsService._internal();
static bool getPerm(Perms perm) {
return _perms[perm] ?? false;
}
static void setPerm(Perms perm, bool value) {
_perms[perm] = value;
}
}