-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
154 changed files
with
3,246 additions
and
1,867 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 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 |
---|---|---|
@@ -1,6 +1,14 @@ | ||
{ | ||
"exclude": [ | ||
"node_modules", | ||
"**/node_modules/*" | ||
"**/node_modules/*", | ||
"build", | ||
"buildzip", | ||
"coverage", | ||
"docs", | ||
"flow", | ||
"flow-typed", | ||
"i18n", | ||
"public" | ||
] | ||
} |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// @flow | ||
|
||
export { default as withTransformPropName } from './withTransformPropName'; | ||
export { default as withLoadingIndicator } from './withLoadingIndicator'; | ||
export { default as withErrorMessageHandler } from './withErrorMessageHandler'; |
29 changes: 19 additions & 10 deletions
29
src/core_modules/capture-core/components/App/isSelectionsEqual.js
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 |
---|---|---|
@@ -1,25 +1,34 @@ | ||
// @flow | ||
/* | ||
The first argument must be a complete selections set | ||
*/ | ||
|
||
const CATEGORIES_KEY = 'categories'; | ||
const COMPLETE_KEY = 'complete'; | ||
|
||
const isSelectionsEqual = (completeSet1: Object, set2: Object) => | ||
Object | ||
.keys(completeSet1) | ||
.filter(key => key !== COMPLETE_KEY && completeSet1[key] != null) | ||
const isSelectionsEqual = (set1: Object, set2: Object) => { | ||
const set1Keys = Object | ||
.keys(set1) | ||
.filter(key => | ||
key !== COMPLETE_KEY && set1[key] && (typeof set1[key] !== 'object' || Object.keys(set1[key]).length > 0)); | ||
|
||
const set2Keys = Object | ||
.keys(set2) | ||
.filter(key => | ||
key !== COMPLETE_KEY && set2[key] && (typeof set2[key] !== 'object' || Object.keys(set2[key]).length > 0)); | ||
|
||
if (set1Keys.length !== set2Keys.length) { | ||
return false; | ||
} | ||
|
||
return set1Keys | ||
.every((key) => { | ||
const value1 = completeSet1[key]; | ||
const value1 = set1[key]; | ||
const value2 = set2[key]; | ||
|
||
if (key === CATEGORIES_KEY) { | ||
const isCategoriesEqual = isSelectionsEqual(completeSet1.categories, set2.categories); | ||
return isCategoriesEqual; | ||
return isSelectionsEqual(set1.categories, set2.categories); | ||
} | ||
|
||
return value1 === value2; | ||
}); | ||
}; | ||
|
||
export default isSelectionsEqual; |
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
57 changes: 57 additions & 0 deletions
57
...dules/capture-core/components/FiltersForTypes/Assignee/AssigneeFilterManager.component.js
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,57 @@ | ||
// @flow | ||
import * as React from 'react'; | ||
import AssigneeFilter from './AssigneeFilter.component'; | ||
import type { AssigneeFilterData } from '../filters.types'; | ||
|
||
type Props = { | ||
filter: ?AssigneeFilterData, | ||
filterTypeRef: ?Function, | ||
}; | ||
|
||
type State = { | ||
value?: ?{ | ||
mode?: ?string, | ||
provided?: ?Object, | ||
}, | ||
}; | ||
|
||
class AssigneeFilterManager extends React.Component<Props, State> { | ||
static calculateDefaultValueState(filter: ?AssigneeFilterData) { | ||
if (!filter) { | ||
return undefined; | ||
} | ||
|
||
return { | ||
mode: filter.assignedUserMode, | ||
provided: filter.assignedUser, | ||
}; | ||
} | ||
|
||
constructor(props: Props) { | ||
super(props); | ||
this.state = { | ||
value: AssigneeFilterManager.calculateDefaultValueState(this.props.filter), | ||
}; | ||
} | ||
|
||
handleCommitValue = (value: ?Object) => { | ||
this.setState({ | ||
value, | ||
}); | ||
} | ||
|
||
render() { | ||
const { filter, filterTypeRef, ...passOnProps } = this.props; | ||
|
||
return ( | ||
<AssigneeFilter | ||
value={this.state.value} | ||
innerRef={filterTypeRef} | ||
onCommitValue={this.handleCommitValue} | ||
{...passOnProps} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
export default AssigneeFilterManager; |
12 changes: 0 additions & 12 deletions
12
src/core_modules/capture-core/components/FiltersForTypes/Assignee/assigneeFilterData.js
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
...core_modules/capture-core/components/FiltersForTypes/Assignee/assigneeFilterDataGetter.js
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,9 @@ | ||
// @flow | ||
import type { AssigneeFilterData } from '../filters.types'; | ||
|
||
export function getAssigneeFilterData(value: Object): AssigneeFilterData { | ||
return { | ||
assignedUserMode: value.mode, | ||
assignedUser: value.provided, | ||
}; | ||
} |
4 changes: 2 additions & 2 deletions
4
src/core_modules/capture-core/components/FiltersForTypes/Assignee/index.js
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// @flow | ||
export { default as AssigneeFilter } from './AssigneeFilter.component'; | ||
export { getAssigneeFilterData } from './assigneeFilterData'; | ||
export { default as AssigneeFilter } from './AssigneeFilterManager.component'; | ||
export { getAssigneeFilterData } from './assigneeFilterDataGetter'; | ||
export { modeKeys } from './modeOptions'; |
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
53 changes: 53 additions & 0 deletions
53
...modules/capture-core/components/FiltersForTypes/Boolean/BooleanFilterManager.component.js
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,53 @@ | ||
// @flow | ||
import * as React from 'react'; | ||
import BooleanFilter from './BooleanFilter.component'; | ||
import type { BooleanFilterData } from '../filters.types'; | ||
|
||
type Props = { | ||
filter: ?BooleanFilterData, | ||
filterTypeRef: Function, | ||
}; | ||
|
||
type State = { | ||
value: ?Array<string>, | ||
}; | ||
|
||
class BooleanFilterManager extends React.Component<Props, State> { | ||
static calculateDefaultValueState(filter: ?BooleanFilterData): ?Array<string> { | ||
if (!filter) { | ||
return undefined; | ||
} | ||
|
||
return filter | ||
.values | ||
.map(value => (value ? 'true' : 'false')); | ||
} | ||
|
||
constructor(props: Props) { | ||
super(props); | ||
this.state = { | ||
value: BooleanFilterManager.calculateDefaultValueState(this.props.filter), | ||
}; | ||
} | ||
|
||
handleCommitValue = (value: ?Array<string>) => { | ||
this.setState({ | ||
value, | ||
}); | ||
} | ||
|
||
render() { | ||
const { filter, filterTypeRef, ...passOnProps } = this.props; | ||
|
||
return ( | ||
<BooleanFilter | ||
value={this.state.value} | ||
innerRef={filterTypeRef} | ||
onCommitValue={this.handleCommitValue} | ||
{...passOnProps} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
export default BooleanFilterManager; |
11 changes: 11 additions & 0 deletions
11
src/core_modules/capture-core/components/FiltersForTypes/Boolean/booleanFilterDataGetter.js
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,11 @@ | ||
// @flow | ||
import type { BooleanFilterData } from '../filters.types'; | ||
|
||
export function getBooleanFilterData( | ||
values: Array<string>, | ||
): BooleanFilterData { | ||
return { | ||
values: values | ||
.map(value => (value === 'true')), | ||
}; | ||
} |
34 changes: 0 additions & 34 deletions
34
src/core_modules/capture-core/components/FiltersForTypes/Boolean/getBooleanFilterData.js
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
src/core_modules/capture-core/components/FiltersForTypes/Boolean/index.js
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,2 @@ | ||
// @flow | ||
export { default as BooleanFilter } from './BooleanFilterManager.component'; |
Oops, something went wrong.