mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 05:18:34 +03:00
add support for showing filter descriptions in narrativised mode
This commit is contained in:
@@ -7,7 +7,7 @@ import narrativeSchema from './narrativeSchema'
|
||||
import sourceSchema from './sourceSchema'
|
||||
import shapeSchema from './shapeSchema'
|
||||
|
||||
import { calcDatetime, capitalize } from '../../common/utilities'
|
||||
import { calcDatetime, capitalize, isFilterLeaf, isFilterDuplicate } from '../../common/utilities'
|
||||
|
||||
/*
|
||||
* Create an error notification object
|
||||
@@ -25,9 +25,6 @@ function isValidDate (d) {
|
||||
return d instanceof Date && !isNaN(d)
|
||||
}
|
||||
|
||||
const isLeaf = node => (Object.keys(node.children).length === 0)
|
||||
const isDuplicate = (node, set) => { return (set.has(node.key)) }
|
||||
|
||||
/*
|
||||
* Traverse a filter tree and check its duplicates. Also recompose as
|
||||
* description if `features.USE_FILTER_DESCRIPTIONS` is true.
|
||||
@@ -47,7 +44,7 @@ function validateFilterTree (node, parent, set, duplicates, hasFilterDescription
|
||||
parent.children = node.children
|
||||
delete parent.isDescription
|
||||
}
|
||||
if (isLeaf(node)) {
|
||||
if (isFilterLeaf(node)) {
|
||||
delete parent.isDescription
|
||||
}
|
||||
}
|
||||
@@ -56,8 +53,8 @@ function validateFilterTree (node, parent, set, duplicates, hasFilterDescription
|
||||
return
|
||||
}
|
||||
// If it's a leaf, check that it's not duplicate
|
||||
if (isLeaf(node)) {
|
||||
if (isDuplicate(node, set)) {
|
||||
if (isFilterLeaf(node)) {
|
||||
if (isFilterDuplicate(node, set)) {
|
||||
duplicates.push({
|
||||
id: node.key,
|
||||
error: makeError('Filters', node.key, 'filter was found more than once in hierarchy. Ignoring duplicate.')
|
||||
|
||||
Reference in New Issue
Block a user