Skip to content

Commit bc16ba3

Browse files
MIT License
1 parent 6fb237d commit bc16ba3

2 files changed

Lines changed: 28 additions & 11 deletions

File tree

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 FormsWizard
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/edit-timeline/features/timeline/Timeline.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function Timeline() {
6868

6969
/** Calculate a timeline event from a row of table data **/
7070
const eventFromRow = useCallback( (row: Row, index: number) => (
71-
{
71+
mapping && {
7272
id: row.id,
7373
content: _.get(row, mapping.content),
7474
start: _.get(row, mapping.start),
@@ -82,22 +82,18 @@ export function Timeline() {
8282
tableData
8383
.map(eventFromRow)
8484
.filter(
85-
(event) => event.start
85+
(event) => event && event.start
8686
) /** entries with missing start are not valid **/,
8787
[tableData]
8888
);
8989
console.log({tableData, mapping, items})
9090

9191
const handleMove = useCallback( (dispatch: AppDispatch, item: Item, callback: any) => {
9292
/** TODO we could use a reducer, that is setting both dates in one dispatch **/
93-
dispatch(
94-
setCellData([
95-
item._rowIdx,
96-
mapping.start,
97-
item.start?.toISOString().slice(0, 19),
98-
])
93+
mapping && dispatch(
94+
setCellData([item._rowIdx, mapping.start, item.start?.toISOString().slice(0, 19)])
9995
);
100-
dispatch(
96+
mapping && dispatch(
10197
setCellData([item._rowIdx, mapping.end, item.end?.toISOString().slice(0, 19)])
10298
);
10399
callback(item);
@@ -110,7 +106,7 @@ export function Timeline() {
110106
);
111107
const onSelect = useCallback(
112108
(selectionArgs: { items: number[] }) =>
113-
handleSelect(dispatch, selectionArgs, items),
109+
items && handleSelect(dispatch, selectionArgs, items),
114110
[dispatch, items]
115111
);
116112

@@ -119,7 +115,7 @@ export function Timeline() {
119115
...defaultOptions,
120116
};
121117

122-
return (
118+
return items && (
123119
<div>
124120
<VisTimelineWrapper options={options} items={items} onSelect={onSelect} />
125121
</div>

0 commit comments

Comments
 (0)