npm package: @masterteam/task-schedule
Description: Syncfusion Gantt based task-schedule package with external model switching.
Latest version: 0.0.7

# `@masterteam/task-schedule`

Syncfusion Gantt based task-schedule package with external model switching.

## Public API

- `TaskSchedule` component (`mt-task-schedule`)
- `TaskScheduleHeader` component (`mt-task-schedule-header`)
- `TaskScheduleImportDialog` component (`mt-task-schedule-import-dialog`)
- `TaskScheduleFetchDataAdapter` interface
- `TaskScheduleActionDataAdapter` interface
- `TaskScheduleFetchService`
- `TaskScheduleActionService`
- `TaskScheduleModelType`
- `TaskScheduleContext`
- `TASK_SCHEDULE_DEFAULT_PDF_FONT`

## Inputs

- `context`: object with required `levelId` and `levelDataId` for fetch-based schedule reads

Main context fields:

- `modelType`: `'default' | 'edit' | 'baseline' | 'criticalPath' | 'critical-path' | 'resources' | 'unscheduled' | 'phaseGate' | 'custom'`
- `langCode`: `'en' | 'ar' | null`
- `dateFormat`: default `dd/MM/yyyy`
- `height`: default `760px`
- `pdfFonts`: optional `{ regular?: string; arabic?: string; size?: number }`

## Outputs

- `toolbarAction`
- `actionBegin`
- `actionCompleted`
- `loaded`
- `loadError`

`TaskScheduleFetchDataAdapter` methods:

- `load(modelType, context)`
- `importTasks(context, file)`
- `exportTasks(context)`
- `loadDependencies(context)`
- `loadTimeline(context, mode)`
- `loadBaselineVersions(context)`
- `loadBaselineSnapshot(context, version?)`

`TaskScheduleActionDataAdapter` methods:

- `createTask(context, payload)`
- `updateTask(context, taskId, payload)`
- `deleteTask(context, taskId)`
- `updateBulkTasks(context, payload)`
- `updateParent(context, taskId, parentId)`
- `updateOrder(context, payload)`
- `updateProgress(context, taskId, payload)`
- `applyImportedTasks(context, payload)`
- `setBaseline(context, payload?)`
- `createDependency(context, payload)`
- `updateDependency(context, dependencyId, payload)`
- `deleteDependency(context, dependencyId)`

## Usage

```ts
import { Component, signal } from '@angular/core';
import {
  TaskSchedule,
  TaskScheduleModelType,
} from '@masterteam/task-schedule';

@Component({
  standalone: true,
  imports: [TaskSchedule],
  selector: 'app-task-schedule-host',
  template: `
    <mt-task-schedule
      [context]="{
        levelId: 12,
        modelType: modelType(),
        levelDataId: 18,
        langCode: 'en'
      }"
    />
  `,
})
export class TaskScheduleHostComponent {
  readonly modelType = signal<TaskScheduleModelType>('default');
}
```

`mt-task-schedule` uses `TaskScheduleFetchService` for reads and `TaskScheduleActionService` for write actions.
`mt-task-schedule-header` and `TaskScheduleImportDialog` also split fetch/write behavior across the same two services.

Backend routes used:

- Mixed schedule reads (default/edit/critical/custom/resources/unscheduled): `POST /api/levels/{levelId}/{levelDataId}/schedule/read`
- Phase-gate runtime tree: `GET /api/levels/{levelId}/{levelDataId}/schedule/tree?renderMode=PhaseGate`
- Runtime baseline snapshot view: `GET /api/levels/{levelId}/{levelDataId}/schedule/baselines/latest`
- Runtime baseline history: `GET /api/levels/{levelId}/{levelDataId}/schedule/baselines`
- Runtime baseline version snapshot: `GET /api/levels/{levelId}/{levelDataId}/schedule/baselines/{version}`
- Runtime dependencies: `GET/POST/PUT/DELETE /api/levels/{levelId}/{levelDataId}/schedule/dependencies`
- Runtime timeline buckets: `POST /api/levels/{levelId}/{levelDataId}/schedule/read` with `mode: 'Timeline'`
- Custom view config: `GET /api/schedulemanager/{levelId}/schedule/{customViewId}`
- Team members (edit/resources mode): `GET /api/levels/{levelId}/TeamMember`

Runtime mutations (when `levelDataId` exists):

- `POST /api/process-submit` for create/update/delete/progress
- `PUT /api/levels/{levelId}/{levelDataId}/schedule/bulk-update`
- `PUT /api/levels/{levelId}/{levelDataId}/schedule/reorder`
- `POST /api/levels/{levelId}/{levelDataId}/schedule/baselines` (set baseline)
- `GET /api/levels/{levelId}/{levelDataId}/schedule/mpp` (export)

Plain schedule reads no longer use legacy `/api/tasks/...` read routes.
Import dialog keeps its current MPP preview/apply flow unless `endpoints.importTasks` / `endpoints.applyImportedTasks` are overridden.

Context options for backend routing:

- `modelType`: selected schedule mode
- `langCode`: optional language override
- `dateFormat`: optional gantt date format
- `height`: optional gantt height
- `customViewId`: used in `custom` mode to load schedule-manager view columns
- `resources`: optional static resource list override
- `endpoints`: optional endpoint template overrides (`processSubmit`, `scheduleRead`, `scheduleQuery`, `scheduleTree`, `scheduleTreePhaseGate`, `scheduleDependencies`, `scheduleDependencyById`, `scheduleBaselines`, `scheduleBaselineByVersion`, `scheduleViewById`, `teamMembers`, `createTask`, etc.)
- `endpoints.importTasks` / `endpoints.applyImportedTasks`: optional overrides for runtime/legacy MPP import flow
- `endpoints.setBaseline`: optional override for baseline endpoint (runtime default: `/api/levels/{levelId}/{levelDataId}/schedule/baselines`)
- `endpoints.exportTasks`: optional override for export endpoint (runtime default: `/api/levels/{levelId}/{levelDataId}/schedule/mpp`)
- `pdfFonts`: optional `{ regular?: string; arabic?: string; size?: number }` base64 font config for PDF export

HTTP base URL, auth, language headers, and idempotency are expected to be handled by the host app interceptors.

When no PDF font is provided, package fallback uses embedded `TASK_SCHEDULE_DEFAULT_PDF_FONT`.

## Import Dialog

Use `TaskScheduleImportDialog` with `ModalService` to import `.mpp`/`.xer` files and apply tasks (replace or append).  
The dialog is Tailwind-based and uses `@masterteam/components` (`mt-button`, `mt-entity-preview`).
Imported rows support inline editing before apply (task name, planned/actual dates, assignee, progress) with per-row selection.

## Shell Component

Use `mt-task-schedule-header` as a reusable schedule header that combines:

- mode switcher
- Set Baseline action (feature service `setBaseline`)
- Import dialog orchestration
- Export tasks action (feature service `exportTasks`)

It does not render `mt-task-schedule` internally. Use it separately when you want a standard schedule header above your own schedule host.

Shell parity control fields also live on `context`:

- `modeOptions`
- `allowEditMode`
- `allowImport`
- `allowSetBaseline`
- `hasTasks`
- `baselinePending`

Use the fetch service for reads/import preview/export and the action service for mutations. The package does not use NGXS.

Fetch and action helpers exposed for runtime helpers:

- `loadDependencies`
- `createDependency`
- `updateDependency`
- `deleteDependency`
- `loadTimeline`
- `loadBaselineVersions`
- `loadBaselineSnapshot`

See `PARITY_REPORT.md` for legacy-to-package migration coverage.