@workiom/frappe-gantt 1.0.21 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.js CHANGED
@@ -1078,6 +1078,7 @@ export default class Gantt {
1078
1078
 
1079
1079
  make_arrows() {
1080
1080
  this.arrows = [];
1081
+ this.active_arrow = null;
1081
1082
 
1082
1083
  // Calculate critical path if enabled
1083
1084
  if (this.options.critical_path) {
@@ -1454,6 +1455,7 @@ export default class Gantt {
1454
1455
  let parent_bar_id = null;
1455
1456
  let bars = []; // instanceof Bar
1456
1457
  this.bar_being_dragged = null;
1458
+ this.active_arrow = null;
1457
1459
 
1458
1460
  const action_in_progress = () =>
1459
1461
  is_dragging || is_resizing_left || is_resizing_right;
@@ -1462,6 +1464,11 @@ export default class Gantt {
1462
1464
  if (e.target.classList.contains('grid-row')) this.unselect_all();
1463
1465
  };
1464
1466
 
1467
+ if (!this._document_click_handler) {
1468
+ this._document_click_handler = () => this.set_active_arrow(null);
1469
+ document.addEventListener('click', this._document_click_handler);
1470
+ }
1471
+
1465
1472
  let pos = 0;
1466
1473
  $.on(this.$svg, 'mousemove', '.bar-wrapper, .handle', (e) => {
1467
1474
  if (
@@ -2026,6 +2033,20 @@ export default class Gantt {
2026
2033
  }
2027
2034
  }
2028
2035
 
2036
+ set_active_arrow(arrow) {
2037
+ if (this.active_arrow === arrow) return;
2038
+ if (this.active_arrow) {
2039
+ this.active_arrow.deactivate();
2040
+ }
2041
+ this.active_arrow = arrow;
2042
+ if (arrow) {
2043
+ arrow.activate();
2044
+ if (this.options.on_arrow_click) {
2045
+ this.options.on_arrow_click(arrow.from_task.task, arrow.to_task.task);
2046
+ }
2047
+ }
2048
+ }
2049
+
2029
2050
  unselect_all() {
2030
2051
  if (this.popup) this.popup.parent.classList.add('hide');
2031
2052
  this.$container
@@ -11,6 +11,8 @@
11
11
  --g-arrow-hover-color-dark: #60a5fa;
12
12
  --g-arrow-critical-color-dark: #f5c044;
13
13
  --g-arrow-invalid-color-dark: #ff7676;
14
+ --g-arrow-type-label-bg-dark: #4a4a4a;
15
+ --g-arrow-type-label-color-dark: #fff;
14
16
  --g-resize-handle-hover-dark: rgba(96, 165, 250, 0.4);
15
17
  --g-resize-handle-active-dark: rgba(96, 165, 250, 0.6);
16
18
  }
@@ -44,11 +46,27 @@
44
46
  stroke: var(--g-arrow-hover-color-dark);
45
47
  }
46
48
 
49
+ & .arrow-active {
50
+ stroke: var(--g-arrow-hover-color-dark);
51
+ }
52
+
53
+ & .arrow-type-label rect {
54
+ fill: var(--g-arrow-type-label-bg-dark);
55
+ }
56
+
57
+ & .arrow-type-label text {
58
+ fill: var(--g-arrow-type-label-color-dark);
59
+ }
60
+
47
61
  & .bar {
48
62
  fill: var(--g-bar-color-dark);
49
63
  stroke: none;
50
64
  }
51
65
 
66
+ & .bar-wrapper .bar.bar-arrow-active {
67
+ outline-color: var(--g-arrow-hover-color-dark);
68
+ }
69
+
52
70
  & .bar-progress {
53
71
  fill: var(--g-progress-color);
54
72
  }
@@ -291,6 +291,26 @@
291
291
  stroke: var(--g-arrow-hover-color);
292
292
  }
293
293
 
294
+ & .arrow-active {
295
+ stroke: var(--g-arrow-hover-color);
296
+ }
297
+
298
+ & .arrow-type-label {
299
+ stroke-width: 0;
300
+ cursor: pointer;
301
+ }
302
+
303
+ & .arrow-type-label rect {
304
+ fill: var(--g-arrow-type-label-bg);
305
+ }
306
+
307
+ & .arrow-type-label text {
308
+ fill: var(--g-arrow-type-label-color);
309
+ font-size: 10px;
310
+ font-weight: 600;
311
+ font-family: inherit;
312
+ pointer-events: none;
313
+ }
294
314
 
295
315
  & .bar-wrapper .bar {
296
316
  fill: var(--g-bar-color);
@@ -299,6 +319,12 @@
299
319
  transition: stroke-width 0.3s ease;
300
320
  }
301
321
 
322
+ & .bar-wrapper .bar.bar-arrow-active {
323
+ outline-color: var(--g-arrow-hover-color);
324
+ outline-width: 2px;
325
+ outline-style: solid;
326
+ }
327
+
302
328
  & .bar-wrapper .bar.bar-arrow-critical {
303
329
  outline-color: var(--g-arrow-critical-color);
304
330
  }
@@ -21,6 +21,8 @@
21
21
  --g-row-border-color: #c7c7c7;
22
22
  --g-today-highlight: #37352f;
23
23
  --g-popup-actions: #ebeff2;
24
+ --g-arrow-type-label-bg: #dbdbdb;
25
+ --g-arrow-type-label-color: #000;
24
26
  --g-weekend-highlight-color: #f7f7f7;
25
27
  --g-task-column-bg: #ffffff;
26
28
  --g-task-row-bg: #ffffff;