improve gantt chart
This commit is contained in:
@@ -25,7 +25,7 @@ services:
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: pm-api
|
container_name: pm-api
|
||||||
environment:
|
environment:
|
||||||
PM_DATABASE_URL: postgresql+asyncpg://postgres:postgres@procurement-postgres:5432/procurement
|
PM_DATABASE_URL: postgresql+asyncpg://pm:${PM_DB_PASSWORD:-pm_secret_2026}@pm-postgres:5432/pm
|
||||||
PM_SESSION_SECRET: ${PM_SESSION_SECRET:-12278fc281bd0e22950e76364e1a18cea61fbc6a24604fdd79690a817ec36ac8}
|
PM_SESSION_SECRET: ${PM_SESSION_SECRET:-12278fc281bd0e22950e76364e1a18cea61fbc6a24604fdd79690a817ec36ac8}
|
||||||
PM_ADMIN_USER: ${PM_ADMIN_USER:-admin}
|
PM_ADMIN_USER: ${PM_ADMIN_USER:-admin}
|
||||||
PM_ADMIN_PASSWORD: ${PM_ADMIN_PASSWORD:-pm123456}
|
PM_ADMIN_PASSWORD: ${PM_ADMIN_PASSWORD:-pm123456}
|
||||||
@@ -48,7 +48,7 @@ services:
|
|||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
networks:
|
networks:
|
||||||
- default
|
- default
|
||||||
- erp_default
|
- traefik_network
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
pm-frontend:
|
pm-frontend:
|
||||||
@@ -85,5 +85,4 @@ networks:
|
|||||||
erp_default:
|
erp_default:
|
||||||
external: true
|
external: true
|
||||||
traefik_network:
|
traefik_network:
|
||||||
external: true
|
external: true
|
||||||
|
|
||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
ChevronUp,
|
ChevronUp,
|
||||||
Clock,
|
Clock,
|
||||||
Flame,
|
Flame,
|
||||||
Hand,
|
|
||||||
Layers,
|
Layers,
|
||||||
Link2,
|
Link2,
|
||||||
Pencil,
|
Pencil,
|
||||||
@@ -167,7 +166,6 @@ export function GanttChart({
|
|||||||
const touchDistanceRef = useRef<number | null>(null);
|
const touchDistanceRef = useRef<number | null>(null);
|
||||||
const hasAutoScrolledToday = useRef<boolean>(false);
|
const hasAutoScrolledToday = useRef<boolean>(false);
|
||||||
|
|
||||||
const [isPanMode, setIsPanMode] = useState(false);
|
|
||||||
const [isSpacePressed, setIsSpacePressed] = useState(false);
|
const [isSpacePressed, setIsSpacePressed] = useState(false);
|
||||||
const [isPanning, setIsPanning] = useState(false);
|
const [isPanning, setIsPanning] = useState(false);
|
||||||
|
|
||||||
@@ -201,9 +199,6 @@ export function GanttChart({
|
|||||||
if (e.code === "Space" && !e.repeat) {
|
if (e.code === "Space" && !e.repeat) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setIsSpacePressed(true);
|
setIsSpacePressed(true);
|
||||||
} else if ((e.key === "h" || e.key === "H") && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
||||||
e.preventDefault();
|
|
||||||
setIsPanMode((prev) => !prev);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -491,11 +486,9 @@ export function GanttChart({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleWheel = (e: React.WheelEvent) => {
|
const handleWheel = (e: React.WheelEvent) => {
|
||||||
if (e.ctrlKey || e.metaKey) {
|
e.preventDefault();
|
||||||
e.preventDefault();
|
if (e.deltaY !== 0) {
|
||||||
setColWidth((prev) => Math.min(Math.max(prev + (e.deltaY < 0 ? 3 : -3), 2), 54));
|
setColWidth((prev) => Math.min(Math.max(prev + (e.deltaY < 0 ? 3 : -3), 2), 54));
|
||||||
} else if (e.shiftKey && e.deltaY && !e.deltaX && scrollRef.current) {
|
|
||||||
scrollRef.current.scrollLeft += e.deltaY;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -511,7 +504,7 @@ export function GanttChart({
|
|||||||
hasMoved: false,
|
hasMoved: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (e.button === 1 || isPanMode || isSpacePressed) {
|
if (e.button === 1 || isSpacePressed) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -692,16 +685,6 @@ export function GanttChart({
|
|||||||
<span className="text-[11px] text-slate-400 font-medium">
|
<span className="text-[11px] text-slate-400 font-medium">
|
||||||
{toFa(execTasks.length)} وظیفه
|
{toFa(execTasks.length)} وظیفه
|
||||||
</span>
|
</span>
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => setIsPanMode((v) => !v)}
|
|
||||||
className={`flex h-7 items-center gap-1 rounded-lg px-2 text-[11px] font-semibold border ${
|
|
||||||
isPanMode ? "bg-sky-600 border-sky-600 text-white" : "border-slate-200 text-slate-600"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<Hand size={11} />
|
|
||||||
<span>پیمایش</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -713,7 +696,7 @@ export function GanttChart({
|
|||||||
className={`w-full overflow-x-auto select-none [&::-webkit-scrollbar]:hidden ${
|
className={`w-full overflow-x-auto select-none [&::-webkit-scrollbar]:hidden ${
|
||||||
isPanning
|
isPanning
|
||||||
? "cursor-grabbing"
|
? "cursor-grabbing"
|
||||||
: isPanMode || isSpacePressed
|
: isSpacePressed
|
||||||
? "cursor-grab"
|
? "cursor-grab"
|
||||||
: "cursor-default"
|
: "cursor-default"
|
||||||
}`}
|
}`}
|
||||||
@@ -826,7 +809,6 @@ export function GanttChart({
|
|||||||
style={{ left: `${coords.left}px`, width: `${coords.width}px` }}
|
style={{ left: `${coords.left}px`, width: `${coords.width}px` }}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
if (
|
if (
|
||||||
isPanMode ||
|
|
||||||
isSpacePressed ||
|
isSpacePressed ||
|
||||||
wasPanningRef.current ||
|
wasPanningRef.current ||
|
||||||
mousePanRef.current.hasMoved ||
|
mousePanRef.current.hasMoved ||
|
||||||
@@ -841,7 +823,7 @@ export function GanttChart({
|
|||||||
className={`absolute h-8 rounded-xl border shadow-xs flex items-center overflow-hidden transition-all active:scale-95 ${barMeta.bg} ${barMeta.border} ${
|
className={`absolute h-8 rounded-xl border shadow-xs flex items-center overflow-hidden transition-all active:scale-95 ${barMeta.bg} ${barMeta.border} ${
|
||||||
isPanning
|
isPanning
|
||||||
? "cursor-grabbing"
|
? "cursor-grabbing"
|
||||||
: isPanMode || isSpacePressed
|
: isSpacePressed
|
||||||
? "cursor-grab"
|
? "cursor-grab"
|
||||||
: "cursor-pointer"
|
: "cursor-pointer"
|
||||||
} ${isSelected ? `ring-2 ring-offset-2 ${barMeta.ring}` : ""}`}
|
} ${isSelected ? `ring-2 ring-offset-2 ${barMeta.ring}` : ""}`}
|
||||||
|
|||||||
Reference in New Issue
Block a user