@outbuild-company/schedule-core 1.10.3 → 1.10.4

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.
package/dist/index.cjs CHANGED
@@ -4284,15 +4284,28 @@ var setDuration = (value) => ({
4284
4284
  });
4285
4285
 
4286
4286
  // src/columns/start-date/start-date-pipeline.ts
4287
+ var SIR_APPLY_EVENT_SOURCE = "sir-apply";
4287
4288
  var startDatePipeline = {
4288
4289
  targetField: "startDate",
4289
- canEdit(activity, hierarchy) {
4290
+ canEdit(activity, hierarchy, edit) {
4290
4291
  if (isSummaryActivity2(activity, hierarchy)) {
4291
4292
  return cannotEdit("summary", "summary_column_value");
4292
4293
  }
4293
- if (hasProgress(activity)) {
4294
+ if (!hasProgress(activity)) return canEdit();
4295
+ if (edit?.eventSource !== SIR_APPLY_EVENT_SOURCE) {
4294
4296
  return cannotEdit("has_progress", "cant_edit_activity_with_progress");
4295
4297
  }
4298
+ if (isCompletedActivity(activity)) {
4299
+ return cannotEdit("completed", "cant_edit_completed_activity");
4300
+ }
4301
+ if (!isValidDate(edit.newValue)) return canEdit();
4302
+ if (isSameDay(activity.startDate, edit.newValue)) return canEdit();
4303
+ if (edit.newValue.getTime() > activity.startDate.getTime()) {
4304
+ return cannotEdit(
4305
+ "sir_start_after_progress",
4306
+ "sir_cant_move_start_after_progress"
4307
+ );
4308
+ }
4296
4309
  return canEdit();
4297
4310
  },
4298
4311
  parseInput(rawValue, _activity, _ctx) {
@@ -13862,7 +13875,7 @@ async function dispatchBulkEdit(action, options, deps) {
13862
13875
  const warnings = [];
13863
13876
  let needsAutoSchedule = false;
13864
13877
  for (const edit of action.edits) {
13865
- const outcome = applyOneEdit2(edit, deps);
13878
+ const outcome = applyOneEdit2(edit, deps, action.eventSource);
13866
13879
  verdicts.push(outcome.verdict);
13867
13880
  if (!outcome.verdict.ok || !outcome.changes) continue;
13868
13881
  const constraintWarning = toConstraintWarning(
@@ -13958,7 +13971,7 @@ async function dispatchBulkEdit(action, options, deps) {
13958
13971
  })
13959
13972
  };
13960
13973
  }
13961
- function applyOneEdit2(edit, deps) {
13974
+ function applyOneEdit2(edit, deps, eventSource) {
13962
13975
  const { ctx } = deps;
13963
13976
  const activityId = edit.activityId;
13964
13977
  const pipeline = findPipelineForColumn(edit.column);
@@ -13983,7 +13996,10 @@ function applyOneEdit2(edit, deps) {
13983
13996
  changes: null
13984
13997
  };
13985
13998
  }
13986
- const editGate = pipeline.canEdit(activitySnap, ctx.hierarchy);
13999
+ const editGate = pipeline.canEdit(activitySnap, ctx.hierarchy, {
14000
+ eventSource,
14001
+ newValue: edit.newValue
14002
+ });
13987
14003
  if (!editGate.allowed) {
13988
14004
  return {
13989
14005
  verdict: {
@@ -21346,11 +21362,7 @@ var ScheduleCore = class _ScheduleCore {
21346
21362
  );
21347
21363
  });
21348
21364
  this._criticalPathReady = this._initPromise.then(
21349
- () => this._enqueue(async () => {
21350
- const result = await this._runCriticalPathAndCapture();
21351
- this._criticalPathRevision = this._scheduleRevision;
21352
- return result;
21353
- })
21365
+ () => this._startCriticalPathForCurrentRevision()
21354
21366
  );
21355
21367
  const waitForCriticalPathOnLoad = input.criticalPathOnLoad === true;
21356
21368
  this._ready = waitForCriticalPathOnLoad ? this._criticalPathReady.then(() => void 0) : this._initPromise;
@@ -21988,39 +22000,6 @@ var ScheduleCore = class _ScheduleCore {
21988
22000
  void promise.then(clearIfActive, clearIfActive);
21989
22001
  return promise;
21990
22002
  }
21991
- async _runCriticalPathAndCapture() {
21992
- if (this._status === SCHEDULE_CORE_STATUS.DESTROYED) {
21993
- return {
21994
- changes: {
21995
- source: { kind: "init" },
21996
- activities: [],
21997
- links: [],
21998
- calendars: [],
21999
- trackingEvents: []
22000
- }
22001
- };
22002
- }
22003
- this.coreRuntime.state.beginWriteCapture();
22004
- this.coreRuntime.customIdTracker.beginCustomIdTransaction();
22005
- let changes;
22006
- try {
22007
- await applyCriticalPath(
22008
- this.coreRuntime.state,
22009
- this.coreRuntime.sector.hoursPerDay
22010
- );
22011
- changes = await assembleChangeSet(this.coreRuntime.state, {
22012
- source: { kind: "init" },
22013
- beforeSnap: /* @__PURE__ */ new Map(),
22014
- touchedIds: [],
22015
- scheduledIds: [],
22016
- hoursPerDay: this.coreRuntime.sector.hoursPerDay
22017
- });
22018
- } finally {
22019
- this.coreRuntime.state.endWriteCapture();
22020
- this.coreRuntime.customIdTracker.commitCustomIdTransaction();
22021
- }
22022
- return { changes };
22023
- }
22024
22003
  undo(options = {}) {
22025
22004
  const admitted = this._admitScheduleMutation();
22026
22005
  let changedState = false;