Skip to content
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

Move dependent tasks on parent end date change #194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ var gantt = new Gantt("#gantt", tasks, {
padding: 18,
view_mode: 'Day',
date_format: 'YYYY-MM-DD',
custom_popup_html: null
custom_popup_html: null,
move_dependent: 'right'
});
```

Expand Down
29 changes: 20 additions & 9 deletions dist/frappe-gantt.js
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ class Gantt {
} else {
throw new TypeError(
'Frappé Gantt only supports usage of a string CSS selector,' +
" HTML DOM element or SVG DOM element for the 'element' parameter"
" HTML DOM element or SVG DOM element for the 'element' parameter"
);
}

Expand Down Expand Up @@ -1109,7 +1109,8 @@ class Gantt {
date_format: 'YYYY-MM-DD',
popup_trigger: 'click',
custom_popup_html: null,
language: 'en'
language: 'en',
move_dependent: 'left'
};
this.options = Object.assign({}, default_options, options);
}
Expand Down Expand Up @@ -1330,7 +1331,7 @@ class Gantt {
this.options.header_height +
this.options.padding +
(this.options.bar_height + this.options.padding) *
this.tasks.length;
this.tasks.length;

createSVG('rect', {
x: 0,
Expand Down Expand Up @@ -1447,7 +1448,7 @@ class Gantt {
const width = this.options.column_width;
const height =
(this.options.bar_height + this.options.padding) *
this.tasks.length +
this.tasks.length +
this.options.header_height +
this.options.padding / 2;

Expand Down Expand Up @@ -1533,8 +1534,8 @@ class Gantt {
'Half Day_upper':
date.getDate() !== last_date.getDate()
? date.getMonth() !== last_date.getMonth()
? date_utils.format(date, 'D MMM', this.options.language)
: date_utils.format(date, 'D', this.options.language)
? date_utils.format(date, 'D MMM', this.options.language)
: date_utils.format(date, 'D', this.options.language)
: '',
Day_upper:
date.getMonth() !== last_date.getMonth()
Expand Down Expand Up @@ -1647,8 +1648,8 @@ class Gantt {

const scroll_pos =
hours_before_first_task /
this.options.step *
this.options.column_width -
this.options.step *
this.options.column_width -
this.options.column_width;

parent_element.scrollLeft = scroll_pos;
Expand Down Expand Up @@ -1729,7 +1730,10 @@ class Gantt {
x: $bar.ox + $bar.finaldx,
width: $bar.owidth - $bar.finaldx
});
} else {
} else if (
this.options.move_dependent === 'left' ||
this.options.move_dependent === 'both'
) {
bar.update_bar_position({
x: $bar.ox + $bar.finaldx
});
Expand All @@ -1739,6 +1743,13 @@ class Gantt {
bar.update_bar_position({
width: $bar.owidth + $bar.finaldx
});
} else if (
this.options.move_dependent === 'right' ||
this.options.move_dependent === 'both'
) {
bar.update_bar_position({
x: $bar.ox + $bar.finaldx
});
}
} else if (is_dragging) {
bar.update_bar_position({ x: $bar.ox + $bar.finaldx });
Expand Down
Loading