akfatimeline 1.0.0
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/README.md +924 -0
- package/babel.config.json +4 -0
- package/package.json +50 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/src/App copy.js +185 -0
- package/src/App.css +38 -0
- package/src/App.js +201 -0
- package/src/App.test.js +8 -0
- package/src/components/Timeline/DragAndDropHandler.js +35 -0
- package/src/components/Timeline/EventTooltip.js +206 -0
- package/src/components/Timeline/Indicator.js +30 -0
- package/src/components/Timeline/MasterHeader.js +55 -0
- package/src/components/Timeline/Resources.js +53 -0
- package/src/components/Timeline/ResourcesHeader.js +14 -0
- package/src/components/Timeline/Timeline.css +534 -0
- package/src/components/Timeline/Timeline.js +277 -0
- package/src/components/Timeline/TimelineCell.js +8 -0
- package/src/components/Timeline/TimelineContent copy.js +421 -0
- package/src/components/Timeline/TimelineContent.js +422 -0
- package/src/components/Timeline/TimelineEvents.js +114 -0
- package/src/components/Timeline/TimelineHeader.js +43 -0
- package/src/components/Timeline/TimelineMonthContainer.js +29 -0
- package/src/components/Timeline/TimelineResources.js +16 -0
- package/src/dist/Timeline.js +277 -0
- package/src/hooks/useDragAndDrop.js +80 -0
- package/src/hooks/useEventDragDrop.js +120 -0
- package/src/hooks/useExtendEvent.js +28 -0
- package/src/index.css +13 -0
- package/src/index.js +17 -0
- package/src/logo.svg +1 -0
- package/src/reportWebVitals.js +13 -0
- package/src/setupTests.js +5 -0
- package/src/utils/HorizontalVirtualScroll.js +0 -0
- package/src/utils/dateUtils.js +36 -0
- package/src/utils/filterTimelineData.js +21 -0
- package/src/utils/timelineUtils.js +40 -0
- package/webpack.config.js +31 -0
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from "react";
|
|
2
|
+
import { parseDate } from "../../utils/dateUtils";
|
|
3
|
+
import useDragAndDrop from "../../hooks/useDragAndDrop";
|
|
4
|
+
import useEventDragDrop from "../../hooks/useEventDragDrop";
|
|
5
|
+
import Indicator from "./Indicator";
|
|
6
|
+
import useExtendEvent from "../../hooks/useExtendEvent";
|
|
7
|
+
// import "./Timeline.css"; // varsayalım "Timeline.css" globalde import ediliyor
|
|
8
|
+
|
|
9
|
+
const TimelineContent = ({
|
|
10
|
+
groupedResources,
|
|
11
|
+
dates,
|
|
12
|
+
collapsedGroups,
|
|
13
|
+
events,
|
|
14
|
+
setEvents,
|
|
15
|
+
onEventClick,
|
|
16
|
+
todayIndex,
|
|
17
|
+
indicatorOn,
|
|
18
|
+
resourceSettings,
|
|
19
|
+
setDropInfo,
|
|
20
|
+
|
|
21
|
+
// Yeni prop'lar
|
|
22
|
+
eventsDragOn = true,
|
|
23
|
+
eventsExtendOn = true,
|
|
24
|
+
createNewEventOn = true,
|
|
25
|
+
onDragInfo,
|
|
26
|
+
onExtendInfo,
|
|
27
|
+
onCreateEventInfo,
|
|
28
|
+
onEventRightClick,
|
|
29
|
+
}) => {
|
|
30
|
+
// ------------------- HOOKS & STATE -------------------
|
|
31
|
+
const containerRef = useRef(null);
|
|
32
|
+
|
|
33
|
+
// Drag
|
|
34
|
+
const { isDragging, dragStart, dragEnd } = useDragAndDrop(events, setEvents);
|
|
35
|
+
const { handleDragStart, handleDragOver, handleDrop, handleDragEnd } =
|
|
36
|
+
useEventDragDrop(events, setEvents, setDropInfo);
|
|
37
|
+
|
|
38
|
+
// Extend
|
|
39
|
+
const { extendEvent } = useExtendEvent(events, setEvents);
|
|
40
|
+
const [mode, setMode] = useState(null); // null | "extend"
|
|
41
|
+
const [extendingEvent, setExtendingEvent] = useState(null);
|
|
42
|
+
const [originalEndDate, setOriginalEndDate] = useState(null);
|
|
43
|
+
const [startMouseX, setStartMouseX] = useState(null);
|
|
44
|
+
|
|
45
|
+
// Create new event
|
|
46
|
+
const [isCreating, setIsCreating] = useState(false);
|
|
47
|
+
const [tempEvent, setTempEvent] = useState(null);
|
|
48
|
+
|
|
49
|
+
// Tooltip
|
|
50
|
+
const [selectedEvent, setSelectedEvent] = useState(null);
|
|
51
|
+
const [tooltipPosition, setTooltipPosition] = useState({ top: 0, left: 0 });
|
|
52
|
+
|
|
53
|
+
const totalDays = dates.length;
|
|
54
|
+
|
|
55
|
+
// ------------------- Tooltip Logic -------------------
|
|
56
|
+
const handleEventClickInternal = (event, e) => {
|
|
57
|
+
e.stopPropagation();
|
|
58
|
+
// Harici callback
|
|
59
|
+
if (onEventClick) onEventClick(event, e);
|
|
60
|
+
|
|
61
|
+
// Tooltip göstermek
|
|
62
|
+
const eventElement = e.currentTarget;
|
|
63
|
+
if (eventElement) {
|
|
64
|
+
const rect = eventElement.getBoundingClientRect();
|
|
65
|
+
setTooltipPosition({
|
|
66
|
+
top: rect.top + window.scrollY,
|
|
67
|
+
left: rect.left + rect.width / 2 + window.scrollX,
|
|
68
|
+
});
|
|
69
|
+
setSelectedEvent(event);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const handleCloseTooltip = () => {
|
|
74
|
+
setSelectedEvent(null);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// ------------------- Create New Event -------------------
|
|
78
|
+
const handleCellClick = (resourceId, date) => {
|
|
79
|
+
if (!createNewEventOn) return; // create devrede değilse
|
|
80
|
+
|
|
81
|
+
const startDate = parseDate(date.fullDate);
|
|
82
|
+
const newEvent = {
|
|
83
|
+
id: Date.now(),
|
|
84
|
+
title: "1 Gece",
|
|
85
|
+
startDate,
|
|
86
|
+
endDate: new Date(startDate.getTime() + 24 * 60 * 60 * 1000),
|
|
87
|
+
resourceId,
|
|
88
|
+
// color => var(--timeline-new-event-background-color) => => Sonra inline style yerine className
|
|
89
|
+
color: "", // Bunu .css’te "var(--timeline-new-event-background-color)" atayabilirsin
|
|
90
|
+
};
|
|
91
|
+
setTempEvent(newEvent);
|
|
92
|
+
setIsCreating(true);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (!createNewEventOn) return;
|
|
97
|
+
if (!isCreating) return;
|
|
98
|
+
if (mode === "extend") {
|
|
99
|
+
console.log(">>> 'extend' mode, skip new event creation");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const handleMouseMove = (e) => {
|
|
104
|
+
if (!isCreating || !tempEvent) return;
|
|
105
|
+
const cell = document.elementFromPoint(e.clientX, e.clientY);
|
|
106
|
+
const cellW = cell?.offsetWidth || 30;
|
|
107
|
+
|
|
108
|
+
const startX = tempEvent.startX || e.clientX;
|
|
109
|
+
const deltaX = e.clientX - startX;
|
|
110
|
+
const daysToAdd = Math.max(1, Math.floor(deltaX / cellW));
|
|
111
|
+
|
|
112
|
+
const newEndDate = new Date(tempEvent.startDate.getTime());
|
|
113
|
+
newEndDate.setDate(newEndDate.getDate() + daysToAdd);
|
|
114
|
+
|
|
115
|
+
setTempEvent({
|
|
116
|
+
...tempEvent,
|
|
117
|
+
endDate: newEndDate,
|
|
118
|
+
startX: startX,
|
|
119
|
+
title: `${daysToAdd} Gece`,
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const handleMouseUp = () => {
|
|
124
|
+
if (isCreating && tempEvent) {
|
|
125
|
+
setEvents([...events, tempEvent]);
|
|
126
|
+
if (onCreateEventInfo) {
|
|
127
|
+
onCreateEventInfo(tempEvent);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
setTempEvent(null);
|
|
131
|
+
setIsCreating(false);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
135
|
+
window.addEventListener("mouseup", handleMouseUp);
|
|
136
|
+
|
|
137
|
+
return () => {
|
|
138
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
139
|
+
window.removeEventListener("mouseup", handleMouseUp);
|
|
140
|
+
};
|
|
141
|
+
}, [createNewEventOn, isCreating, mode, tempEvent, events, onCreateEventInfo, setEvents]);
|
|
142
|
+
|
|
143
|
+
// ------------------- Drag Logic -------------------
|
|
144
|
+
const handleDragStartSafe = (e, eventId) => {
|
|
145
|
+
if (!eventsDragOn) {
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
handleDragStart(e, eventId);
|
|
150
|
+
};
|
|
151
|
+
const handleDragEndSafe = (e) => {
|
|
152
|
+
if (!eventsDragOn) {
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
handleDragEnd();
|
|
157
|
+
// onDragInfo(...) => if needed
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// ------------------- Extend Logic -------------------
|
|
161
|
+
const handleMouseDownExtend = (mouseEvent, event) => {
|
|
162
|
+
if (!eventsExtendOn) return;
|
|
163
|
+
mouseEvent.stopPropagation();
|
|
164
|
+
console.log(">>> Extend start ID:", event.id);
|
|
165
|
+
setMode("extend");
|
|
166
|
+
setExtendingEvent(event);
|
|
167
|
+
setOriginalEndDate(event.endDate);
|
|
168
|
+
setStartMouseX(mouseEvent.clientX);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const handleMouseMoveExtend = (e) => {
|
|
172
|
+
if (mode !== "extend" || !extendingEvent) return;
|
|
173
|
+
if (!eventsExtendOn) return;
|
|
174
|
+
|
|
175
|
+
const currentMouseX = e.clientX;
|
|
176
|
+
const deltaX = currentMouseX - (startMouseX ?? 0);
|
|
177
|
+
const cellW = 30;
|
|
178
|
+
const daysToAdd = Math.floor(deltaX / cellW);
|
|
179
|
+
|
|
180
|
+
const newEndDate = new Date((originalEndDate ?? new Date()).getTime());
|
|
181
|
+
newEndDate.setDate(newEndDate.getDate() + daysToAdd);
|
|
182
|
+
|
|
183
|
+
console.log(">>> Extending ID:", extendingEvent.id, "=>", newEndDate);
|
|
184
|
+
|
|
185
|
+
setEvents((prev) =>
|
|
186
|
+
prev.map((evt) => (evt.id === extendingEvent.id ? { ...evt, endDate: newEndDate } : evt))
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const handleMouseUpExtend = () => {
|
|
191
|
+
console.log(">>> Extend finished ID:", extendingEvent?.id);
|
|
192
|
+
if (onExtendInfo && extendingEvent) {
|
|
193
|
+
// callback
|
|
194
|
+
const updatedEvent = events.find((ev) => ev.id === extendingEvent.id);
|
|
195
|
+
if (updatedEvent) {
|
|
196
|
+
onExtendInfo({
|
|
197
|
+
eventId: extendingEvent.id,
|
|
198
|
+
newEndDate: updatedEvent.endDate,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
setMode(null);
|
|
203
|
+
setExtendingEvent(null);
|
|
204
|
+
setOriginalEndDate(null);
|
|
205
|
+
setStartMouseX(null);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
if (mode === "extend") {
|
|
210
|
+
const onMove = (e) => handleMouseMoveExtend(e);
|
|
211
|
+
const onUp = () => handleMouseUpExtend();
|
|
212
|
+
document.addEventListener("mousemove", onMove);
|
|
213
|
+
document.addEventListener("mouseup", onUp);
|
|
214
|
+
return () => {
|
|
215
|
+
document.removeEventListener("mousemove", onMove);
|
|
216
|
+
document.removeEventListener("mouseup", onUp);
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}, [mode, extendingEvent, eventsExtendOn, originalEndDate, startMouseX]);
|
|
220
|
+
|
|
221
|
+
// ------------------- Right Click (context) -------------------
|
|
222
|
+
const handleRightClickEvent = (evt, reactEvent) => {
|
|
223
|
+
reactEvent.preventDefault();
|
|
224
|
+
if (onEventRightClick) onEventRightClick(evt, reactEvent);
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// ------------------- Helper isCellSelected -------------------
|
|
228
|
+
const isCellSelected = (resourceId, date) => {
|
|
229
|
+
if (!dragStart || !dragEnd) return false;
|
|
230
|
+
if (resourceId !== dragStart.resourceId) return false;
|
|
231
|
+
|
|
232
|
+
const startIndex = dates.findIndex((d) => parseDate(d.fullDate).getTime() === parseDate(dragStart.date).getTime());
|
|
233
|
+
const endIndex = dates.findIndex((d) => parseDate(d.fullDate).getTime() === parseDate(dragEnd.date).getTime());
|
|
234
|
+
const currentIndex = dates.findIndex((d) => parseDate(d.fullDate).getTime() === parseDate(date.fullDate).getTime());
|
|
235
|
+
|
|
236
|
+
if (startIndex === -1 || endIndex === -1 || currentIndex === -1) return false;
|
|
237
|
+
|
|
238
|
+
return currentIndex >= Math.min(startIndex, endIndex) && currentIndex <= Math.max(startIndex, endIndex);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// ------------------- calculatePosition -------------------
|
|
242
|
+
const calculatePosition = (ev, dateArr) => {
|
|
243
|
+
const startDate = parseDate(ev.startDate);
|
|
244
|
+
const endDate = parseDate(ev.endDate);
|
|
245
|
+
|
|
246
|
+
const startIndex = dateArr.findIndex((d) => parseDate(d.fullDate).toDateString() === startDate.toDateString());
|
|
247
|
+
const endIndex = dateArr.findIndex((d) => parseDate(d.fullDate).toDateString() === endDate.toDateString());
|
|
248
|
+
|
|
249
|
+
const totalDays = dateArr.length;
|
|
250
|
+
if (startIndex < 0 && endIndex < 0) {
|
|
251
|
+
return { isVisible: false, left: 0, width: 0, isPartialStart: false, isPartialEnd: false };
|
|
252
|
+
}
|
|
253
|
+
if (startIndex >= totalDays && endIndex >= totalDays) {
|
|
254
|
+
return { isVisible: false, left: 0, width: 0, isPartialStart: false, isPartialEnd: false };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const effectiveStartIndex = Math.max(startIndex, 0);
|
|
258
|
+
const effectiveEndIndex = Math.min(endIndex, totalDays - 1);
|
|
259
|
+
|
|
260
|
+
const isPartialStart = startIndex < 0;
|
|
261
|
+
const isPartialEnd = endIndex >= totalDays;
|
|
262
|
+
|
|
263
|
+
const leftPercentage = ((effectiveStartIndex + (isPartialStart ? 0 : 0.5)) / totalDays) * 100;
|
|
264
|
+
const rightPercentage = ((effectiveEndIndex + (isPartialEnd ? 1 : 0.5)) / totalDays) * 100;
|
|
265
|
+
const widthPercentage = rightPercentage - leftPercentage;
|
|
266
|
+
|
|
267
|
+
return {
|
|
268
|
+
isVisible: true,
|
|
269
|
+
left: `${leftPercentage}%`,
|
|
270
|
+
width: `${widthPercentage}%`,
|
|
271
|
+
isPartialStart,
|
|
272
|
+
isPartialEnd,
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// ------------------- RENDER -------------------
|
|
277
|
+
return (
|
|
278
|
+
<div
|
|
279
|
+
ref={containerRef}
|
|
280
|
+
className="timeline-content-container" // Yeni class, stilini timeline.css'e ekleyebilirsin
|
|
281
|
+
>
|
|
282
|
+
{indicatorOn && (
|
|
283
|
+
<Indicator todayIndex={todayIndex} totalDays={totalDays} />
|
|
284
|
+
)}
|
|
285
|
+
|
|
286
|
+
{groupedResources.map((group, groupIndex) => (
|
|
287
|
+
<div key={groupIndex} className="timeline-group-container">
|
|
288
|
+
{/* Grup Başlığı */}
|
|
289
|
+
{resourceSettings.isGrouped && (
|
|
290
|
+
<div className="timeline-group-header-row">
|
|
291
|
+
{dates.map((dateObj, colIndex) => (
|
|
292
|
+
<div
|
|
293
|
+
key={`group-header-${groupIndex}-${colIndex}`}
|
|
294
|
+
className="timeline-group-header-cell"
|
|
295
|
+
></div>
|
|
296
|
+
))}
|
|
297
|
+
</div>
|
|
298
|
+
)}
|
|
299
|
+
|
|
300
|
+
{/* Kaynaklar */}
|
|
301
|
+
{!collapsedGroups[group.groupName] &&
|
|
302
|
+
group.resources.map((resource, rowIndex) => {
|
|
303
|
+
const resourceEvents = events.filter((ev) => ev.resourceId === resource.id);
|
|
304
|
+
|
|
305
|
+
return (
|
|
306
|
+
<div key={resource.id} className="timeline-resource-row">
|
|
307
|
+
{/* Her resource row'u */}
|
|
308
|
+
{resourceEvents.map((event) => {
|
|
309
|
+
const { isVisible, left, width, isPartialStart, isPartialEnd } =
|
|
310
|
+
calculatePosition(event, dates);
|
|
311
|
+
if (!isVisible) return null;
|
|
312
|
+
|
|
313
|
+
return (
|
|
314
|
+
<div
|
|
315
|
+
key={event.id}
|
|
316
|
+
className="timeline-event"
|
|
317
|
+
draggable={mode !== "extend" && eventsDragOn}
|
|
318
|
+
onDragStart={(e) => {
|
|
319
|
+
if (mode === "extend") {
|
|
320
|
+
e.preventDefault();
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
handleDragStartSafe(e, event.id);
|
|
324
|
+
}}
|
|
325
|
+
onDragEnd={(e) => {
|
|
326
|
+
if (mode === "extend") {
|
|
327
|
+
e.preventDefault();
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
handleDragEndSafe(e);
|
|
331
|
+
}}
|
|
332
|
+
onContextMenu={(reactEvent) => handleRightClickEvent(event, reactEvent)}
|
|
333
|
+
onClick={(ev) => handleEventClickInternal(event, ev)}
|
|
334
|
+
style={{
|
|
335
|
+
left,
|
|
336
|
+
width,
|
|
337
|
+
top: "5px",
|
|
338
|
+
// color from var(--timeline-event-text-color)
|
|
339
|
+
// background from event.color or var(...) => if event.color empty, fallback in CSS
|
|
340
|
+
borderTopLeftRadius: isPartialStart ? "0px" : "20px",
|
|
341
|
+
borderBottomLeftRadius: isPartialStart ? "0px" : "20px",
|
|
342
|
+
borderTopRightRadius: isPartialEnd ? "0px" : "20px",
|
|
343
|
+
borderBottomRightRadius: isPartialEnd ? "0px" : "20px",
|
|
344
|
+
cursor: mode === "extend" ? "col-resize" : "grab",
|
|
345
|
+
}}
|
|
346
|
+
>
|
|
347
|
+
{event.title}
|
|
348
|
+
{eventsExtendOn && (
|
|
349
|
+
<div
|
|
350
|
+
className="timeline-event-extend-handle"
|
|
351
|
+
onMouseDown={(mouseEvent) => {
|
|
352
|
+
mouseEvent.stopPropagation();
|
|
353
|
+
handleMouseDownExtend(mouseEvent, event);
|
|
354
|
+
}}
|
|
355
|
+
></div>
|
|
356
|
+
)}
|
|
357
|
+
</div>
|
|
358
|
+
);
|
|
359
|
+
})}
|
|
360
|
+
|
|
361
|
+
{/* Geçici (yeni) event */}
|
|
362
|
+
{tempEvent && tempEvent.resourceId === resource.id && (
|
|
363
|
+
<div
|
|
364
|
+
className="timeline-temp-event"
|
|
365
|
+
style={{
|
|
366
|
+
...calculatePosition(tempEvent, dates),
|
|
367
|
+
top: "5px",
|
|
368
|
+
}}
|
|
369
|
+
>
|
|
370
|
+
{tempEvent.title}
|
|
371
|
+
</div>
|
|
372
|
+
)}
|
|
373
|
+
|
|
374
|
+
{/* Tarih Hücreleri */}
|
|
375
|
+
{dates.map((dateObj, colIndex) => (
|
|
376
|
+
<div
|
|
377
|
+
key={`cell-${groupIndex}-${rowIndex}-${colIndex}`}
|
|
378
|
+
className={`timeline-cell ${
|
|
379
|
+
isCellSelected(resource.id, dateObj) ? "selected" : ""
|
|
380
|
+
}`}
|
|
381
|
+
data-date={JSON.stringify(dateObj)}
|
|
382
|
+
data-resource-id={resource.id}
|
|
383
|
+
onMouseDown={() => handleCellClick(resource.id, dateObj)}
|
|
384
|
+
onDragOver={(e) => handleDragOver(e)}
|
|
385
|
+
onDrop={(e) =>
|
|
386
|
+
handleDrop(e, resource.id, parseDate(dateObj.fullDate))
|
|
387
|
+
}
|
|
388
|
+
></div>
|
|
389
|
+
))}
|
|
390
|
+
</div>
|
|
391
|
+
);
|
|
392
|
+
})}
|
|
393
|
+
</div>
|
|
394
|
+
))}
|
|
395
|
+
|
|
396
|
+
{/* Tooltip vb. */}
|
|
397
|
+
{selectedEvent && (
|
|
398
|
+
// "timeline-event-tooltip" gibi className tanımlanabilir
|
|
399
|
+
// eğer custom css istenirse
|
|
400
|
+
<div
|
|
401
|
+
style={{
|
|
402
|
+
position: "absolute",
|
|
403
|
+
top: tooltipPosition.top,
|
|
404
|
+
left: tooltipPosition.left,
|
|
405
|
+
// ...
|
|
406
|
+
backgroundColor: "#333",
|
|
407
|
+
color: "#fff",
|
|
408
|
+
padding: "5px",
|
|
409
|
+
borderRadius: "4px",
|
|
410
|
+
zIndex: 999,
|
|
411
|
+
}}
|
|
412
|
+
>
|
|
413
|
+
<button onClick={() => handleCloseTooltip()}>X</button>
|
|
414
|
+
{/* Content */}
|
|
415
|
+
{selectedEvent.title}
|
|
416
|
+
</div>
|
|
417
|
+
)}
|
|
418
|
+
</div>
|
|
419
|
+
);
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
export default TimelineContent;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// src/components/Timeline/TimelineEvents.js
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { isDateInRange, parseDate } from "../../utils/dateUtils";
|
|
4
|
+
|
|
5
|
+
const TimelineEvents = ({ date, events, resourceId, onDelete }) => {
|
|
6
|
+
// Gelen tüm props'ları kontrol et
|
|
7
|
+
console.log("TimelineEvents Props:", { date, events, resourceId, onDelete });
|
|
8
|
+
|
|
9
|
+
const dateToCompare = date?.fullDate;
|
|
10
|
+
|
|
11
|
+
if (!dateToCompare) {
|
|
12
|
+
console.error("Hata: date.fullDate değeri tanımlı değil.");
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (!Array.isArray(events)) {
|
|
17
|
+
console.error("Hata: events bir dizi değil.", events);
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!resourceId) {
|
|
22
|
+
console.error("Hata: resourceId değeri tanımlı değil.");
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Event'leri filtrele: Tarih aralığı ve resource eşleşmesi ile
|
|
27
|
+
const filteredEvents = events.filter((event) => {
|
|
28
|
+
const isMatch =
|
|
29
|
+
event.resourceId === resourceId &&
|
|
30
|
+
isDateInRange(dateToCompare, event.startDate, event.endDate);
|
|
31
|
+
console.log(
|
|
32
|
+
"Event Filtering:",
|
|
33
|
+
{
|
|
34
|
+
event,
|
|
35
|
+
dateToCompare,
|
|
36
|
+
isMatch,
|
|
37
|
+
resourceId,
|
|
38
|
+
startDate: event.startDate,
|
|
39
|
+
endDate: event.endDate,
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
return isMatch;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
console.log("Filtered Events for Resource:", { resourceId, filteredEvents });
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div style={{ position: "relative", height: "100%", width: "100%" }}>
|
|
49
|
+
{filteredEvents.map((event) => {
|
|
50
|
+
const eventStartDate = parseDate(event.startDate);
|
|
51
|
+
const eventEndDate = parseDate(event.endDate);
|
|
52
|
+
|
|
53
|
+
if (!eventStartDate || !eventEndDate) {
|
|
54
|
+
console.error("Hata: Etkinlik başlangıç veya bitiş tarihi hatalı.", {
|
|
55
|
+
event,
|
|
56
|
+
});
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const durationInDays = Math.floor(
|
|
61
|
+
(eventEndDate - eventStartDate) / (24 * 60 * 60 * 1000) + 1
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
key={event.id}
|
|
67
|
+
onClick={(e) => {
|
|
68
|
+
e.stopPropagation(); // Sürükleme işlemini engelle
|
|
69
|
+
if (window.confirm(`\"${event.title}\" etkinliğini silmek istiyor musun?`)) {
|
|
70
|
+
onDelete(event.id);
|
|
71
|
+
}
|
|
72
|
+
}}
|
|
73
|
+
style={{
|
|
74
|
+
position: "absolute",
|
|
75
|
+
top: "5px", // Üstten biraz boşluk
|
|
76
|
+
left: "5px", // Soldan biraz boşluk
|
|
77
|
+
width: `calc(${durationInDays * 100}% - 10px)`, // Sağdan ve soldan 5px boşluk için 10px çıkarıldı
|
|
78
|
+
height: `calc(100% - 10px)`, // Alttan ve üstten 5px boşluk için 10px çıkarıldı
|
|
79
|
+
backgroundColor: event.color,
|
|
80
|
+
color: "#fff",
|
|
81
|
+
fontSize: "14px",
|
|
82
|
+
padding: "5px 10px",
|
|
83
|
+
borderRadius: "6px",
|
|
84
|
+
textAlign: "left",
|
|
85
|
+
display: "flex",
|
|
86
|
+
alignItems: "center",
|
|
87
|
+
boxSizing: "border-box",
|
|
88
|
+
zIndex: 10,
|
|
89
|
+
overflow: "hidden",
|
|
90
|
+
textOverflow: "ellipsis",
|
|
91
|
+
whiteSpace: "nowrap",
|
|
92
|
+
border: "1px solid #fff",
|
|
93
|
+
cursor: "pointer",
|
|
94
|
+
boxShadow: "0 2px 6px rgba(0, 0, 0, 0.15)",
|
|
95
|
+
transition: "transform 0.2s ease, box-shadow 0.2s ease",
|
|
96
|
+
}}
|
|
97
|
+
onMouseOver={(e) => {
|
|
98
|
+
e.currentTarget.style.transform = "scale(1.02)";
|
|
99
|
+
e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.3)";
|
|
100
|
+
}}
|
|
101
|
+
onMouseOut={(e) => {
|
|
102
|
+
e.currentTarget.style.transform = "scale(1)";
|
|
103
|
+
e.currentTarget.style.boxShadow = "0 2px 6px rgba(0, 0, 0, 0.15)";
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
{event.title}
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
})}
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default TimelineEvents;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./Timeline.css"; // CSS dosyasını import etmeyi unutma
|
|
3
|
+
|
|
4
|
+
const TimelineHeader = ({ dates, monthHeaders }) => {
|
|
5
|
+
return (
|
|
6
|
+
<div className="timeline-header-container">
|
|
7
|
+
{/* Ay ve Yıl Başlıkları */}
|
|
8
|
+
<div className="timeline-header-month-row">
|
|
9
|
+
{monthHeaders.map((monthHeader, index) => (
|
|
10
|
+
<div
|
|
11
|
+
key={index}
|
|
12
|
+
className="timeline-header-month-cell"
|
|
13
|
+
style={{
|
|
14
|
+
flex: monthHeader.endIndex - monthHeader.startIndex + 1,
|
|
15
|
+
borderRight:
|
|
16
|
+
index < monthHeaders.length - 1 ? "1px solid var(--border-color)" : "none",
|
|
17
|
+
}}
|
|
18
|
+
>
|
|
19
|
+
{monthHeader.monthName} {monthHeader.year}
|
|
20
|
+
</div>
|
|
21
|
+
))}
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
{/* Günlük Hücreler */}
|
|
25
|
+
<div className="timeline-header-day-row">
|
|
26
|
+
{dates.map((date, index) => (
|
|
27
|
+
<div
|
|
28
|
+
key={index}
|
|
29
|
+
className="timeline-header-day-cell"
|
|
30
|
+
style={{
|
|
31
|
+
flex: 1,
|
|
32
|
+
borderRight: index < dates.length - 1 ? "1px solid var(--border-color)" : "none",
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
{date.display}
|
|
36
|
+
</div>
|
|
37
|
+
))}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default TimelineHeader;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import TimelineHeader from "./TimelineHeader";
|
|
3
|
+
import TimelineContent from "./TimelineContent";
|
|
4
|
+
|
|
5
|
+
const TimelineMonthContainer = ({
|
|
6
|
+
dates,
|
|
7
|
+
month,
|
|
8
|
+
groupedResources,
|
|
9
|
+
collapsedGroups,
|
|
10
|
+
toggleGroupCollapse,
|
|
11
|
+
}) => {
|
|
12
|
+
return (
|
|
13
|
+
<div style={{ display: "flex", flexDirection: "column", width: "100%" }}>
|
|
14
|
+
{/* Timeline Header */}
|
|
15
|
+
<TimelineHeader dates={dates} monthHeaders={[{ month, startIndex: 0, endIndex: dates.length - 1 }]} />
|
|
16
|
+
|
|
17
|
+
{/* Timeline Content */}
|
|
18
|
+
<div style={{ display: "flex" }}>
|
|
19
|
+
<TimelineContent
|
|
20
|
+
groupedResources={groupedResources}
|
|
21
|
+
dates={dates}
|
|
22
|
+
collapsedGroups={collapsedGroups}
|
|
23
|
+
/>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default TimelineMonthContainer;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './Timeline.css';
|
|
3
|
+
|
|
4
|
+
const TimelineResources = ({ resources }) => {
|
|
5
|
+
return (
|
|
6
|
+
<div className="timeline-resources">
|
|
7
|
+
{resources.map((resource, index) => (
|
|
8
|
+
<div key={index} className="resource-cell">
|
|
9
|
+
{resource}
|
|
10
|
+
</div>
|
|
11
|
+
))}
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default TimelineResources;
|