chore: format

This commit is contained in:
Safwan Samsudeen 2024-04-30 17:51:02 +05:30
parent 5e18b534bf
commit 9cd3633dd7
2 changed files with 54 additions and 45 deletions

View File

@ -92,7 +92,6 @@ export default class Bar {
} }
draw_bar() { draw_bar() {
this.$bar = createSVG('rect', { this.$bar = createSVG('rect', {
x: this.x, x: this.x,
y: this.y, y: this.y,
@ -100,7 +99,12 @@ export default class Bar {
height: this.height, height: this.height,
rx: this.corner_radius, rx: this.corner_radius,
ry: this.corner_radius, ry: this.corner_radius,
class: 'bar' + (/^((?!chrome|android).)*safari/i.test(navigator.userAgent) && !this.task.important ? ' safari' : ''), class:
'bar' +
(/^((?!chrome|android).)*safari/i.test(navigator.userAgent) &&
!this.task.important
? ' safari'
: ''),
append_to: this.bar_group, append_to: this.bar_group,
}); });
@ -249,14 +253,12 @@ export default class Bar {
class: 'handle left', class: 'handle left',
append_to: this.handle_group, append_to: this.handle_group,
}); });
} }
if (!this.gantt.options.progress_readonly) { if (!this.gantt.options.progress_readonly) {
const bar_progress = this.$bar_progress; const bar_progress = this.$bar_progress;
this.$handle_progress = createSVG('circle', { this.$handle_progress = createSVG('circle', {
cx: bar_progress.getEndX(), cx: bar_progress.getEndX(),
cy: bar_progress.getY() + cy: bar_progress.getY() + bar_progress.getHeight() / 2,
bar_progress.getHeight() / 2,
r: 5, r: 5,
class: 'handle progress', class: 'handle progress',
append_to: this.handle_group, append_to: this.handle_group,
@ -300,7 +302,7 @@ export default class Bar {
'none'; 'none';
}); });
$.on(this.group, "click", () => { $.on(this.group, 'click', () => {
this.gantt.trigger_event('click', [this.task]); this.gantt.trigger_event('click', [this.task]);
}); });
@ -309,8 +311,9 @@ export default class Bar {
// just finished a move action, wait for a few seconds // just finished a move action, wait for a few seconds
return; return;
} }
this.group.classList.remove('active') this.group.classList.remove('active');
if (this.gantt.popup) this.gantt.popup.parent.classList.remove('hidden'); if (this.gantt.popup)
this.gantt.popup.parent.classList.remove('hidden');
this.gantt.trigger_event('double_click', [this.task]); this.gantt.trigger_event('double_click', [this.task]);
}); });
@ -449,12 +452,14 @@ export default class Bar {
x_in_units * this.gantt.options.step, x_in_units * this.gantt.options.step,
'hour', 'hour',
); );
const start_offset = this.gantt.gantt_start.getTimezoneOffset() - new_start_date.getTimezoneOffset(); const start_offset =
this.gantt.gantt_start.getTimezoneOffset() -
new_start_date.getTimezoneOffset();
if (start_offset) { if (start_offset) {
new_start_date = date_utils.add( new_start_date = date_utils.add(
new_start_date, new_start_date,
start_offset, start_offset,
'minute' 'minute',
); );
} }

View File

@ -955,9 +955,9 @@ export default class Gantt {
return is_dragging || is_resizing_left || is_resizing_right; return is_dragging || is_resizing_left || is_resizing_right;
} }
this.$svg.onclick = e => { this.$svg.onclick = (e) => {
if (e.target.classList.contains('grid-row')) this.unselect_all() if (e.target.classList.contains('grid-row')) this.unselect_all();
} };
$.on(this.$svg, 'mousedown', '.bar-wrapper, .handle', (e, element) => { $.on(this.$svg, 'mousedown', '.bar-wrapper, .handle', (e, element) => {
const bar_wrapper = $.closest('.bar-wrapper', element); const bar_wrapper = $.closest('.bar-wrapper', element);
@ -1064,7 +1064,7 @@ export default class Gantt {
$.on(this.$svg, 'mousemove', (e) => { $.on(this.$svg, 'mousemove', (e) => {
if (!action_in_progress()) return; if (!action_in_progress()) return;
console.log(e) console.log(e);
const dx = (e.offsetX || e.layerX) - x_on_start; const dx = (e.offsetX || e.layerX) - x_on_start;
bars.forEach((bar) => { bars.forEach((bar) => {
@ -1088,7 +1088,11 @@ export default class Gantt {
width: $bar.owidth + $bar.finaldx, width: $bar.owidth + $bar.finaldx,
}); });
} }
} else if (is_dragging && !this.options.readonly && !this.options.dates_readonly) { } else if (
is_dragging &&
!this.options.readonly &&
!this.options.dates_readonly
) {
bar.update_bar_position({ x: $bar.ox + $bar.finaldx }); bar.update_bar_position({ x: $bar.ox + $bar.finaldx });
} }
}); });