Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehta authored Mar 27, 2024
2 parents be1c875 + 4ba1566 commit ce43bb9
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 28 deletions.
11 changes: 7 additions & 4 deletions dist/frappe-gantt.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@
user-select: none;
}
.gantt .bar-progress {
fill: #a3a3ff;
fill: #acacfa;
}
.gantt .bar-expected-progress {
fill: #c4c4e9;
}
.gantt .bar-invalid {
fill: transparent;
Expand Down Expand Up @@ -144,7 +147,7 @@
fill: #a9b5c1;
}
.gantt .bar-wrapper:hover .bar-progress {
fill: #8a8aff;
fill: #9494f9;
}
.gantt .bar-wrapper:hover .handle {
visibility: visible;
Expand All @@ -154,7 +157,7 @@
fill: #a9b5c1;
}
.gantt .bar-wrapper.active .bar-progress {
fill: #8a8aff;
fill: #9494f9;
}
.gantt .lower-text, .gantt .upper-text {
font-size: 12px;
Expand Down Expand Up @@ -185,7 +188,7 @@
border-radius: 3px;
}
.gantt-container .popup-wrapper .title {
border-bottom: 3px solid #a3a3ff;
border-bottom: 3px solid #acacfa;
padding: 10px;
}
.gantt-container .popup-wrapper .subtitle {
Expand Down
65 changes: 58 additions & 7 deletions dist/frappe-gantt.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/frappe-gantt.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/frappe-gantt.min.js

Large diffs are not rendered by default.

65 changes: 58 additions & 7 deletions src/bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ export default class Bar {
prepare_values() {
this.invalid = this.task.invalid;
this.height = this.gantt.options.bar_height;
this.x = this.compute_x();
this.y = this.compute_y();
this.compute_x();
this.compute_y();
this.compute_duration();
this.corner_radius = this.gantt.options.bar_corner_radius;
this.duration =
date_utils.diff(this.task._end, this.task._start, 'hour') /
this.gantt.options.step;
this.width = this.gantt.options.column_width * this.duration;
this.progress_width =
this.gantt.options.column_width *
Expand Down Expand Up @@ -66,8 +64,20 @@ export default class Bar {
};
}

prepare_expected_progress_values() {
this.compute_expected_progress();
this.expected_progress_width =
this.gantt.options.column_width *
this.duration *
(this.expected_progress / 100) || 0;
}

draw() {
this.draw_bar();
if (this.gantt.options.show_expected_progress) {
this.prepare_expected_progress_values();
this.draw_expected_progress_bar();
}
this.draw_progress_bar();
this.draw_label();
this.draw_resize_handles();
Expand All @@ -92,6 +102,22 @@ export default class Bar {
}
}

draw_expected_progress_bar() {
if (this.invalid) return;
this.$expected_bar_progress = createSVG('rect', {
x: this.x,
y: this.y,
width: this.expected_progress_width,
height: this.height,
rx: this.corner_radius,
ry: this.corner_radius,
class: 'bar-expected-progress',
append_to: this.bar_group,
});

animateSVG(this.$expected_bar_progress, 'width', 0, this.expected_progress_width);
}

draw_progress_bar() {
if (this.invalid) return;
this.$bar_progress = createSVG('rect', {
Expand Down Expand Up @@ -241,6 +267,11 @@ export default class Bar {
}
this.update_label_position();
this.update_handle_position();
if (this.gantt.options.show_expected_progress){
this.date_changed();
this.compute_duration();
this.update_expected_progressbar_position();
}
this.update_progressbar_position();
this.update_arrow_position();
}
Expand Down Expand Up @@ -303,6 +334,11 @@ export default class Bar {
return parseInt(progress, 10);
}

compute_expected_progress() {
this.expected_progress = date_utils.diff(date_utils.today(), this.task._start, 'hour') / this.gantt.options.step;
this.expected_progress = ((this.expected_progress < this.duration) ? this.expected_progress : this.duration) * 100 / this.duration;
}

compute_x() {
const { step, column_width } = this.gantt.options;
const task_start = this.task._start;
Expand All @@ -315,17 +351,22 @@ export default class Bar {
const diff = date_utils.diff(task_start, gantt_start, 'day');
x = (diff * column_width) / 30;
}
return x;
this.x = x;
}

compute_y() {
return (
this.y = (
this.gantt.options.header_height +
this.gantt.options.padding +
this.task._index * (this.height + this.gantt.options.padding)
);
}

compute_duration() {
this.duration = date_utils.diff(this.task._end, this.task._start, 'hour') /
this.gantt.options.step;
}

get_snap_position(dx) {
let odx = dx,
rem,
Expand Down Expand Up @@ -367,6 +408,16 @@ export default class Bar {
return element;
}

update_expected_progressbar_position() {
if (this.invalid) return;
this.$expected_bar_progress.setAttribute('x', this.$bar.getX());
this.compute_expected_progress();
this.$expected_bar_progress.setAttribute(
'width',
this.gantt.options.column_width * this.duration * (this.expected_progress / 100) || 0
);
}

update_progressbar_position() {
if (this.invalid) return;
this.$bar_progress.setAttribute('x', this.$bar.getX());
Expand Down
21 changes: 20 additions & 1 deletion src/gantt.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ $light-yellow: #fcf8e3 !default;
$text-muted: #666 !default;
$text-light: #555 !default;
$text-color: #333 !default;
$blue: #a3a3ff !default;
$blue: #acacfa !default;
$handle-color: #ddd !default;
$light-blue: #c4c4e9 !default;

.gantt {
.grid-background {
Expand Down Expand Up @@ -42,6 +43,21 @@ $handle-color: #ddd !default;
opacity: 0.5;
}

.week-highlight {
fill: $light-yellow;
opacity: 0.5;
}

.month-highlight {
fill: $light-yellow;
opacity: 0.5;
}

.year-highlight {
fill: $light-yellow;
opacity: 0.5;
}

.arrow {
fill: none;
stroke: $text-muted;
Expand All @@ -58,6 +74,9 @@ $handle-color: #ddd !default;
.bar-progress {
fill: $blue;
}
.bar-expected-progress {
fill: $light-blue;
}
.bar-invalid {
fill: transparent;
stroke: $bar-stroke;
Expand Down
Loading

0 comments on commit ce43bb9

Please sign in to comment.