From a1b24ba466696541bff5caae83369ba164d797ca Mon Sep 17 00:00:00 2001 From: Jacek Pyziak Date: Fri, 11 Apr 2025 22:57:23 +0200 Subject: [PATCH] update --- .vscode/ftp-kr.sync.cache.json | 269 ++++++++++++++++++++++-- libraries/jquery-gantt/jquery-gantt.css | 18 ++ libraries/jquery-gantt/jquery-gantt.js | 70 +++++- templates/tasks/main_view.php | 7 +- 4 files changed, 345 insertions(+), 19 deletions(-) diff --git a/.vscode/ftp-kr.sync.cache.json b/.vscode/ftp-kr.sync.cache.json index 82c6ae1..7fd9fe3 100644 --- a/.vscode/ftp-kr.sync.cache.json +++ b/.vscode/ftp-kr.sync.cache.json @@ -14,14 +14,149 @@ "modified": false }, "autoload": { + "class.Cache.php": { + "type": "-", + "size": 1006, + "lmtime": 0, + "modified": false + }, + "class.Chunk.php": { + "type": "-", + "size": 7304, + "lmtime": 0, + "modified": false + }, + "class.Cron.php": { + "type": "-", + "size": 8979, + "lmtime": 1744321951326, + "modified": false + }, + "class.DbModel.php": { + "type": "-", + "size": 1392, + "lmtime": 0, + "modified": false + }, + "class.Excel.php": { + "type": "-", + "size": 4319, + "lmtime": 0, + "modified": false + }, + "class.Html.php": { + "type": "-", + "size": 2105, + "lmtime": 0, + "modified": false + }, + "class.S.php": { + "type": "-", + "size": 7575, + "lmtime": 0, + "modified": false + }, + "class.Tpl.php": { + "type": "-", + "size": 1746, + "lmtime": 0, + "modified": false + }, "controls": { + "class.Crm.php": { + "type": "-", + "size": 1824, + "lmtime": 0, + "modified": false + }, + "class.Cron.php": { + "type": "-", + "size": 131, + "lmtime": 0, + "modified": false + }, + "class.Finances.php": { + "type": "-", + "size": 6614, + "lmtime": 0, + "modified": false + }, + "class.Projects.php": { + "type": "-", + "size": 9777, + "lmtime": 0, + "modified": false + }, + "class.Site.php": { + "type": "-", + "size": 575, + "lmtime": 0, + "modified": false + }, "class.Tasks.php": { "type": "-", - "size": 15591, - "lmtime": 1740507790191, + "size": 16669, + "lmtime": 1744323786682, + "modified": false + }, + "class.Users.php": { + "type": "-", + "size": 3591, + "lmtime": 0, + "modified": false + }, + "class.Wiki.php": { + "type": "-", + "size": 1825, + "lmtime": 0, "modified": false } - } + }, + "factory": { + "class.Crm.php": { + "type": "-", + "size": 1863, + "lmtime": 0, + "modified": false + }, + "class.Cron.php": { + "type": "-", + "size": 26120, + "lmtime": 0, + "modified": false + }, + "class.Finances.php": { + "type": "-", + "size": 16159, + "lmtime": 0, + "modified": false + }, + "class.Projects.php": { + "type": "-", + "size": 27175, + "lmtime": 0, + "modified": false + }, + "class.Tasks.php": { + "type": "-", + "size": 17068, + "lmtime": 1744321917674, + "modified": false + }, + "class.Users.php": { + "type": "-", + "size": 2020, + "lmtime": 0, + "modified": false + }, + "class.Wiki.php": { + "type": "-", + "size": 1911, + "lmtime": 0, + "modified": false + } + }, + "view": {} }, "ceidg.php": { "type": "-", @@ -56,24 +191,110 @@ "layout": { "style.css": { "type": "-", - "size": 22346, - "lmtime": 1743623979088, + "size": 22359, + "lmtime": 1744321764868, "modified": false }, "style.css.map": { "type": "-", - "size": 39015, - "lmtime": 1743623979088, + "size": 39045, + "lmtime": 1744321764868, "modified": false }, "style.scss": { "type": "-", - "size": 27154, - "lmtime": 1743623978938, + "size": 27172, + "lmtime": 1744321764492, "modified": false } }, - "libraries": {}, + "libraries": { + "JS-Gantt-Chart-master": { + "gantt.css": { + "type": "-", + "size": 2007, + "lmtime": 1744320380208, + "modified": false + }, + "gantt.js": { + "type": "-", + "size": 16093, + "lmtime": 1744320529415, + "modified": false + }, + "gantt.min.css": { + "type": "-", + "size": 1696, + "lmtime": 0, + "modified": false + }, + "gantt.min.js": { + "type": "-", + "size": 9935, + "lmtime": 0, + "modified": false + }, + ".gitattributes": { + "type": "-", + "size": 66, + "lmtime": 0, + "modified": false + }, + "LICENSE": { + "type": "-", + "size": 1067, + "lmtime": 0, + "modified": false + }, + "README.md": { + "type": "-", + "size": 2501, + "lmtime": 0, + "modified": false + }, + "sample-chart": {} + }, + "jquery-gantt": { + "img": { + "grid.png": { + "type": "-", + "size": 96, + "lmtime": 0, + "modified": false + }, + "icon_sprite.png": { + "type": "-", + "size": 808, + "lmtime": 0, + "modified": false + }, + "slider_handle.png": { + "type": "-", + "size": 817, + "lmtime": 0, + "modified": false + } + }, + "jquery-gantt.css": { + "type": "-", + "size": 9801, + "lmtime": 1744323885612, + "modified": false + }, + "jquery-gantt.css.map": { + "type": "-", + "size": 2942, + "lmtime": 0, + "modified": false + }, + "jquery-gantt.js": { + "type": "-", + "size": 86598, + "lmtime": 1744323096250, + "modified": false + } + } + }, "robots.txt": { "type": "-", "size": 25, @@ -97,14 +318,14 @@ }, "main_view.php": { "type": "-", - "size": 29103, - "lmtime": 1743623929427, + "size": 29690, + "lmtime": 1744323939813, "modified": false }, "task_edit.php": { "type": "-", - "size": 7649, - "lmtime": 0, + "size": 7891, + "lmtime": 1744321858310, "modified": false }, "task_popup.php": { @@ -125,6 +346,26 @@ "lmtime": 0, "modified": false } + }, + "site": { + "layout-cron.php": { + "type": "-", + "size": 5804, + "lmtime": 0, + "modified": false + }, + "layout-logged.php": { + "type": "-", + "size": 5556, + "lmtime": 1744321038374, + "modified": false + }, + "layout-unlogged.php": { + "type": "-", + "size": 986, + "lmtime": 0, + "modified": false + } } }, "upload": {} diff --git a/libraries/jquery-gantt/jquery-gantt.css b/libraries/jquery-gantt/jquery-gantt.css index fbe3374..69cefe1 100644 --- a/libraries/jquery-gantt/jquery-gantt.css +++ b/libraries/jquery-gantt/jquery-gantt.css @@ -490,4 +490,22 @@ .row:after { clear: both; +} + +.handle { + width: 6px; + background: #333; + position: absolute; + top: 0; + bottom: 0; + cursor: ew-resize; + z-index: 20; +} + +.handle-left { + left: 0; +} + +.handle-right { + right: 0; } \ No newline at end of file diff --git a/libraries/jquery-gantt/jquery-gantt.js b/libraries/jquery-gantt/jquery-gantt.js index 06fbe33..8aa88b2 100644 --- a/libraries/jquery-gantt/jquery-gantt.js +++ b/libraries/jquery-gantt/jquery-gantt.js @@ -22,7 +22,8 @@ onItemClick: function (data) { return; }, onAddClick: function (data) { return; }, onRender: function() { return; }, - scrollToToday: true + scrollToToday: true, + saveEndpoint: null }; /** @@ -940,6 +941,66 @@ e.stopPropagation(); settings.onItemClick($(this).data("dataObj")); }); + bar.append('
'); + + let isDragging = false; + let dragType = null; + let startX = 0; + let originalLeft = 0; + let originalWidth = 0; + + bar.find('.handle').on('mousedown', function(e) { + e.stopPropagation(); + isDragging = true; + dragType = $(this).hasClass('handle-left') ? 'left' : 'right'; + startX = e.pageX; + originalLeft = bar.position().left; + originalWidth = bar.width(); + + $(document).on('mousemove.barDrag', function(e) { + if (!isDragging) return; + let delta = e.pageX - startX; + if (dragType === 'left') { + let newLeft = originalLeft + delta; + let newWidth = originalWidth - delta; + if (newWidth > 10) { + bar.css({ left: newLeft + 'px', width: newWidth + 'px' }); + } + } else if (dragType === 'right') { + let newWidth = originalWidth + delta; + if (newWidth > 10) { + bar.css({ width: newWidth + 'px' }); + } + } + }); + + $(document).on('mouseup.barDrag', function() { + if (isDragging) { + isDragging = false; + $(document).off('.barDrag'); + + // Oblicz nową datę z `left` i `width` + const cellSize = tools.getCellSize(); + const newFromOffset = bar.position().left; + const newToOffset = newFromOffset + bar.width(); + + const ganttEl = bar.closest(".fn-gantt").parent()[0]; + const fromTime = tools.getDateFromOffset(newFromOffset, ganttEl); + const toTime = tools.getDateFromOffset(newToOffset, ganttEl); + + const data = bar.data("dataObj"); + + // Tutaj można wysłać AJAX + $.post(settings.saveEndpoint, { + from: fromTime.toISOString(), + to: toTime.toISOString() + }); + + console.log("Zmieniono daty:", fromTime, toTime); + } + }); + }); + return bar; }, @@ -1441,7 +1502,12 @@ } return maxDate; }, - + getDateFromOffset: function(offsetPx, element) { + const step = settings.scale === "hours" ? 3600000 * element.scaleStep : 86400000; // godziny lub dni + const startDate = element.dateStart.getTime(); + const index = Math.floor(offsetPx / tools.getCellSize()); + return new Date(startDate + index * step); + }, // Return the minimum available date in data depending on the scale getMinDate: function (element) { var minDate = null; diff --git a/templates/tasks/main_view.php b/templates/tasks/main_view.php index 34f332d..c9a4c69 100644 --- a/templates/tasks/main_view.php +++ b/templates/tasks/main_view.php @@ -165,14 +165,15 @@ maxScale: "months", scaleStep: 1, scrollToToday: false, + saveEndpoint: "/tasks/set_task_dates/", onItemClick: function(data) { - alert("Item clicked - show some details"); + alert("Item clicked - show some details"); }, onAddClick: function(dt, rowId) { - alert("Empty space clicked - add an item!"); + alert("Empty space clicked - add an item!"); }, onRender: function() { - console.log("chart rendered"); + console.log("chart rendered"); } });