그리드 없는 간트 편집과 이벤트 기록Gantt editing without a grid, with an event log
편집을 켠 차트가 보내는 의도 이벤트를 받아 가짜 서버가 확정하거나 거절해요(applyPatch, revertIntent).The chart with editing on sends intent events; a fake server confirms or refuses them (applyPatch, revertIntent).
코드Code
탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.
이 예제는 추가 패키지가 필요해요. 내 컴퓨터에서 돌리려면 npm i maxgrid @maxgrid/gantt로 설치하세요.
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<div id="app">
<div id="grid" style="height: 460px"></div>
</div>
<script type="module" src="./main.js"></script>import { setup } from './example';
setup(document.getElementById('grid'), console.log);import { createGantt } from '@maxgrid/gantt';
// 편집을 켠 간트 차트(그리드 없음). 차트는 데이터를 스스로 바꾸지 않아요. 막대를 놓으면 intentId가 든 이벤트만 보내고,
// 호스트가 서버에 확인한 뒤 applyPatch로 확정하거나 revertIntent로 되돌려요. 여기서는 0.4초 걸리는 가짜 서버를 써요.
const data = {
tasks: [
{
id: '1',
parentId: null,
sortNo: 1,
name: '웹사이트 개편',
status: 'IN_PROGRESS',
plannedStart: '2026-11-02',
plannedEnd: '2027-01-29',
progressPct: 40,
isMilestone: false,
hasChildren: true,
calendarId: null,
version: 1,
},
{
id: '2',
parentId: '1',
sortNo: 1,
name: '디자인',
status: 'DONE',
plannedStart: '2026-11-02',
plannedEnd: '2026-11-20',
progressPct: 100,
isMilestone: false,
hasChildren: true,
calendarId: null,
version: 1,
},
{
id: '3',
parentId: '2',
sortNo: 1,
name: '와이어프레임',
status: 'DONE',
plannedStart: '2026-11-02',
plannedEnd: '2026-11-10',
progressPct: 100,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '4',
parentId: '2',
sortNo: 2,
name: '화면 디자인',
status: 'DONE',
plannedStart: '2026-11-11',
plannedEnd: '2026-11-20',
progressPct: 100,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '5',
parentId: '1',
sortNo: 2,
name: '개발',
status: 'IN_PROGRESS',
plannedStart: '2026-11-23',
plannedEnd: '2027-01-15',
progressPct: 30,
isMilestone: false,
hasChildren: true,
calendarId: null,
version: 1,
},
{
id: '6',
parentId: '5',
sortNo: 1,
name: '프런트엔드',
status: 'IN_PROGRESS',
plannedStart: '2026-11-23',
plannedEnd: '2026-12-18',
progressPct: 60,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '7',
parentId: '5',
sortNo: 2,
name: '백엔드',
status: 'IN_PROGRESS',
plannedStart: '2026-11-30',
plannedEnd: '2027-01-08',
progressPct: 20,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '8',
parentId: '5',
sortNo: 3,
name: '콘텐츠 이전',
status: 'ON_HOLD',
plannedStart: '2026-12-07',
plannedEnd: '2026-12-24',
progressPct: 0,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '9',
parentId: '5',
sortNo: 4,
name: '통합 시험',
status: 'TODO',
plannedStart: '2027-01-04',
plannedEnd: '2027-01-15',
progressPct: 0,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '10',
parentId: '1',
sortNo: 3,
name: '출시',
status: 'TODO',
plannedStart: '2027-01-29',
plannedEnd: '2027-01-29',
progressPct: 0,
isMilestone: true,
hasChildren: false,
calendarId: null,
version: 1,
},
],
dependencies: [
{ id: 'd1', predecessorId: '3', successorId: '4', depType: 'FS', lagDays: 0 },
{ id: 'd2', predecessorId: '4', successorId: '6', depType: 'FS', lagDays: 0 },
{ id: 'd3', predecessorId: '6', successorId: '9', depType: 'FS', lagDays: 0 },
{ id: 'd4', predecessorId: '9', successorId: '10', depType: 'FS', lagDays: 0 },
],
calendars: [{ id: 'c1', name: '표준', workDays: 31, isDefault: true, exceptions: [] }],
};
// 가짜 서버의 규칙: 프로젝트 시작(2026-11-02)보다 앞으로는 못 옮겨요(거절).
const PROJECT_START = '2026-11-02';
const fakeServer = (change) => new Promise((resolve) => setTimeout(() => resolve((change.plannedStart ?? PROJECT_START) < PROJECT_START ? 'refused' : 'ok'), 400));
export function setup(host, log) {
const gantt = createGantt(host, {
ariaLabel: '프로젝트 일정',
locale: 'ko',
rowHeight: 32,
today: '2026-11-26',
editable: true,
});
gantt.setData(data);
const answer = async (intentId, taskId, change) => {
if ((await fakeServer(change)) === 'ok') {
gantt.applyPatch({ intentId, tasks: [{ id: taskId, ...change }] }); // 확정
log({ ko: `서버가 확정했어요: ${taskId}번`, en: `Server confirmed: task ${taskId}` });
}
else {
gantt.revertIntent(intentId); // 거절: 막대가 원래 자리로 돌아가요
log({
ko: `서버가 거절했어요: ${taskId}번, 막대를 되돌렸어요`,
en: `Server refused task ${taskId}; the bar was reverted`,
});
}
};
const offs = [
gantt.on('task-move', (e) => {
log({
ko: `옮기기: ${e.taskId}번, ${e.plannedStart} ~ ${e.plannedEnd}`,
en: `Move: task ${e.taskId}, ${e.plannedStart} to ${e.plannedEnd}`,
});
void answer(e.intentId, e.taskId, { plannedStart: e.plannedStart, plannedEnd: e.plannedEnd });
}),
gantt.on('task-resize', (e) => {
log({
ko: `늘이기·줄이기(${e.edge}): ${e.taskId}번, ${e.plannedStart} ~ ${e.plannedEnd}`,
en: `Resize (${e.edge}): task ${e.taskId}, ${e.plannedStart} to ${e.plannedEnd}`,
});
void answer(e.intentId, e.taskId, { plannedStart: e.plannedStart, plannedEnd: e.plannedEnd });
}),
gantt.on('task-progress', (e) => {
log({
ko: `진행률: ${e.taskId}번 ${e.progressPct}%`,
en: `Progress: task ${e.taskId} ${e.progressPct}%`,
});
void answer(e.intentId, e.taskId, { progressPct: e.progressPct });
}),
gantt.on('dependency-create', (e) => {
log({
ko: `의존 만들기: ${e.predecessorId} → ${e.successorId} (${e.depType})`,
en: `Link: ${e.predecessorId} to ${e.successorId} (${e.depType})`,
});
// 이 예제는 새 의존을 항상 거절해요(실제 서버는 자기 규칙으로 정해요).
gantt.revertIntent(e.intentId);
}),
gantt.on('row-select', (e) => log({ ko: `행 선택: ${e.taskId ?? '없음'}`, en: `Row selected: ${e.taskId ?? 'none'}` })),
];
log({
ko: '막대를 끌어 옮기거나 끝을 늘여 보세요. 2026-11-02보다 앞으로 옮기면 서버가 거절해요',
en: 'Drag a bar or stretch its end. Moving before 2026-11-02 makes the server refuse',
});
return () => {
offs.forEach((off) => off());
gantt.destroy();
};
} 이 HTML은 추가 번들(위 script 태그)도 함께 불러오고 전역 변수로 써요. 별도 설치는 필요 없어요.
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>그리드 없는 간트 편집과 이벤트 기록</title>
</head>
<body>
<div id="grid" style="height: 460px"></div>
<link rel="stylesheet" href="https://cdn.maxmine.com/maxgrid/latest/maxgrid.gantt.css" />
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.gantt.min.js"></script>
<script>
const { createGantt } = MaxGridGantt;
// 편집을 켠 간트 차트(그리드 없음). 차트는 데이터를 스스로 바꾸지 않아요. 막대를 놓으면 intentId가 든 이벤트만 보내고,
// 호스트가 서버에 확인한 뒤 applyPatch로 확정하거나 revertIntent로 되돌려요. 여기서는 0.4초 걸리는 가짜 서버를 써요.
const data = {
tasks: [
{
id: '1',
parentId: null,
sortNo: 1,
name: '웹사이트 개편',
status: 'IN_PROGRESS',
plannedStart: '2026-11-02',
plannedEnd: '2027-01-29',
progressPct: 40,
isMilestone: false,
hasChildren: true,
calendarId: null,
version: 1,
},
{
id: '2',
parentId: '1',
sortNo: 1,
name: '디자인',
status: 'DONE',
plannedStart: '2026-11-02',
plannedEnd: '2026-11-20',
progressPct: 100,
isMilestone: false,
hasChildren: true,
calendarId: null,
version: 1,
},
{
id: '3',
parentId: '2',
sortNo: 1,
name: '와이어프레임',
status: 'DONE',
plannedStart: '2026-11-02',
plannedEnd: '2026-11-10',
progressPct: 100,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '4',
parentId: '2',
sortNo: 2,
name: '화면 디자인',
status: 'DONE',
plannedStart: '2026-11-11',
plannedEnd: '2026-11-20',
progressPct: 100,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '5',
parentId: '1',
sortNo: 2,
name: '개발',
status: 'IN_PROGRESS',
plannedStart: '2026-11-23',
plannedEnd: '2027-01-15',
progressPct: 30,
isMilestone: false,
hasChildren: true,
calendarId: null,
version: 1,
},
{
id: '6',
parentId: '5',
sortNo: 1,
name: '프런트엔드',
status: 'IN_PROGRESS',
plannedStart: '2026-11-23',
plannedEnd: '2026-12-18',
progressPct: 60,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '7',
parentId: '5',
sortNo: 2,
name: '백엔드',
status: 'IN_PROGRESS',
plannedStart: '2026-11-30',
plannedEnd: '2027-01-08',
progressPct: 20,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '8',
parentId: '5',
sortNo: 3,
name: '콘텐츠 이전',
status: 'ON_HOLD',
plannedStart: '2026-12-07',
plannedEnd: '2026-12-24',
progressPct: 0,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '9',
parentId: '5',
sortNo: 4,
name: '통합 시험',
status: 'TODO',
plannedStart: '2027-01-04',
plannedEnd: '2027-01-15',
progressPct: 0,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '10',
parentId: '1',
sortNo: 3,
name: '출시',
status: 'TODO',
plannedStart: '2027-01-29',
plannedEnd: '2027-01-29',
progressPct: 0,
isMilestone: true,
hasChildren: false,
calendarId: null,
version: 1,
},
],
dependencies: [
{ id: 'd1', predecessorId: '3', successorId: '4', depType: 'FS', lagDays: 0 },
{ id: 'd2', predecessorId: '4', successorId: '6', depType: 'FS', lagDays: 0 },
{ id: 'd3', predecessorId: '6', successorId: '9', depType: 'FS', lagDays: 0 },
{ id: 'd4', predecessorId: '9', successorId: '10', depType: 'FS', lagDays: 0 },
],
calendars: [{ id: 'c1', name: '표준', workDays: 31, isDefault: true, exceptions: [] }],
};
// 가짜 서버의 규칙: 프로젝트 시작(2026-11-02)보다 앞으로는 못 옮겨요(거절).
const PROJECT_START = '2026-11-02';
const fakeServer = (change) => new Promise((resolve) => setTimeout(() => resolve((change.plannedStart ?? PROJECT_START) < PROJECT_START ? 'refused' : 'ok'), 400));
function setup(host, log) {
const gantt = createGantt(host, {
ariaLabel: '프로젝트 일정',
locale: 'ko',
rowHeight: 32,
today: '2026-11-26',
editable: true,
});
gantt.setData(data);
const answer = async (intentId, taskId, change) => {
if ((await fakeServer(change)) === 'ok') {
gantt.applyPatch({ intentId, tasks: [{ id: taskId, ...change }] }); // 확정
log({ ko: `서버가 확정했어요: ${taskId}번`, en: `Server confirmed: task ${taskId}` });
}
else {
gantt.revertIntent(intentId); // 거절: 막대가 원래 자리로 돌아가요
log({
ko: `서버가 거절했어요: ${taskId}번, 막대를 되돌렸어요`,
en: `Server refused task ${taskId}; the bar was reverted`,
});
}
};
const offs = [
gantt.on('task-move', (e) => {
log({
ko: `옮기기: ${e.taskId}번, ${e.plannedStart} ~ ${e.plannedEnd}`,
en: `Move: task ${e.taskId}, ${e.plannedStart} to ${e.plannedEnd}`,
});
void answer(e.intentId, e.taskId, { plannedStart: e.plannedStart, plannedEnd: e.plannedEnd });
}),
gantt.on('task-resize', (e) => {
log({
ko: `늘이기·줄이기(${e.edge}): ${e.taskId}번, ${e.plannedStart} ~ ${e.plannedEnd}`,
en: `Resize (${e.edge}): task ${e.taskId}, ${e.plannedStart} to ${e.plannedEnd}`,
});
void answer(e.intentId, e.taskId, { plannedStart: e.plannedStart, plannedEnd: e.plannedEnd });
}),
gantt.on('task-progress', (e) => {
log({
ko: `진행률: ${e.taskId}번 ${e.progressPct}%`,
en: `Progress: task ${e.taskId} ${e.progressPct}%`,
});
void answer(e.intentId, e.taskId, { progressPct: e.progressPct });
}),
gantt.on('dependency-create', (e) => {
log({
ko: `의존 만들기: ${e.predecessorId} → ${e.successorId} (${e.depType})`,
en: `Link: ${e.predecessorId} to ${e.successorId} (${e.depType})`,
});
// 이 예제는 새 의존을 항상 거절해요(실제 서버는 자기 규칙으로 정해요).
gantt.revertIntent(e.intentId);
}),
gantt.on('row-select', (e) => log({ ko: `행 선택: ${e.taskId ?? '없음'}`, en: `Row selected: ${e.taskId ?? 'none'}` })),
];
log({
ko: '막대를 끌어 옮기거나 끝을 늘여 보세요. 2026-11-02보다 앞으로 옮기면 서버가 거절해요',
en: 'Drag a bar or stretch its end. Moving before 2026-11-02 makes the server refuse',
});
return () => {
offs.forEach((off) => off());
gantt.destroy();
};
}
setup(document.getElementById('grid'), console.log);
</script>
</body>
</html> This example needs an extra package. To run it locally, install with npm i maxgrid @maxgrid/gantt.
When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div id="grid" style="height: 460px"></div>
</div>
<script type="module" src="./main.js"></script>import { setup } from './example';
setup(document.getElementById('grid'), console.log);import { createGantt } from '@maxgrid/gantt';
// A Gantt chart with editing on (no grid). The chart never changes the data itself: when you drop a bar it only sends an event with an intentId,
// and the host asks the server, then confirms with applyPatch or refuses with revertIntent. Here a fake server answers after 0.4 s.
const data = {
tasks: [
{
id: '1',
parentId: null,
sortNo: 1,
name: 'Website relaunch',
status: 'IN_PROGRESS',
plannedStart: '2026-11-02',
plannedEnd: '2027-01-29',
progressPct: 40,
isMilestone: false,
hasChildren: true,
calendarId: null,
version: 1,
},
{
id: '2',
parentId: '1',
sortNo: 1,
name: 'Design',
status: 'DONE',
plannedStart: '2026-11-02',
plannedEnd: '2026-11-20',
progressPct: 100,
isMilestone: false,
hasChildren: true,
calendarId: null,
version: 1,
},
{
id: '3',
parentId: '2',
sortNo: 1,
name: 'Wireframes',
status: 'DONE',
plannedStart: '2026-11-02',
plannedEnd: '2026-11-10',
progressPct: 100,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '4',
parentId: '2',
sortNo: 2,
name: 'Visual design',
status: 'DONE',
plannedStart: '2026-11-11',
plannedEnd: '2026-11-20',
progressPct: 100,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '5',
parentId: '1',
sortNo: 2,
name: 'Build',
status: 'IN_PROGRESS',
plannedStart: '2026-11-23',
plannedEnd: '2027-01-15',
progressPct: 30,
isMilestone: false,
hasChildren: true,
calendarId: null,
version: 1,
},
{
id: '6',
parentId: '5',
sortNo: 1,
name: 'Frontend',
status: 'IN_PROGRESS',
plannedStart: '2026-11-23',
plannedEnd: '2026-12-18',
progressPct: 60,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '7',
parentId: '5',
sortNo: 2,
name: 'Backend',
status: 'IN_PROGRESS',
plannedStart: '2026-11-30',
plannedEnd: '2027-01-08',
progressPct: 20,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '8',
parentId: '5',
sortNo: 3,
name: 'Content migration',
status: 'ON_HOLD',
plannedStart: '2026-12-07',
plannedEnd: '2026-12-24',
progressPct: 0,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '9',
parentId: '5',
sortNo: 4,
name: 'Integration test',
status: 'TODO',
plannedStart: '2027-01-04',
plannedEnd: '2027-01-15',
progressPct: 0,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '10',
parentId: '1',
sortNo: 3,
name: 'Launch',
status: 'TODO',
plannedStart: '2027-01-29',
plannedEnd: '2027-01-29',
progressPct: 0,
isMilestone: true,
hasChildren: false,
calendarId: null,
version: 1,
},
],
dependencies: [
{ id: 'd1', predecessorId: '3', successorId: '4', depType: 'FS', lagDays: 0 },
{ id: 'd2', predecessorId: '4', successorId: '6', depType: 'FS', lagDays: 0 },
{ id: 'd3', predecessorId: '6', successorId: '9', depType: 'FS', lagDays: 0 },
{ id: 'd4', predecessorId: '9', successorId: '10', depType: 'FS', lagDays: 0 },
],
calendars: [{ id: 'c1', name: 'Standard', workDays: 31, isDefault: true, exceptions: [] }],
};
// The fake server's rule: nothing may start before the project start (2026-11-02); such a change is refused.
const PROJECT_START = '2026-11-02';
const fakeServer = (change) => new Promise((resolve) => setTimeout(() => resolve((change.plannedStart ?? PROJECT_START) < PROJECT_START ? 'refused' : 'ok'), 400));
export function setup(host, log) {
const gantt = createGantt(host, {
ariaLabel: 'Project plan',
locale: 'en',
rowHeight: 32,
today: '2026-11-26',
editable: true,
});
gantt.setData(data);
const answer = async (intentId, taskId, change) => {
if ((await fakeServer(change)) === 'ok') {
gantt.applyPatch({ intentId, tasks: [{ id: taskId, ...change }] }); // confirm
log(`Server confirmed: task ${taskId}`);
}
else {
gantt.revertIntent(intentId); // refused: the bar goes back
log(`Server refused task ${taskId}; the bar was reverted`);
}
};
const offs = [
gantt.on('task-move', (e) => {
log(`Move: task ${e.taskId}, ${e.plannedStart} to ${e.plannedEnd}`);
void answer(e.intentId, e.taskId, { plannedStart: e.plannedStart, plannedEnd: e.plannedEnd });
}),
gantt.on('task-resize', (e) => {
log(`Resize (${e.edge}): task ${e.taskId}, ${e.plannedStart} to ${e.plannedEnd}`);
void answer(e.intentId, e.taskId, { plannedStart: e.plannedStart, plannedEnd: e.plannedEnd });
}),
gantt.on('task-progress', (e) => {
log(`Progress: task ${e.taskId} ${e.progressPct}%`);
void answer(e.intentId, e.taskId, { progressPct: e.progressPct });
}),
gantt.on('dependency-create', (e) => {
log(`Link: ${e.predecessorId} to ${e.successorId} (${e.depType})`);
// This example refuses every new link (a real server applies its own rules).
gantt.revertIntent(e.intentId);
}),
gantt.on('row-select', (e) => log(`Row selected: ${e.taskId ?? 'none'}`)),
];
log('Drag a bar or stretch its end. Moving before 2026-11-02 makes the server refuse');
return () => {
offs.forEach((off) => off());
gantt.destroy();
};
}This HTML also loads an extra bundle (the extra script tag above) and uses it as a global. No install is needed.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Gantt editing without a grid, with an event log</title>
</head>
<body>
<div id="grid" style="height: 460px"></div>
<link rel="stylesheet" href="https://cdn.maxmine.com/maxgrid/latest/maxgrid.gantt.css" />
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.gantt.min.js"></script>
<script>
const { createGantt } = MaxGridGantt;
// A Gantt chart with editing on (no grid). The chart never changes the data itself: when you drop a bar it only sends an event with an intentId,
// and the host asks the server, then confirms with applyPatch or refuses with revertIntent. Here a fake server answers after 0.4 s.
const data = {
tasks: [
{
id: '1',
parentId: null,
sortNo: 1,
name: 'Website relaunch',
status: 'IN_PROGRESS',
plannedStart: '2026-11-02',
plannedEnd: '2027-01-29',
progressPct: 40,
isMilestone: false,
hasChildren: true,
calendarId: null,
version: 1,
},
{
id: '2',
parentId: '1',
sortNo: 1,
name: 'Design',
status: 'DONE',
plannedStart: '2026-11-02',
plannedEnd: '2026-11-20',
progressPct: 100,
isMilestone: false,
hasChildren: true,
calendarId: null,
version: 1,
},
{
id: '3',
parentId: '2',
sortNo: 1,
name: 'Wireframes',
status: 'DONE',
plannedStart: '2026-11-02',
plannedEnd: '2026-11-10',
progressPct: 100,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '4',
parentId: '2',
sortNo: 2,
name: 'Visual design',
status: 'DONE',
plannedStart: '2026-11-11',
plannedEnd: '2026-11-20',
progressPct: 100,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '5',
parentId: '1',
sortNo: 2,
name: 'Build',
status: 'IN_PROGRESS',
plannedStart: '2026-11-23',
plannedEnd: '2027-01-15',
progressPct: 30,
isMilestone: false,
hasChildren: true,
calendarId: null,
version: 1,
},
{
id: '6',
parentId: '5',
sortNo: 1,
name: 'Frontend',
status: 'IN_PROGRESS',
plannedStart: '2026-11-23',
plannedEnd: '2026-12-18',
progressPct: 60,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '7',
parentId: '5',
sortNo: 2,
name: 'Backend',
status: 'IN_PROGRESS',
plannedStart: '2026-11-30',
plannedEnd: '2027-01-08',
progressPct: 20,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '8',
parentId: '5',
sortNo: 3,
name: 'Content migration',
status: 'ON_HOLD',
plannedStart: '2026-12-07',
plannedEnd: '2026-12-24',
progressPct: 0,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '9',
parentId: '5',
sortNo: 4,
name: 'Integration test',
status: 'TODO',
plannedStart: '2027-01-04',
plannedEnd: '2027-01-15',
progressPct: 0,
isMilestone: false,
hasChildren: false,
calendarId: null,
version: 1,
},
{
id: '10',
parentId: '1',
sortNo: 3,
name: 'Launch',
status: 'TODO',
plannedStart: '2027-01-29',
plannedEnd: '2027-01-29',
progressPct: 0,
isMilestone: true,
hasChildren: false,
calendarId: null,
version: 1,
},
],
dependencies: [
{ id: 'd1', predecessorId: '3', successorId: '4', depType: 'FS', lagDays: 0 },
{ id: 'd2', predecessorId: '4', successorId: '6', depType: 'FS', lagDays: 0 },
{ id: 'd3', predecessorId: '6', successorId: '9', depType: 'FS', lagDays: 0 },
{ id: 'd4', predecessorId: '9', successorId: '10', depType: 'FS', lagDays: 0 },
],
calendars: [{ id: 'c1', name: 'Standard', workDays: 31, isDefault: true, exceptions: [] }],
};
// The fake server's rule: nothing may start before the project start (2026-11-02); such a change is refused.
const PROJECT_START = '2026-11-02';
const fakeServer = (change) => new Promise((resolve) => setTimeout(() => resolve((change.plannedStart ?? PROJECT_START) < PROJECT_START ? 'refused' : 'ok'), 400));
function setup(host, log) {
const gantt = createGantt(host, {
ariaLabel: 'Project plan',
locale: 'en',
rowHeight: 32,
today: '2026-11-26',
editable: true,
});
gantt.setData(data);
const answer = async (intentId, taskId, change) => {
if ((await fakeServer(change)) === 'ok') {
gantt.applyPatch({ intentId, tasks: [{ id: taskId, ...change }] }); // confirm
log(`Server confirmed: task ${taskId}`);
}
else {
gantt.revertIntent(intentId); // refused: the bar goes back
log(`Server refused task ${taskId}; the bar was reverted`);
}
};
const offs = [
gantt.on('task-move', (e) => {
log(`Move: task ${e.taskId}, ${e.plannedStart} to ${e.plannedEnd}`);
void answer(e.intentId, e.taskId, { plannedStart: e.plannedStart, plannedEnd: e.plannedEnd });
}),
gantt.on('task-resize', (e) => {
log(`Resize (${e.edge}): task ${e.taskId}, ${e.plannedStart} to ${e.plannedEnd}`);
void answer(e.intentId, e.taskId, { plannedStart: e.plannedStart, plannedEnd: e.plannedEnd });
}),
gantt.on('task-progress', (e) => {
log(`Progress: task ${e.taskId} ${e.progressPct}%`);
void answer(e.intentId, e.taskId, { progressPct: e.progressPct });
}),
gantt.on('dependency-create', (e) => {
log(`Link: ${e.predecessorId} to ${e.successorId} (${e.depType})`);
// This example refuses every new link (a real server applies its own rules).
gantt.revertIntent(e.intentId);
}),
gantt.on('row-select', (e) => log(`Row selected: ${e.taskId ?? 'none'}`)),
];
log('Drag a bar or stretch its end. Moving before 2026-11-02 makes the server refuse');
return () => {
offs.forEach((off) => off());
gantt.destroy();
};
}
setup(document.getElementById('grid'), console.log);
</script>
</body>
</html>