Skip to content

Hackathon #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
0aa9373
test modifications
Jul 12, 2022
bf56cb0
test modifications
Jul 12, 2022
9beec69
test modifications
Jul 12, 2022
6f1550b
modify package
Jul 13, 2022
2133b5d
modify package
Jul 13, 2022
4db4819
modify package
Jul 13, 2022
e64c759
modify package
Jul 13, 2022
ea5fda0
add new columns
Jul 19, 2022
21589ae
add new columns
Jul 19, 2022
48acc6b
Merge pull request #1 from aryola4/1-adding-columns
valdislav Dec 6, 2022
688c775
styling side bar
Alkar778 Dec 6, 2022
0a2cd92
styling side bar
Alkar778 Dec 6, 2022
f40fc58
styling side bar
Alkar778 Dec 6, 2022
7d4ec91
styling side bar
Alkar778 Dec 6, 2022
e1454b2
styling side bar
Alkar778 Dec 6, 2022
999e082
styling side bar
Alkar778 Dec 6, 2022
8b7b093
styling side bar
Alkar778 Dec 6, 2022
9848d00
styling side bar
Alkar778 Dec 6, 2022
f5707c0
Merge branch 'main' of github.com:magento-swat/gantt-task-react into …
valdislav Dec 7, 2022
f18cb90
Hide triangles.
valdislav Dec 7, 2022
7a06752
Fix ColumnHeaders.
valdislav Dec 7, 2022
541c8d1
Add assigned User.
valdislav Dec 7, 2022
9e5e430
Fix progress.
valdislav Dec 7, 2022
615cdb6
Calendar to narrow.
valdislav Dec 7, 2022
4873518
Calendar to narrow.
valdislav Dec 7, 2022
e612ef6
Calendar to narrow.
valdislav Dec 7, 2022
7d9494c
Calendar to narrow.
valdislav Dec 8, 2022
d3c9e32
Calendar to narrow.
valdislav Dec 8, 2022
f931030
Calendar to narrow.
valdislav Dec 8, 2022
1c647e3
Calendar to narrow.
valdislav Dec 8, 2022
4faac92
Calendar to narrow.
valdislav Dec 8, 2022
9f39861
Calendar to narrow.
valdislav Dec 8, 2022
e524c5f
Add margin.
valdislav Dec 8, 2022
f5af08e
Revert "Add margin."
valdislav Dec 8, 2022
0969e8a
Revert "Revert "Add margin.""
valdislav Dec 8, 2022
43a200c
Add margin.
valdislav Dec 8, 2022
743db2c
Add margin.
valdislav Dec 8, 2022
146c4d7
Calendar to narrow.
valdislav Dec 8, 2022
c42221d
Add margin.
valdislav Dec 9, 2022
69da238
Add margin.
valdislav Dec 9, 2022
d743b57
Add margin.
valdislav Dec 9, 2022
4b84af5
Add margin.
valdislav Dec 9, 2022
ecf5821
Add margin.
valdislav Dec 9, 2022
034bd46
Add margin.
valdislav Dec 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gantt-task-react",
"version": "0.3.9",
"version": "0.3.13",
"description": "Interactive Gantt Chart for React with TypeScript.",
"author": "MaTeMaTuK <[email protected]>",
"homepage": "https://github.com/MaTeMaTuK/gantt-task-react",
Expand Down
21 changes: 11 additions & 10 deletions src/components/calendar/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,10 @@ export const Calendar: React.FC<CalendarProps> = ({
const dates = dateSetup.dates;
for (let i = 0; i < dates.length; i++) {
const date = dates[i];
const bottomValue = `${getLocalDayOfWeek(date, locale, "short")}, ${date
const bottomValue = `${date
.getDate()
.toString()}`;
const bottomValueWeekDay = `${getLocalDayOfWeek(date, locale, "narrow")}`;

bottomValues.push(
<text
Expand All @@ -187,7 +188,7 @@ export const Calendar: React.FC<CalendarProps> = ({
x={columnWidth * i + columnWidth * 0.5}
className={styles.calendarBottomText}
>
{bottomValue}
{bottomValueWeekDay} {bottomValue}
</text>
);
if (
Expand Down Expand Up @@ -334,14 +335,14 @@ export const Calendar: React.FC<CalendarProps> = ({
}
return (
<g className="calendar" fontSize={fontSize} fontFamily={fontFamily}>
<rect
x={0}
y={0}
width={columnWidth * dateSetup.dates.length}
height={headerHeight}
className={styles.calendarHeader}
/>
{bottomValues} {topValues}
<rect
x={0}
y={0}
width={columnWidth * dateSetup.dates.length}
height={headerHeight}
className={styles.calendarHeader}
/>
{bottomValues} {topValues}
</g>
);
};
16 changes: 15 additions & 1 deletion src/components/gantt/gantt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,18 @@ import { HorizontalScroll } from "../other/horizontal-scroll";
import { removeHiddenTasks, sortTasks } from "../../helpers/other-helper";
import styles from "./gantt.module.css";

const COLUMNLIST = [
{ columnName: 'Code', headerCellClass: '', cellClass: '', isVisible: true, columnWithArrow: true, toShow: (task:Task) => {return task.id} },
{ columnName: 'Nom', headerCellClass: '', cellClass: '', isVisible: true, toShow: (task:Task) => {return task.name} },
{ columnName: 'Début', headerCellClass: '', cellClass: '', isVisible: true, isDate:true, toShow: (task:Task) => {return task.start} },
{ columnName: 'Fin', headerCellClass: '', cellClass: '', isVisible: true, isDate:true, toShow: (task:Task) => {return task.end} },
{ columnName: 'Assigné à', headerCellClass: '', cellClass: '', isVisible: true, toShow: (task:Task) => {return task.assignedUser} },
];

export const Gantt: React.FunctionComponent<GanttProps> = ({
tasks,
headerHeight = 50,
marginTop = 0,
columnWidth = 60,
listCellWidth = "155px",
rowHeight = 50,
Expand Down Expand Up @@ -58,6 +67,7 @@ export const Gantt: React.FunctionComponent<GanttProps> = ({
TooltipContent = StandardTooltipContent,
TaskListHeader = TaskListHeaderDefault,
TaskListTable = TaskListTableDefault,
columnList = COLUMNLIST,
onDateChange,
onProgressChange,
onDoubleClick,
Expand Down Expand Up @@ -139,7 +149,8 @@ export const Gantt: React.FunctionComponent<GanttProps> = ({
projectBackgroundColor,
projectBackgroundSelectedColor,
milestoneBackgroundColor,
milestoneBackgroundSelectedColor
milestoneBackgroundSelectedColor,
marginTop,
)
);
}, [
Expand Down Expand Up @@ -395,6 +406,7 @@ export const Gantt: React.FunctionComponent<GanttProps> = ({
dates: dateSetup.dates,
todayColor,
rtl,
marginTop,
};
const calendarProps: CalendarProps = {
dateSetup,
Expand All @@ -421,6 +433,7 @@ export const Gantt: React.FunctionComponent<GanttProps> = ({
arrowIndent,
svgWidth,
rtl,
marginTop,
setGanttEvent,
setFailedTask,
setSelectedTask: handleSelectedTask,
Expand All @@ -444,6 +457,7 @@ export const Gantt: React.FunctionComponent<GanttProps> = ({
horizontalContainerClass: styles.horizontalContainer,
selectedTask,
taskListRef,
columnList,
setSelectedTask: handleSelectedTask,
onExpanderClick: handleExpanderClick,
TaskListHeader,
Expand Down
1 change: 1 addition & 0 deletions src/components/gantt/task-gantt-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type TaskGanttContentProps = {
fontSize: string;
fontFamily: string;
rtl: boolean;
marginTop: number;
setGanttEvent: (value: GanttEvent) => void;
setFailedTask: (value: BarTask | null) => void;
setSelectedTask: (taskId: string) => void;
Expand Down
40 changes: 22 additions & 18 deletions src/components/gantt/task-gantt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ export const TaskGantt: React.FC<TaskGanttProps> = ({
ref={verticalGanttContainerRef}
dir="ltr"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width={gridProps.svgWidth}
height={calendarProps.headerHeight}
fontFamily={barProps.fontFamily}
>
<Calendar {...calendarProps} />
</svg>
<div className="calendarWrapper">
<svg
xmlns="http://www.w3.org/2000/svg"
width={gridProps.svgWidth}
height={calendarProps.headerHeight}
fontFamily={barProps.fontFamily}
>
<Calendar {...calendarProps} />
</svg>
</div>
<div
ref={horizontalContainerRef}
className={styles.horizontalContainer}
Expand All @@ -60,16 +62,18 @@ export const TaskGantt: React.FC<TaskGanttProps> = ({
: { width: gridProps.svgWidth }
}
>
<svg
xmlns="http://www.w3.org/2000/svg"
width={gridProps.svgWidth}
height={barProps.rowHeight * barProps.tasks.length}
fontFamily={barProps.fontFamily}
ref={ganttSVGRef}
>
<Grid {...gridProps} />
<TaskGanttContent {...newBarProps} />
</svg>
<div className="contentGridWrapper">
<svg
xmlns="http://www.w3.org/2000/svg"
width={gridProps.svgWidth}
height={barProps.rowHeight * barProps.tasks.length + 2 * barProps.marginTop}
fontFamily={barProps.fontFamily}
ref={ganttSVGRef}
>
<Grid {...gridProps} />
<TaskGanttContent {...newBarProps} />
</svg>
</div>
</div>
</div>
);
Expand Down
22 changes: 19 additions & 3 deletions src/components/grid/grid-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type GridBodyProps = {
columnWidth: number;
todayColor: string;
rtl: boolean;
marginTop: number;
};
export const GridBody: React.FC<GridBodyProps> = ({
tasks,
Expand All @@ -20,8 +21,9 @@ export const GridBody: React.FC<GridBodyProps> = ({
columnWidth,
todayColor,
rtl,
marginTop,
}) => {
let y = 0;
let y = marginTop;
const gridRows: ReactChild[] = [];
const rowLines: ReactChild[] = [
<line
Expand All @@ -33,14 +35,28 @@ export const GridBody: React.FC<GridBodyProps> = ({
className={styles.gridRowLine}
/>,
];
let i = 0;
let tasksLength = tasks.length;
for (const task of tasks) {
let yTmp = y;
let tmpHeight = rowHeight;
if (i === 0) {
//set first row rectangle y to 0 to fill first row completely including marginTop
yTmp = 0;
tmpHeight = rowHeight + marginTop;
}
// set last row to fill margin
if (i === (tasksLength - 1)) {
tmpHeight = rowHeight + marginTop;
}
i++;
gridRows.push(
<rect
key={"Row" + task.id}
x="0"
y={y}
y={yTmp}
width={svgWidth}
height={rowHeight}
height={tmpHeight}
className={styles.gridRow}
/>
);
Expand Down
4 changes: 0 additions & 4 deletions src/components/grid/grid.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
fill: #fff;
}

.gridRow:nth-child(even) {
fill: #f5f5f5;
}

.gridRowLine {
stroke: #ebeff2;
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/other/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ export const StandardTooltipContent: React.FC<{
<p className={styles.tooltipDefaultContainerParagraph}>
{!!task.progress && `Progress: ${task.progress} %`}
</p>
<p className={styles.tooltipDefaultContainerParagraph}>
{`Description: ${task.description}`}
</p>
</div>
);
};
26 changes: 21 additions & 5 deletions src/components/task-item/bar/bar-display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type BarDisplayProps = {
progressSelectedColor: string;
};
onMouseDown: (event: React.MouseEvent<SVGPolygonElement, MouseEvent>) => void;
assignedUser?: string;
};
export const BarDisplay: React.FC<BarDisplayProps> = ({
x,
Expand All @@ -30,6 +31,7 @@ export const BarDisplay: React.FC<BarDisplayProps> = ({
barCornerRadius,
styles,
onMouseDown,
assignedUser,
}) => {
const getProcessColor = () => {
return isSelected ? styles.progressSelectedColor : styles.progressColor;
Expand All @@ -38,7 +40,20 @@ export const BarDisplay: React.FC<BarDisplayProps> = ({
const getBarColor = () => {
return isSelected ? styles.backgroundSelectedColor : styles.backgroundColor;
};

let showAvatar = false;
if (assignedUser !== undefined) {
showAvatar = true;
}
let avatarX = x + 30;
let avatarY = y + height / 2 - 10;
let progressCornerRadius = barCornerRadius;
let progressHeight = height;
let progressY = y
if (progressWidth < 20) {
progressCornerRadius = 50;
progressHeight = height / 3;
progressY = progressY + progressHeight
}
return (
<g onMouseDown={onMouseDown}>
<rect
Expand All @@ -54,12 +69,13 @@ export const BarDisplay: React.FC<BarDisplayProps> = ({
<rect
x={progressX}
width={progressWidth}
y={y}
height={height}
ry={barCornerRadius}
rx={barCornerRadius}
y={progressY}
height={progressHeight}
ry={progressCornerRadius}
rx={progressCornerRadius}
fill={getProcessColor()}
/>
{showAvatar && <image x={avatarX} y={avatarY} href="https://www.nps.gov/maps/tools/symbol-library/assets/img/volleyball-black-22.svg" height="22px" width="22px" preserveAspectRatio="none"/>}
</g>
);
};
1 change: 1 addition & 0 deletions src/components/task-item/bar/bar-small.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const BarSmall: React.FC<TaskItemProps> = ({
onMouseDown={e => {
isDateChangeable && onEventStart("move", task, e);
}}
assignedUser={task.assignedUser}
/>
<g className="handleGroup">
{isProgressChangeable && (
Expand Down
1 change: 1 addition & 0 deletions src/components/task-item/bar/bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const Bar: React.FC<TaskItemProps> = ({
onMouseDown={e => {
isDateChangeable && onEventStart("move", task, e);
}}
assignedUser={task.assignedUser}
/>
<g className="handleGroup">
{isDateChangeable && (
Expand Down
27 changes: 12 additions & 15 deletions src/components/task-item/project/project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ export const Project: React.FC<TaskItemProps> = ({ task, isSelected }) => {
task.x2 - 15,
task.y + task.height / 2 - 1,
].join(",");

let showTriangles = task.barCornerRadius < 6;
let showAvatar = false;
if (task.assignedUser !== undefined) {
showAvatar = true;
}
let avatarX = task.x1 + 30;
let avatarY = task.y + task.height / 2 - 10;
return (
<g tabIndex={0} className={styles.projectWrapper}>
<rect
Expand All @@ -49,26 +55,17 @@ export const Project: React.FC<TaskItemProps> = ({ task, isSelected }) => {
rx={task.barCornerRadius}
fill={processColor}
/>
<rect
fill={barColor}
x={task.x1}
width={projectWith}
y={task.y}
height={task.height / 2}
rx={task.barCornerRadius}
ry={task.barCornerRadius}
className={styles.projectTop}
/>
<polygon
{showTriangles && <polygon
className={styles.projectTop}
points={projectLeftTriangle}
fill={barColor}
/>
<polygon
/>}
{showTriangles && <polygon
className={styles.projectTop}
points={projectRightTriangle}
fill={barColor}
/>
/>}
{showAvatar && <image x={avatarX} y={avatarY} href="https://www.nps.gov/maps/tools/symbol-library/assets/img/volleyball-black-22.svg" height="22px" width="22px" preserveAspectRatio="none"/>}
</g>
);
};
Loading