Hi,
I have created a custom task type, say call group
.
Now, before I created this new group
type, I have a lot of assumption over the data available. Meaning to say,
I would assume that there is start_date
, end_date
, and so on.
However, with this group
type, it is quite similar to project
where it does not start_date
, end_date
and so on.
So in many on my events triggers such as
gantt.attachEvent('onQuickInfo` function(taskId) {
const task = gantt.getTask(taskId);
const start = task.start_date;
const end = task.end_date;
}
or declaring the templates.
gantt.templates.quick_info_content = function(start, end, task){
return task.start_date;
};
With new requirements, new type is added, and my current solution is to do a prevent trigger such as:
gantt.attachEvent('onQuickInfo` function(taskId) {
if (task.type === gantt.config.types.group) return;
const task = gantt.getTask(taskId);
const start = task.start_date;
const end = task.end_date;
}
gantt.templates.quick_info_content = function(start, end, task){
if (task.type === gantt.config.types.group) return;
return task.start_date;
};
And this (checking task type) is spreading over and across multiple places all over the project. I am wondering if there is a better way to achieve the same by setting it at a global function or something.
Note: the code may not be accurate, it’s just a concept.
Thanks.