fix(db): make Edit leads and Export leads grantable url-less M modules

The Roles screen only grants type M modules, so type A could never be
granted. A url-less M module with no children stays out of the sidebar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-11-27 16:12:21 +08:00
1 parent 6ab495ad3e
commit 6855906cf1
4 files changed
+13 -10

No files matched your search

+2 -2
View File
@@ -116,5 +116,5 @@ ALTER TABLE `event_lead` ADD KEY `idx_event_lead_company_lead` (`company_id`, `l
USE `service-system`;
INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES
(40400000, 'BO_LEADS', 'Leads', 'BO', 'M', 40000000, '/leads', 'Users'),
(40500000, 'BO_LEADS_EDIT', 'Edit leads', 'BO', 'A', 40000000, NULL, NULL),
(40600000, 'BO_LEADS_EXPORT', 'Export leads', 'BO', 'A', 40000000, NULL, NULL);
(40500000, 'BO_LEADS_EDIT', 'Edit leads', 'BO', 'M', 40000000, NULL, NULL),
(40600000, 'BO_LEADS_EXPORT', 'Export leads', 'BO', 'M', 40000000, NULL, NULL);
@@ -12,7 +12,7 @@ Change 4a (`openspec/changes/archive/2026-11-27-add-event-lead-capture/`) added
**Access control:**
- `@AdminModule` allows a caller holding any one of the listed modules (`AppAccessAspect`). `AdminModuleAccess.grantedAny` checks modules in code.
- Modules of type `A` (action) are granted like any module and show in the Roles access tree. The sidebar never shows them (`aclSidebar.ts`).
- Only modules of type `M` can be granted on the Roles screen (`AdminAclService.isGrantable`); type `A` is refused with `UNKNOWN_MODULE`. The sidebar hides an `M` module that has no url and no children (`aclSidebar.ts`, with a test).
- The portal checks access with `useAdminAuth().hasModule(name)`.
**Data facts:**
@@ -48,10 +48,12 @@ See proposal.md for why.
| id | name | desc | type | url | icon_name |
|---|---|---|---|---|---|
| 40400000 | `BO_LEADS` | Leads | `M` | `/leads` | `Users` |
| 40500000 | `BO_LEADS_EDIT` | Edit leads | `A` | NULL | NULL |
| 40600000 | `BO_LEADS_EXPORT` | Export leads | `A` | NULL | NULL |
| 40500000 | `BO_LEADS_EDIT` | Edit leads | `M` | NULL | NULL |
| 40600000 | `BO_LEADS_EXPORT` | Export leads | `M` | NULL | NULL |
**Placement:** the two action modules sit directly under the root, not under `BO_LEADS`. That way a role with only `BO_EVENT_LEADS` can still be given export.
**Edit and Export modules:** these are url-less `M` modules, so they can be granted and never show in the sidebar. A first draft used type `A`, which the Roles screen cannot grant.
**Placement:** the two modules sit directly under the root, not under `BO_LEADS`. That way a role with only `BO_EVENT_LEADS` can still be given export.
**Files:** `sql/01-lead-index.sql`, `sql/02-lead-modules.sql`, `sql/99-rollback.sql`, all mirrored in `local/seed/03-colite.sql`.
@@ -17,7 +17,7 @@ Change 4a lets staff capture leads at an event and work them one event at a time
- Each export is logged with the username, the listing and the row count, but never with lead data.
- **Permissions**:
- New menu module `BO_LEADS` (`/leads`) to view the Lead Listing and lead detail.
- New action modules `BO_LEADS_EDIT` (edit a lead) and `BO_LEADS_EXPORT` (export either listing). Action modules never show in the sidebar.
- New modules `BO_LEADS_EDIT` (edit a lead) and `BO_LEADS_EXPORT` (export either listing). They have no url, so they never show in the sidebar.
- An export also needs the listing's own module: `BO_LEADS` for the Lead Listing, `BO_EVENT_LEADS` for the Event Leads Listing.
- **Link from the event lead edit page** to the lead detail page, for users who hold `BO_LEADS`.
- **New dependency** `org.apache.poi:poi-ooxml` 4.1.0 in `mobile-api`. It is the same library and version that `services-system` already uses for its spreadsheet exports.
@@ -1,9 +1,10 @@
-- Co-Lite change 4b: Leads menu module and the Edit leads / Export leads action modules (area BO).
-- The action modules sit under the root so a role with only Event leads can be given export.
-- Edit and Export are url-less M modules: grantable on the Roles screen (only type M is), hidden from the sidebar
-- (a url-less M with no children renders nothing). They sit under the root so a role with only Event leads can be given export.
-- Target: `service-system`.`module`. Additive only. Run once.
USE `service-system`;
INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES
(40400000, 'BO_LEADS', 'Leads', 'BO', 'M', 40000000, '/leads', 'Users'),
(40500000, 'BO_LEADS_EDIT', 'Edit leads', 'BO', 'A', 40000000, NULL, NULL),
(40600000, 'BO_LEADS_EXPORT', 'Export leads', 'BO', 'A', 40000000, NULL, NULL);
(40500000, 'BO_LEADS_EDIT', 'Edit leads', 'BO', 'M', 40000000, NULL, NULL),
(40600000, 'BO_LEADS_EXPORT', 'Export leads', 'BO', 'M', 40000000, NULL, NULL);