@masterteam/task-schedule 0.0.21 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2641,15 +2641,24 @@ class TaskScheduleDialog {
2641
2641
  this.ref.close(response);
2642
2642
  }
2643
2643
  mapSubmitRequest(request) {
2644
- if (this.mode() !== 'create' || !this.parentGuid()) {
2645
- return request;
2644
+ // Schedule items submit under their type-specific schedule module key
2645
+ // ('Task' | 'Milestone' | 'Deliverable'), not the generic 'ModuleData' the
2646
+ // form loads with. The backend only maps the task_* fields (and the parent
2647
+ // link) when the schedule module key is used.
2648
+ const moduleKey = this.selectedType() ?? request.moduleKey;
2649
+ const isSubtaskCreate = this.mode() === 'create' && !!this.parentGuid();
2650
+ if (!isSubtaskCreate) {
2651
+ return { ...request, moduleKey };
2646
2652
  }
2647
2653
  return {
2648
2654
  ...request,
2655
+ moduleKey,
2649
2656
  fields: [
2650
2657
  ...(request.fields ?? []),
2651
2658
  {
2652
- propertyKey: 'parentId',
2659
+ // Parent reference is the anchor row's schedule guid / externalId,
2660
+ // not its numeric database id.
2661
+ propertyKey: 'externalParentId',
2653
2662
  value: this.parentGuid(),
2654
2663
  },
2655
2664
  ],
@@ -3721,6 +3730,16 @@ class TaskSchedule {
3721
3730
  this.openScheduleDialog(args?.requestType === 'beforeOpenEditDialog' ? 'edit' : 'create', args);
3722
3731
  return;
3723
3732
  }
3733
+ // Context-menu "Add > Above/Below/Child" calls Gantt's addRecord directly,
3734
+ // so it never raises beforeOpenAddDialog — the row is inserted locally and
3735
+ // never persisted (it vanishes on refresh). Cancel that local-only add and
3736
+ // route it through the create dialog, which saves it with the correct
3737
+ // parent (parentGuid is resolved from the right-clicked anchor row).
3738
+ if (args?.requestType === 'beforeAdd' && this.isContextAddAction()) {
3739
+ args.cancel = true;
3740
+ this.openScheduleDialog('create', args);
3741
+ return;
3742
+ }
3724
3743
  if (args?.requestType === 'beforeDelete') {
3725
3744
  args.cancel = true;
3726
3745
  const taskId = this.actionService.readDeleteTaskId(args);
@@ -4013,12 +4032,18 @@ class TaskSchedule {
4013
4032
  }
4014
4033
  resolveParentGuidForContextAddTask(task) {
4015
4034
  const actionId = this.contextAddTask();
4035
+ // The anchor is Syncfusion's row object, which keeps the original record
4036
+ // (and its custom guid/parentGuid) under `taskData` rather than at the top
4037
+ // level. Fall back to it so the subtask is actually created with a parent.
4038
+ const taskData = task?.['taskData'];
4039
+ const guid = task?.guid ?? taskData?.guid;
4040
+ const parentGuid = task?.parentGuid ?? taskData?.parentGuid;
4016
4041
  if (actionId.endsWith('_contextMenu_Child')) {
4017
- return String(task?.guid ?? '');
4042
+ return String(guid ?? '');
4018
4043
  }
4019
4044
  if (actionId.endsWith('_contextMenu_Below') ||
4020
4045
  actionId.endsWith('_contextMenu_Above')) {
4021
- return String(task?.parentGuid ?? '');
4046
+ return String(parentGuid ?? '');
4022
4047
  }
4023
4048
  return null;
4024
4049
  }