commit task-ep.1.6.2-r1

This commit is contained in:
phaichayon
2026-07-13 22:29:11 +07:00
parent 7d7548ebd4
commit bb5a910b88
49 changed files with 4663 additions and 361 deletions

View File

@@ -0,0 +1,65 @@
# Task EP.1.6.2 - Direct Big Calendar UI Adoption
Date: 2026-07-13
Status: Foundation Implemented
Upstream reviewed: `lramos33/big-calendar`
Upstream commit: `fbb8485e3d54b267261056c784632229ba6f7bc3`
License: MIT, upstream concepts retained with local ALLA OS adaptation.
## Summary
EP.1.6.2 replaces the CRM calendar workspace's custom tab/grid renderer with a local Big Calendar layer adapted from the upstream component architecture. The implementation preserves ALLA OS backend ownership: Activity, Business Events, Calendar Projection, Projection Runtime, permissions, and API contracts remain unchanged.
The UI now flows through:
```text
CalendarProjectionItem
-> mapCalendarProjectionToBigCalendarEvent()
-> BigCalendarProvider
-> BigCalendarHeader
-> Day / Week / Month / Agenda views
-> Activity reschedule command
```
## Adopted Components And Concepts
- Added `src/features/crm/calendar/big-calendar/provider.tsx` for local calendar state, selected date, selected view, user filter, drag state, working hours, and Activity command dispatch.
- Added `src/features/crm/calendar/big-calendar/header.tsx` for upstream-style Today, previous, next, range display, user filter, and view switching.
- Added `src/features/crm/calendar/big-calendar/views.tsx` for Day, Week, Month, and Agenda rendering.
- Added `src/features/crm/calendar/big-calendar/calendar-slot.tsx` for calendar slots, empty overlays, and HTML5 drop handling.
- Added `src/features/crm/calendar/big-calendar/event-card.tsx` for draggable event cards and resize command affordance.
- Added `src/features/crm/calendar/big-calendar/helpers.ts` and `types.ts` for local view, slot, date range, and command contracts.
- Updated `src/features/crm/calendar/components/calendar-workspace.tsx` to use the Big Calendar provider/header/views instead of local custom renderers.
- Updated `src/features/crm/calendar/components/calendar-adapter.ts` with `mapBigCalendarActionToActivityCommand()`.
- Extended `BigCalendarEvent.source` with `ownerId` and `assigneeId` so the provider can support user filtering without reading database rows.
## Rejected Upstream Demo Code
- Did not import the upstream app shell, demo stores, or mock data ownership.
- Did not add React Hook Form; this repository forbids new RHF usage.
- Did not add upstream persistence or direct database reads.
- Did not mutate `crm_calendar_projection` rows from UI interactions.
- Did not replace the Activity API or Business Event flow.
## Interaction Behavior
- Editable Activity events can emit reschedule commands through `rescheduleActivity()`.
- Drag/drop maps a dropped editable Activity to an Activity reschedule request.
- Resize currently uses a command-based duration extension affordance rather than full upstream edge-resize parity.
- Read-only milestones do not emit Activity commands.
- After successful reschedule, Calendar, Activity, and My Day query groups are invalidated.
- Day, Week, and Month retain EP.1.6.1 behavior by always rendering grid slots, including empty states.
- Agenda keeps list-style empty behavior.
## Upgrade Strategy
Future upstream sync should compare against commit `fbb8485e3d54b267261056c784632229ba6f7bc3`, then port only rendering and interaction improvements into `src/features/crm/calendar/big-calendar/**`. Keep ALLA OS adapter and command boundaries stable.
Full upstream parity still requires a deliberate dependency review for `react-dnd`, upstream resize behavior, and any accessibility changes before adding them to this Next.js 16 / React 19 / shadcn / TanStack stack.
## Verification
- Passed: `npm run typecheck`
- Passed: `npx oxlint src/features/crm/calendar`
- Not run: `npm run db:generate` because EP.1.6.2 made no schema changes.
- Not automated: browser drag/drop, resize, responsive, and screen-reader regression checks.

View File

@@ -0,0 +1,89 @@
# Task EP.1.6.2-R1 - Upstream Big Calendar Source Adoption
Date: 2026-07-13
Status: Implemented
Upstream: `https://github.com/lramos33/big-calendar`
Pinned commit: `fbb8485e3d54b267261056c784632229ba6f7bc3`
## Outcome
R1 replaces the locally reimplemented EP.1.6.2 calendar renderer with copied upstream Big Calendar source under:
```text
src/features/crm/calendar/upstream-big-calendar/**
```
The active `/dashboard/crm/calendar` workspace now renders:
```text
CalendarProvider -> ClientContainer -> CalendarHeader -> Day / Week / Month / Year / Agenda
```
ALLA OS still owns Calendar Projection, Activity lifecycle, Business Events, Projection Runtime, CRM authorization, and React Query invalidation.
## Removal / Replacement Matrix
| Previous EP.1.6.2 file | R1 action | Replacement |
| --- | --- | --- |
| `big-calendar/provider.tsx` | removed | upstream `contexts/calendar-context.tsx` |
| `big-calendar/header.tsx` | removed | upstream `components/header/**` |
| `big-calendar/views.tsx` | removed | upstream `month-view`, `week-and-day-view`, `agenda-view`, `year-view` |
| `big-calendar/calendar-slot.tsx` | removed | upstream day/week/month cells and DnD droppables |
| `big-calendar/event-card.tsx` | removed | upstream event block, month badge, agenda card |
| `big-calendar/helpers.ts` | removed | upstream `helpers.ts` |
| `big-calendar/types.ts` | removed | upstream `interfaces.ts` and `types.ts` |
The previous custom folder was removed from the active source tree.
## Local Adapter Boundary
- `mapCalendarProjectionToUpstreamEvent()` maps `CalendarProjectionItem` into upstream `IEvent`.
- `mapUpstreamEventToActivityCommand()` maps upstream moved events into Activity reschedule commands.
- Upstream `IEvent` carries an `alla` metadata object for source references, editability, milestone/read-only flags, and visibility metadata.
- Read-only milestones are marked non-editable and prevented from dragging through upstream DnD wrappers.
## Upstream Patches
- Import paths were rewritten from `@/calendar/*` to the isolated local upstream directory.
- `lucide-react` imports were mapped to the project icon registry via `upstream-big-calendar/icons.tsx`.
- Upstream demo add/edit dialogs were replaced with ALLA-safe integration shells; React Hook Form was not introduced.
- Upstream mock data, request helpers, and demo schemas were removed.
- `CalendarProvider` was extended with `initialDate`, `initialView`, and `onEventChange`.
- `ClientContainer` now reads selected view from upstream context so the toolbar can switch views inside the ALLA route.
- Header view buttons preserve upstream toolbar composition but no longer navigate to upstream demo routes.
- Upstream `react-dnd` / `react-dnd-html5-backend` behavior is used for drag/drop.
## Dependency Review
Added:
- `react-dnd@16.0.1`
- `react-dnd-html5-backend@16.0.1`
Not added:
- `react-hook-form`
- `@hookform/resolvers`
- `react-aria-components`
- `lucide-react`
Reason: those were only required by upstream demo forms/config controls or were replaced by existing ALLA UI/icon primitives.
`npm install` reported existing audit findings after dependency update: 9 moderate and 3 high. No automatic `audit fix --force` was run because it may introduce unrelated breaking changes.
## Parity Notes
- Adopted upstream Day, Week, Month, Agenda, Year, Header, DnD provider, drag layer, droppable cells, event positioning helpers, multi-day rows, and month event badges.
- Agenda empty state comes from upstream agenda view.
- Day/Week/Month still render actual upstream grids when empty.
- Year view is adopted.
- Drag/drop uses upstream `react-dnd` mechanics and forwards changed editable Activity events to the ALLA Activity reschedule API.
- Resize edge-handle parity remains limited by the reviewed upstream commit; no separate local resize approximation was retained.
- Full browser visual parity, dark-mode parity, and interaction parity still require manual browser verification.
## Verification
- Passed: `npm run typecheck`
- Passed: `npx oxlint src/features/crm/calendar`
- Not run: `npm run db:generate`; no schema changes.
- Not automated: browser drag/drop regression, responsive screenshots, screen-reader pass, dark-mode visual parity.