Added placeholder for lastName and role addition functionality
This commit is contained in:
@@ -30,6 +30,7 @@ class InvitationsProvider extends GenericProvider<Invitation> {
|
||||
required String roleRef,
|
||||
required String inviterRef,
|
||||
String name = '',
|
||||
String lastName = '',
|
||||
String comment = '',
|
||||
DateTime? expiresAt,
|
||||
}) async {
|
||||
@@ -39,6 +40,7 @@ class InvitationsProvider extends GenericProvider<Invitation> {
|
||||
inviterRef: inviterRef,
|
||||
email: email,
|
||||
name: name,
|
||||
lastName: lastName,
|
||||
comment: comment,
|
||||
expiresAt: expiresAt,
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import 'package:pshared/api/requests/change_role.dart';
|
||||
import 'package:pshared/models/describable.dart';
|
||||
import 'package:pshared/models/permissions/access.dart';
|
||||
import 'package:pshared/models/permissions/action.dart' as perm;
|
||||
import 'package:pshared/models/permissions/data/permission.dart';
|
||||
@@ -101,6 +102,32 @@ class PermissionsProvider extends ChangeNotifier {
|
||||
return _performServiceCall(() => PermissionsService.deleteRoleDescription(descRef));
|
||||
}
|
||||
|
||||
Future<RoleDescription?> createRoleDescription({
|
||||
required String name,
|
||||
String? description,
|
||||
}) async {
|
||||
if (!_organizations.isOrganizationSet) {
|
||||
throw StateError('Organization is not set');
|
||||
}
|
||||
final normalizedName = name.trim();
|
||||
final normalizedDescription = description?.trim();
|
||||
final roleDescription = RoleDescription.build(
|
||||
organizationRef: _organizations.current.id,
|
||||
roleDescription: newDescribable(name: normalizedName, description: normalizedDescription),
|
||||
);
|
||||
|
||||
await _performServiceCall(() => PermissionsService.createRoleDescription(roleDescription));
|
||||
final matches = roleDescriptions.where(
|
||||
(role) =>
|
||||
role.organizationRef == _organizations.current.id &&
|
||||
role.name == normalizedName &&
|
||||
(role.description ?? '') == (normalizedDescription ?? ''),
|
||||
).toList()
|
||||
..sort((a, b) => b.createdAt.compareTo(a.createdAt));
|
||||
|
||||
return matches.isEmpty ? null : matches.first;
|
||||
}
|
||||
|
||||
Future<UserAccess?> createPermissions(List<Policy> policies) {
|
||||
return _performServiceCall(() => PermissionsService.createPolicies(policies));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user