-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query Node Editor higher-order component (#71)
* Rename QueryNodeModal -> QueryNodeEditor, refactor interface as HOC * Adapt tests * Clean up
- Loading branch information
Showing
33 changed files
with
422 additions
and
600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
105 changes: 0 additions & 105 deletions
105
frontend/lib/js/external-forms/common/FormQueryNodeModal.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @flow | ||
|
||
import type { ElementType } from '../standard-query-editor/types'; | ||
|
||
import { tablesHaveActiveFilter } from './table'; | ||
|
||
export const nodeHasActiveFilters = (node, tables = node.tables) => | ||
node.excludeTimestamps || | ||
nodeHasActiveTableFilters(node, tables) || | ||
nodeHasExludedTable(node, tables); | ||
|
||
export const nodeHasActiveTableFilters = (node: ElementType, tables = node.tables) => { | ||
if (!tables) return false; | ||
return tablesHaveActiveFilter(tables); | ||
}; | ||
|
||
export const nodeHasExludedTable = (node: ElementType, tables = node.tables) => { | ||
if (!tables) return false; | ||
return tables.some(table => table.exclude); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// @flow | ||
|
||
import type { TableType } from '../standard-query-editor/types'; | ||
|
||
import { isEmpty } from '../common/helpers'; | ||
|
||
export const tablesHaveActiveFilter = (tables: TableType[]) => | ||
tables.some(table => tableHasActiveFilters(table)); | ||
|
||
export const tableHasActiveFilters = (table: TableType) => | ||
table.filters && | ||
table.filters.some(filter => !isEmpty(filter.value) && filter.value !== filter.defaultValue); | ||
|
||
export const resetAllFiltersInTables = (tables: TableType[]) => { | ||
return (tables || []).map(table => { | ||
const filters = table.filters | ||
// It's actually a FilterType, but flow can't decide which one | ||
// of the intersections it is | ||
// $FlowFixMe | ||
? table.filters.map((filter) => ({ | ||
...filter, | ||
value: filter.defaultValue | ||
})) | ||
: null; | ||
|
||
return { | ||
...table, | ||
filters, | ||
exclude: false, | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.