Introduce on click event on task

This commit is contained in:
AzureAD\CaliceLEFEVRE 2022-02-22 16:35:56 +01:00
parent 016fbd2257
commit e38fc8f37e
7 changed files with 21 additions and 0 deletions

View File

@ -44,6 +44,7 @@ You may handle actions
onTaskDelete={onTaskDelete} onTaskDelete={onTaskDelete}
onProgressChange={onProgressChange} onProgressChange={onProgressChange}
onDoubleClick={onDblClick} onDoubleClick={onDblClick}
onClick={onClick}
/> />
``` ```
@ -72,6 +73,7 @@ npm start
| :----------------- | :---------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------- | | :----------------- | :---------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------- |
| onSelect | (task: Task, isSelected: boolean) => void | Specifies the function to be executed on the taskbar select or unselect event. | | onSelect | (task: Task, isSelected: boolean) => void | Specifies the function to be executed on the taskbar select or unselect event. |
| onDoubleClick | (task: Task) => void | Specifies the function to be executed on the taskbar onDoubleClick event. | | onDoubleClick | (task: Task) => void | Specifies the function to be executed on the taskbar onDoubleClick event. |
| onClick | (task: Task) => void | Specifies the function to be executed on the taskbar onClick event. |
| onDelete\* | (task: Task) => void/boolean/Promise<void>/Promise<boolean> | Specifies the function to be executed on the taskbar on Delete button press event. | | onDelete\* | (task: Task) => void/boolean/Promise<void>/Promise<boolean> | Specifies the function to be executed on the taskbar on Delete button press event. |
| onDateChange\* | (task: Task, children: Task[]) => void/boolean/Promise<void>/Promise<boolean> | Specifies the function to be executed when drag taskbar event on timeline has finished. | | onDateChange\* | (task: Task, children: Task[]) => void/boolean/Promise<void>/Promise<boolean> | Specifies the function to be executed when drag taskbar event on timeline has finished. |
| onProgressChange\* | (task: Task, children: Task[]) => void/boolean/Promise<void>/Promise<boolean> | Specifies the function to be executed when drag taskbar progress event has finished. | | onProgressChange\* | (task: Task, children: Task[]) => void/boolean/Promise<void>/Promise<boolean> | Specifies the function to be executed when drag taskbar progress event has finished. |

View File

@ -52,6 +52,10 @@ const App = () => {
alert("On Double Click event Id:" + task.id); alert("On Double Click event Id:" + task.id);
}; };
const handleClick = (task: Task) => {
console.log("On Click event Id:" + task.id);
};
const handleSelect = (task: Task, isSelected: boolean) => { const handleSelect = (task: Task, isSelected: boolean) => {
console.log(task.name + " has " + (isSelected ? "selected" : "unselected")); console.log(task.name + " has " + (isSelected ? "selected" : "unselected"));
}; };
@ -76,6 +80,7 @@ const App = () => {
onDelete={handleTaskDelete} onDelete={handleTaskDelete}
onProgressChange={handleProgressChange} onProgressChange={handleProgressChange}
onDoubleClick={handleDblClick} onDoubleClick={handleDblClick}
onClick={handleClick}
onSelect={handleSelect} onSelect={handleSelect}
onExpanderClick={handleExpanderClick} onExpanderClick={handleExpanderClick}
listCellWidth={isChecked ? "155px" : ""} listCellWidth={isChecked ? "155px" : ""}
@ -89,6 +94,7 @@ const App = () => {
onDelete={handleTaskDelete} onDelete={handleTaskDelete}
onProgressChange={handleProgressChange} onProgressChange={handleProgressChange}
onDoubleClick={handleDblClick} onDoubleClick={handleDblClick}
onClick={handleClick}
onSelect={handleSelect} onSelect={handleSelect}
onExpanderClick={handleExpanderClick} onExpanderClick={handleExpanderClick}
listCellWidth={isChecked ? "155px" : ""} listCellWidth={isChecked ? "155px" : ""}

View File

@ -60,6 +60,7 @@ export const Gantt: React.FunctionComponent<GanttProps> = ({
onDateChange, onDateChange,
onProgressChange, onProgressChange,
onDoubleClick, onDoubleClick,
onClick,
onDelete, onDelete,
onSelect, onSelect,
onExpanderClick, onExpanderClick,
@ -411,6 +412,7 @@ export const Gantt: React.FunctionComponent<GanttProps> = ({
onDateChange, onDateChange,
onProgressChange, onProgressChange,
onDoubleClick, onDoubleClick,
onClick,
onDelete, onDelete,
}; };

View File

@ -53,6 +53,7 @@ export const TaskGanttContent: React.FC<TaskGanttContentProps> = ({
onDateChange, onDateChange,
onProgressChange, onProgressChange,
onDoubleClick, onDoubleClick,
onClick,
onDelete, onDelete,
}) => { }) => {
const point = svg?.current?.createSVGPoint(); const point = svg?.current?.createSVGPoint();
@ -230,6 +231,8 @@ export const TaskGanttContent: React.FC<TaskGanttContentProps> = ({
} }
} else if (action === "dblclick") { } else if (action === "dblclick") {
!!onDoubleClick && onDoubleClick(task); !!onDoubleClick && onDoubleClick(task);
} else if (action === "click") {
!!onClick && onClick(task);
} }
// Change task event start // Change task event start
else if (action === "move") { else if (action === "move") {

View File

@ -100,6 +100,9 @@ export const TaskItem: React.FC<TaskItemProps> = props => {
onDoubleClick={e => { onDoubleClick={e => {
onEventStart("dblclick", task, e); onEventStart("dblclick", task, e);
}} }}
onClick={e => {
onEventStart("click", task, e);
}}
onFocus={() => { onFocus={() => {
onEventStart("select", task); onEventStart("select", task);
}} }}

View File

@ -6,6 +6,7 @@ export type GanttContentMoveAction =
| "mouseleave" | "mouseleave"
| "delete" | "delete"
| "dblclick" | "dblclick"
| "click"
| "select" | "select"
| "" | ""
| BarMoveAction; | BarMoveAction;

View File

@ -44,6 +44,10 @@ export interface EventOption {
* Invokes on bar double click. * Invokes on bar double click.
*/ */
onDoubleClick?: (task: Task) => void; onDoubleClick?: (task: Task) => void;
/**
* Invokes on bar click.
*/
onClick?: (task: Task) => void;
/** /**
* Invokes on end and start time change. Chart undoes operation if method return false or error. * Invokes on end and start time change. Chart undoes operation if method return false or error.
*/ */