vis-chronicle 1.2.2 → 1.2.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/render.js +22 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vis-chronicle",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Generates JSON for populating a vis.js timeline from Wikidata queries.",
5
5
  "keywords": [
6
6
  "wikidata",
package/src/render.js CHANGED
@@ -35,6 +35,18 @@ function momentSafeMax(a, b)
35
35
  return a ? (b ? moment.max(a, b) : a) : b
36
36
  }
37
37
 
38
+ // Copies properties that should be untouched by the renderer from 'from' to 'to'
39
+ function copyItemUntouchedProps(from, to)
40
+ {
41
+ to.align = from.align
42
+ to.selectable = from.selectable
43
+ to.style = from.style
44
+ to.title = from.title
45
+ to.limitSize = from.limitSize
46
+ to.editable = from.editable
47
+ to.wikidata = from.entity
48
+ }
49
+
38
50
  const renderer = {}
39
51
 
40
52
  renderer.getExpectation = function(item)
@@ -197,9 +209,9 @@ renderer.produceOutput = function(inputSpec, items)
197
209
  content: item.label,
198
210
  className: item.className,
199
211
  comment: item.comment,
200
- type: item.type,
201
- wikidata: item.entity
212
+ type: item.type
202
213
  }
214
+ copyItemUntouchedProps(item, outputItem)
203
215
  if (item.group)
204
216
  {
205
217
  outputItem.group = item.group
@@ -287,9 +299,9 @@ renderer.produceOutput = function(inputSpec, items)
287
299
  start: uncertainMin,
288
300
  end: item.end_max,
289
301
  group: item.group,
290
- subgroup: outputItem.subgroup,
291
- wikidata: item.entity
302
+ subgroup: outputItem.subgroup
292
303
  }
304
+ copyItemUntouchedProps(item, uncertainElement)
293
305
  outputObject.items.push(uncertainElement)
294
306
 
295
307
  if (permitBgOverlay)
@@ -344,9 +356,9 @@ renderer.produceOutput = function(inputSpec, items)
344
356
  start: outputItem.end,
345
357
  end: tailEnd,
346
358
  group: item.group,
347
- subgroup: outputItem.subgroup,
348
- wikidata: item.entity
359
+ subgroup: outputItem.subgroup
349
360
  })
361
+ copyItemUntouchedProps(item, outputObject)
350
362
 
351
363
  outputItem.className = [ outputItem.className, 'visc-right-connection' ].join(' ')
352
364
  }
@@ -367,9 +379,9 @@ renderer.produceOutput = function(inputSpec, items)
367
379
  start: outputItem.end,
368
380
  end: tailEnd,
369
381
  group: item.group,
370
- subgroup: outputItem.subgroup,
371
- wikidata: item.entity
382
+ subgroup: outputItem.subgroup
372
383
  })
384
+ copyItemUntouchedProps(item, outputObject)
373
385
 
374
386
  outputItem.className = [ outputItem.className, 'visc-right-connection' ].join(' ')
375
387
  }
@@ -410,9 +422,9 @@ renderer.produceOutput = function(inputSpec, items)
410
422
  start: item.start_min,
411
423
  end: uncertainMax,
412
424
  group: item.group,
413
- subgroup: outputItem.subgroup,
414
- wikidata: item.entity
425
+ subgroup: outputItem.subgroup
415
426
  }
427
+ copyItemUntouchedProps(item, uncertainElement)
416
428
  outputObject.items.push(uncertainElement)
417
429
 
418
430
  if (permitBgOverlay)