Commit graph

354 commits

Author SHA1 Message Date
3e8f29bf31 fix: add actor and domain parameters to user count functions in Show
Add actor and domain parameters to recalculate_user_count and
load_user_count to ensure consistent authorization. Clarify that
load_user_count is for initial display while recalculate_user_count
is for fresh count before deletion.
2026-01-08 14:09:28 +01:00
266df8a8ad fix: add actor and domain parameters to user count functions
Add actor parameter to load_user_counts and recalculate_user_count
in Index LiveView to ensure consistent authorization and policy
enforcement. Also add domain parameter for clarity.
2026-01-08 14:09:27 +01:00
c27b903018
refactor: replace cond with if in handle_delete_role functions
All checks were successful
continuous-integration/drone/push Build is passing
2026-01-08 13:56:08 +01:00
4f371352e2 refactor: extract ensure_user_role_loaded into shared on_mount hook
Move duplicate ensure_user_role_loaded logic into MvWeb.LiveHelpers
on_mount hook to eliminate code duplication across RoleLive modules
and centralize security-related user role loading.
2026-01-08 13:50:33 +01:00
2c36621259 fix: eliminate duplicate user_count queries in delete handlers
Calculate user_count once and reuse the value instead of calling
recalculate_user_count twice, reducing unnecessary database queries.
2026-01-08 13:50:28 +01:00
f4b0d1c9a8 fix: add actor parameter to Authorization.get_role in Index
Ensure consistent authorization by passing actor parameter to
get_role call, matching the pattern used in Show LiveView.
2026-01-08 13:50:26 +01:00
fe8b4a65dd
fix: use reraise instead of raise in rescue blocks
Replace raise with reraise to preserve the original stacktrace when
re-raising exceptions in rescue blocks, improving error debugging.
2026-01-08 13:30:36 +01:00
fbc962ce94
refactor: reduce nesting depth in RoleLive handle_event functions 2026-01-08 13:30:20 +01:00
8afccf1dd0
feat: prevent deletion of roles with assigned users
All checks were successful
continuous-integration/drone/push Build is passing
2026-01-08 12:06:15 +01:00
1dd7c0eaa0 fix: improve contrast for 'No description' text to meet WCAG 2 AA
All checks were successful
continuous-integration/drone/push Build is passing
Change text-base-content/50 to text-base-content/70 for better
accessibility contrast ratio in role index and show pages
2026-01-08 12:00:38 +01:00
d092fea6de feat: convert Settings to dropdown menu with sub-items
- Convert Settings menu item to dropdown (similar to Contributions)
- Add Global Settings and Roles as sub-items
- Update German translations: 'Global Settings' and 'Roles'
2026-01-08 11:42:30 +01:00
b65b5a376b feat: add user count display for each role
- Add Users column showing number of users assigned to each role
- Load user counts efficiently in single query to avoid N+1
- Similar implementation to membership fee types member count
2026-01-08 11:42:29 +01:00
303b81d37d refactor: reduce nesting depth in RoleLive.Index.mount
Extract role loading logic into separate private functions to fix Credo warning about nested function body.
2026-01-06 23:57:57 +01:00
a5081793b0
feat: assign admin role to admin user in seeds
Some checks failed
continuous-integration/drone/push Build is failing
- Create Admin role if it doesn't exist
- Assign Admin role to admin@mv.local user
- Remove separate create_admin_role script (integrated into seeds)
2026-01-06 23:55:46 +01:00
7b3362dc48
feat: add visible buttons with text for role CRUD operations
- Add text labels to Edit and Delete buttons in index page
- Change button size from btn-xs to btn-sm for better visibility
- Add Delete button to show page for non-system roles
- Implement handle_event for delete in show page
- Add format_error helper to show page
2026-01-06 23:48:36 +01:00
8820ce6429
feat: implement role management LiveViews
Add complete CRUD interface for role management under /admin/roles.

- Index page with table showing name, description, permission_set_name, is_system_role
- Show page for role details
- Form component for create/edit with permission_set_name dropdown
- System role badge and disabled delete button
- Flash messages for success/error
- Authorization checks using MvWeb.Authorization helpers
- Comprehensive test coverage (22 tests)

Routes added under /admin scope. All LiveViews load user role
for authorization checks. Form uses custom dropdown for permission sets.
2026-01-06 23:36:26 +01:00
c6b5b7a22e feat: add UI-level authorization helpers
Implement MvWeb.Authorization module with can?/3 and can_access_page?/2
functions for conditional rendering in LiveView templates.

- can?/3 supports both resource atoms and record structs with scope checking
- can_access_page?/2 checks page access permissions
- All functions use PermissionSets module for consistency with backend
- Graceful handling of nil users and invalid permission sets
- Comprehensive test coverage with 17 test cases
2026-01-06 22:34:21 +01:00
18ec4bfd16 fix: add missing /custom_field_values/:id page to read_only and normal_user
All checks were successful
continuous-integration/drone/push Build is passing
- Add /custom_field_values/:id to read_only pages (users can view list, should also view details)
- Add /custom_field_values/:id to normal_user pages
- Refactor tests to reduce duplication (use for-comprehension for structure tests)
- Add tests for invalid input types in valid_permission_set?/1
- Update @spec for valid_permission_set?/1 to accept any() type
2026-01-06 22:17:33 +01:00
7845117fad refactor: improve error handling and documentation in PermissionSets
All checks were successful
continuous-integration/drone/push Build is passing
- Add explicit ArgumentError for invalid permission set names with helpful message
- Soften performance claim in documentation (intended to be constant-time)
- Add tests for error handling
- Improve maintainability with guard clause for invalid inputs
2026-01-06 21:55:52 +01:00
9b0d022767 fix: add missing /profile page to read_only and normal_user permission sets
Both permission sets allow User:update :own, so users should be able
to access their profile page. This makes the implementation consistent
with the documentation and the logical permission model.
2026-01-06 21:55:13 +01:00
3a0fb4e84f
feat: implement PermissionSets module with all 4 permission sets
- Add types for scope, action, resource_permission, permission_set
- Implement get_permissions/1 for all 4 sets (own_data, read_only, normal_user, admin)
- Implement valid_permission_set?/1 for string and atom validation
- Implement permission_set_name_to_atom/1 with error handling
2026-01-06 21:33:39 +01:00
5f13901ca5 security: remove is_system_role from public API
Remove is_system_role from accept lists in create_role and update_role
actions. This field should only be set via seeds or internal actions to
prevent users from creating unkillable roles through the public API.
2026-01-06 19:04:03 +01:00
deacc43030 docs: document FK constraint behavior for role relationship
Add comment explaining on_delete: :restrict behavior for
users.role_id foreign key constraint.
2026-01-06 18:37:37 +01:00
f63405052f feat: add get_role action to Authorization domain
Add get_role action for retrieving single role by ID through
code interface.
2026-01-06 18:37:35 +01:00
557eb4d27d refactor: simplify system role deletion validation
Remove redundant action_type check since validation already
runs only on destroy actions. Add field to error for better
error handling.
2026-01-06 18:37:34 +01:00
12c08cabee docs: clean up PermissionSets documentation
Remove issue number references from moduledoc
2026-01-06 18:14:19 +01:00
82ec4e565a refactor: use UUIDv7 and improve Role validations
- Change id from uuid_primary_key to uuid_v7_primary_key
- Replace custom validation with built-in one_of validation
- Add explicit on_delete: :restrict for users foreign key
- Update postgres references configuration
2026-01-06 18:14:16 +01:00
90c32c2afd feat: add role relationship to User resource
Add belongs_to :role relationship to User resource and register
Authorization domain in config.
2026-01-06 17:18:33 +01:00
4535551b8d feat: add Role resource with validations
Create Role resource with name, description, permission_set_name,
and is_system_role fields. Add validations for permission_set_name
and system role deletion protection.
2026-01-06 17:18:32 +01:00
1b2927ce40 feat: create Authorization domain
Add Mv.Authorization domain with AshAdmin and AshPhoenix extensions.
Register domain in config for role management.
2026-01-06 17:18:30 +01:00
37d1655227 feat: add PermissionSets stub module for role validation
Add minimal PermissionSets module with all_permission_sets/0 function
to support permission_set_name validation in Role resource.
2026-01-06 17:18:29 +01:00
850f00fe22 formatting
All checks were successful
continuous-integration/drone/push Build is passing
2026-01-02 13:53:24 +01:00
08f563a412 Merge branch 'main' into bugfix/274_required_custom_fields
Some checks failed
continuous-integration/drone/push Build is failing
2026-01-02 13:47:24 +01:00
0df5d1c0b9
Merge branch 'main' into feature/280_membership_fee_ui
All checks were successful
continuous-integration/drone/push Build is passing
2025-12-26 23:14:10 +01:00
77ac3d1b18 fix: remove duplicate toggle button in table header
Keep only the toggle button in toolbar for better UX.
2025-12-26 21:41:22 +01:00
619fdc90af fix: clear warning state on Decimal.parse error
Explicitly call hide_amount_warning when Decimal.parse returns error.
2025-12-26 21:41:14 +01:00
856ce53295 fix: improve MembershipFeesComponent state management and error handling
Replace assign_new with assign for cycles and available_fee_types. Set regenerating flag at event start. Fix create_cycle parsing with explicit error handling. Use atomic bulk delete for all cycles. Improve delete confirmation robustness. Fix unless/else pattern for Credo compliance.
2025-12-26 21:41:05 +01:00
3afc20c2e2 refactor: improve format_currency robustness and reduce complexity
Extract formatting logic into helper functions to reduce cyclomatic complexity. Improve pattern matching for edge cases.
2025-12-26 21:40:53 +01:00
ee6589c4fa docs: correct load_cycles_for_members documentation
Document that function loads all cycles, not just relevant ones, as no database-level filtering is currently implemented.
2025-12-26 21:40:42 +01:00
5318b2c07d docs: add typespec for SetDefaultMembershipFeeType.change/3 2025-12-26 21:40:32 +01:00
d02add75ef fix: convert after_action to after_transaction for cycle generation
Replace after_action hooks with after_transaction to ensure async tasks only run after successful commit. Extract common cycle generation logic into handle_cycle_generation/2 to reduce duplication. Add structured error logging with context.
2025-12-26 21:40:22 +01:00
b2c2013b4d refactor: extract sql_sandbox config to Mv.Config module
Centralize application-wide configuration values for better maintainability.
2025-12-26 21:40:12 +01:00
961261eff2 feat: add Task.Supervisor to supervision tree
Add Task.Supervisor for supervised async task execution in cycle generation.
2025-12-26 21:40:04 +01:00
3035869fc8 Add explicit domain to Ash.get! for consistency
All checks were successful
continuous-integration/drone/push Build is passing
2025-12-26 21:04:43 +01:00
a8ea121800
Refactor cycle generator and update translations
All checks were successful
continuous-integration/drone/push Build is passing
Extract error handling into separate functions to reduce nesting depth.
2025-12-26 21:01:17 +01:00
3cf8244cd6 fix linting errors
Some checks failed
continuous-integration/drone/push Build is failing
2025-12-23 18:14:59 +01:00
1dd68bcaf2 feat: coherent required boolean handling
Some checks failed
continuous-integration/drone/push Build is failing
2025-12-23 18:08:31 +01:00
33652265b8 feat: add accessible empty value also to member fields
Some checks failed
continuous-integration/drone/push Build is failing
2025-12-23 17:10:52 +01:00
8e58829e95 fix: improve performance loading custom fields 2025-12-23 17:07:38 +01:00
4e101ea36e feat: Add WCAG-compliant handling for boolean custom fields 2025-12-23 17:02:07 +01:00