Skip to content

Commit 74672c2

Browse files
authored
Merge pull request #492 from namespace-ee/develop
0.23.0
2 parents 1ca8d0d + d9ea3bf commit 74672c2

34 files changed

+2370
-496
lines changed

CHANGELOG.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,59 @@ and this project adheres (more or less) to [Semantic Versioning](http://semver.o
77

88
## Unreleased
99

10+
## 0.23.0
11+
12+
- improve unit tests coverage #426 - @ilaiwi
13+
- stack items by group #384 - @acemac
14+
- fix bug where `canMove` prop gets ignored #484 - @acemac + @ilaiwi
15+
- fix sidebar re-render when groupHeights do not change #478 - @SDupZ
16+
17+
### Stack per group
18+
19+
now you can stack choose to stack items in individual groups by providing the property `stackItems` in group object. The property in group overrides the timeline prop `stackItems`.
20+
21+
```
22+
const groups = [{ id: 1, title: 'group 1', stackItems: false }, { id: 2, title: 'group 2', stackItems: true }]
23+
24+
const items = [
25+
{
26+
id: 1,
27+
group: 1,
28+
title: 'item 1',
29+
start_time: moment(),
30+
end_time: moment().add(1, 'hour')
31+
},
32+
{
33+
id: 2,
34+
group: 2,
35+
title: 'item 2',
36+
start_time: moment().add(-0.5, 'hour'),
37+
end_time: moment().add(0.5, 'hour')
38+
},
39+
{
40+
id: 3,
41+
group: 1,
42+
title: 'item 3',
43+
start_time: moment().add(2, 'hour'),
44+
end_time: moment().add(3, 'hour')
45+
}
46+
]
47+
48+
ReactDOM.render(
49+
<div>
50+
Rendered by react!
51+
<Timeline
52+
groups={groups}
53+
items={items}
54+
defaultTimeStart={moment().add(-12, 'hour')}
55+
defaultTimeEnd={moment().add(12, 'hour')}
56+
/>
57+
</div>,
58+
document.getElementById('root')
59+
)
60+
```
61+
62+
1063
## 0.22.0
1164

1265
### Fixed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Expects either a vanilla JS array or an immutableJS array, consisting of objects
8383
id: 1,
8484
title: 'group 1',
8585
rightTitle: 'title in the right sidebar',
86+
stackItems?: true,
87+
height?: 30
8688
}
8789
```
8890

@@ -234,7 +236,7 @@ Append a special `.rct-drag-right` handle to the elements and only resize if dra
234236

235237
### stackItems
236238

237-
Stack items under each other, so there is no visual overlap when times collide. Defaults to `false`.
239+
Stack items under each other, so there is no visual overlap when times collide. Can be overridden in the `groups` array. Defaults to `false`.
238240

239241
## traditionalZoom
240242

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
export const orderedGroups = {
2+
'1': {
3+
group: {
4+
id: '1'
5+
},
6+
index: 0
7+
},
8+
'2': {
9+
group: {
10+
id: '2'
11+
},
12+
index: 1
13+
},
14+
'3': {
15+
group: {
16+
id: '3'
17+
},
18+
index: 2
19+
}
20+
}
21+
22+
export const dimensionItems = [
23+
{
24+
dimensions: {
25+
collisionLeft: 1540540000000,
26+
collisionWidth: 6803877,
27+
height: 22.5,
28+
left: 907.4074074074074,
29+
order: {
30+
group: {
31+
id: '1'
32+
},
33+
index: 0
34+
},
35+
stack: true,
36+
top: 7.5,
37+
width: 78.74857638888886
38+
},
39+
id: '0'
40+
},
41+
{
42+
dimensions: {
43+
collisionLeft: 1540532800000,
44+
collisionWidth: 21203877,
45+
height: 22.5,
46+
left: 824.074074074074,
47+
order: {
48+
group: {
49+
id: '1'
50+
},
51+
index: 0
52+
},
53+
stack: true,
54+
top: 37.5,
55+
width: 245.4152430555556
56+
},
57+
id: '5'
58+
},
59+
{
60+
dimensions: {
61+
collisionLeft: 1540550800000,
62+
collisionWidth: 24803877,
63+
height: 22.5,
64+
left: 1032.4074074074074,
65+
order: {
66+
group: {
67+
id: '1'
68+
},
69+
index: 0
70+
},
71+
stack: true,
72+
top: 7.5,
73+
width: 287.08190972222224
74+
},
75+
id: '6'
76+
},
77+
{
78+
dimensions: {
79+
collisionLeft: 1540570000000,
80+
collisionWidth: 14875919,
81+
height: 22.5,
82+
left: 1254.6296296296296,
83+
order: {
84+
group: {
85+
id: '1'
86+
},
87+
index: 0
88+
},
89+
stack: true,
90+
top: 37.5,
91+
width: 172.1749884259259
92+
},
93+
id: '1'
94+
},
95+
{
96+
dimensions: {
97+
collisionLeft: 1540620000000,
98+
collisionWidth: 20397548,
99+
height: 22.5,
100+
left: 1833.3333333333333,
101+
order: {
102+
group: {
103+
id: '1'
104+
},
105+
index: 0
106+
},
107+
stack: true,
108+
top: 7.5,
109+
width: 236.08273148148123
110+
},
111+
id: '2'
112+
},
113+
{
114+
dimensions: {
115+
collisionLeft: 1540656000000,
116+
collisionWidth: 20397548,
117+
height: 22.5,
118+
left: 2250,
119+
order: {
120+
group: {
121+
id: '3'
122+
},
123+
index: 2
124+
},
125+
stack: true,
126+
top: 105,
127+
width: 236.08273148148146
128+
},
129+
id: '3'
130+
}
131+
]

__fixtures__/itemsAndGroups.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
export const items = [
3+
{
4+
id: '0',
5+
group: '1',
6+
start_time: 1540540000000,
7+
end_time: 1540546803877,
8+
canMove: false,
9+
canResize: false
10+
},
11+
{
12+
id: '5',
13+
group: '1',
14+
start_time: 1540532800000,
15+
end_time: 1540554003877,
16+
canMove: false,
17+
canResize: false,
18+
className: ''
19+
},
20+
{
21+
id: '6',
22+
group: '1',
23+
start_time: 1540550800000,
24+
end_time: 1540575603877,
25+
canMove: false,
26+
canResize: false,
27+
className: ''
28+
},
29+
{
30+
id: '1',
31+
group: '1',
32+
start_time: 1540570000000,
33+
end_time: 1540584875919,
34+
canMove: true,
35+
canResize: 'both'
36+
},
37+
{
38+
id: '2',
39+
group: '1',
40+
start_time: 1540620000000,
41+
end_time: 1540640397548,
42+
canMove: false,
43+
canResize: false,
44+
className: ''
45+
},
46+
{
47+
id: '3',
48+
group: '3',
49+
start_time: 1540656000000,
50+
end_time: 1540676397548,
51+
canMove: false,
52+
canResize: false,
53+
className: ''
54+
}
55+
]
56+
57+
export const groups = [{ id: '1' }, { id: '2' }, { id: '3' }]

__fixtures__/stateAndProps.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { defaultKeys } from 'lib/default-config'
2+
import {items} from './itemsAndGroups'
3+
export const props = {
4+
keys: defaultKeys,
5+
lineHeight: 30,
6+
stackItems: true,
7+
itemHeightRatio: 0.75
8+
}
9+
10+
export const propsNoStack = {
11+
...props,
12+
stackItems: false,
13+
}
14+
15+
export const visibleTimeStart = 1540501200000
16+
export const visibleTimeEnd = 1540587600000
17+
18+
export const state = {
19+
draggingItem: undefined,
20+
dragTime: null,
21+
resizingItem: null,
22+
resizingEdge: null,
23+
resizeTime: null,
24+
newGroupOrder: null,
25+
canvasTimeStart: 1540414800000,
26+
visibleTimeEnd: visibleTimeEnd,
27+
visibleTimeStart: visibleTimeStart,
28+
canvasTimeEnd: 1540674000000,
29+
width: 1000,
30+
}
31+
32+
//offset 1 hour
33+
const timeOffset = 1 * 60 *60 *1000
34+
35+
export const stateMoveItem = {
36+
...state,
37+
draggingItem: items[0].id,
38+
dragTime: items[0].start_time+timeOffset,
39+
newGroupOrder: 0,
40+
}
41+
export const stateResizeItemLeft = {
42+
...state,
43+
resizingItem: items[0].id,
44+
resizingEdge: 'left',
45+
resizeTime: items[0].start_time+timeOffset,
46+
newGroupOrder: 0,
47+
}
48+
49+
export const stateResizeItemRight = {
50+
...state,
51+
resizingItem: items[0].id,
52+
resizingEdge: 'right',
53+
resizeTime: items[0].end_time+timeOffset,
54+
newGroupOrder: 0,
55+
}

0 commit comments

Comments
 (0)