Skip to content
Snippets Groups Projects
Commit 438fbb6d authored by esikkala's avatar esikkala
Browse files

JavaScript standard style patches

parent 85d044df
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ import ChipsArray from './ChipsArray' ...@@ -6,7 +6,7 @@ import ChipsArray from './ChipsArray'
const ActiveFilters = props => { const ActiveFilters = props => {
const { uriFilters, textFilters, timespanFilters, integerFilters, facetClass, someFacetIsFetching, fetchingResultCount } = props const { uriFilters, textFilters, timespanFilters, integerFilters, facetClass, someFacetIsFetching, fetchingResultCount } = props
const facetValues = [] const facetValues = []
Object.keys(uriFilters).map(activeFacetID => { Object.keys(uriFilters).forEach(activeFacetID => {
// URI filter may have multiple values // URI filter may have multiple values
Object.values(uriFilters[activeFacetID]).forEach(value => { Object.values(uriFilters[activeFacetID]).forEach(value => {
facetValues.push({ facetValues.push({
...@@ -17,7 +17,7 @@ const ActiveFilters = props => { ...@@ -17,7 +17,7 @@ const ActiveFilters = props => {
}) })
}) })
}) })
Object.keys(textFilters).map(facetID => { Object.keys(textFilters).forEach(facetID => {
facetValues.push({ facetValues.push({
facetID: facetID, facetID: facetID,
facetLabel: intl.get(`perspectives.${facetClass}.properties.${facetID}.label`), facetLabel: intl.get(`perspectives.${facetClass}.properties.${facetID}.label`),
...@@ -25,7 +25,7 @@ const ActiveFilters = props => { ...@@ -25,7 +25,7 @@ const ActiveFilters = props => {
value: textFilters[facetID] value: textFilters[facetID]
}) })
}) })
Object.keys(timespanFilters).map(facetID => { Object.keys(timespanFilters).forEach(facetID => {
facetValues.push({ facetValues.push({
facetID: facetID, facetID: facetID,
facetLabel: intl.get(`perspectives.${facetClass}.properties.${facetID}.label`), facetLabel: intl.get(`perspectives.${facetClass}.properties.${facetID}.label`),
...@@ -33,7 +33,7 @@ const ActiveFilters = props => { ...@@ -33,7 +33,7 @@ const ActiveFilters = props => {
value: timespanFilters[facetID] value: timespanFilters[facetID]
}) })
}) })
Object.keys(integerFilters).map(facetID => { Object.keys(integerFilters).forEach(facetID => {
facetValues.push({ facetValues.push({
facetID: facetID, facetID: facetID,
facetLabel: intl.get(`perspectives.${facetClass}.properties.${facetID}.label`), facetLabel: intl.get(`perspectives.${facetClass}.properties.${facetID}.label`),
......
...@@ -266,7 +266,8 @@ class FacetBar extends React.Component { ...@@ -266,7 +266,8 @@ class FacetBar extends React.Component {
facet={facet} facet={facet}
facetConstrainSelf={facetConstrainSelf} facetConstrainSelf={facetConstrainSelf}
facetConstrainSelfUpdateID={this.props.facetDataConstrainSelf facetConstrainSelfUpdateID={this.props.facetDataConstrainSelf
? this.props.facetDataConstrainSelf.facetUpdateID : null} ? this.props.facetDataConstrainSelf.facetUpdateID
: null}
isActive={isActive} isActive={isActive}
facetClass={this.props.facetClass} facetClass={this.props.facetClass}
resultClass={this.props.resultClass} resultClass={this.props.resultClass}
...@@ -319,9 +320,8 @@ class FacetBar extends React.Component { ...@@ -319,9 +320,8 @@ class FacetBar extends React.Component {
className={classes.accordionDetails} className={classes.accordionDetails}
/> />
{facets && Object.keys(facets).map(facetID => { {facets && Object.keys(facets).map(facetID => {
if (facetID !== 'datasetSelector') { if (facetID === 'datasetSelector') { return null }
return this.renderFacet(facetID, someFacetIsFetching) return this.renderFacet(facetID, someFacetIsFetching)
}
})} })}
</Accordion> </Accordion>
) )
...@@ -329,9 +329,8 @@ class FacetBar extends React.Component { ...@@ -329,9 +329,8 @@ class FacetBar extends React.Component {
return ( return (
<> <>
{facets && Object.keys(facets).map(facetID => { {facets && Object.keys(facets).map(facetID => {
if (facetID !== 'datasetSelector') { if (facetID === 'datasetSelector') { return null }
return this.renderFacet(facetID, someFacetIsFetching) return this.renderFacet(facetID, someFacetIsFetching)
}
})} })}
</> </>
) )
......
...@@ -70,7 +70,8 @@ class FacetHeader extends React.Component { ...@@ -70,7 +70,8 @@ class FacetHeader extends React.Component {
sortDirection = 'asc' // default sort direction when sorting by prefLabel sortDirection = 'asc' // default sort direction when sorting by prefLabel
} else { } else {
sortDirection = this.props.facet.sortDirection === 'asc' sortDirection = this.props.facet.sortDirection === 'asc'
? 'desc' : 'asc' ? 'desc'
: 'asc'
} }
} }
if (buttonID === 'instanceCount') { if (buttonID === 'instanceCount') {
...@@ -78,7 +79,8 @@ class FacetHeader extends React.Component { ...@@ -78,7 +79,8 @@ class FacetHeader extends React.Component {
sortDirection = 'desc' // default sort direction when sorting by instanceCount sortDirection = 'desc' // default sort direction when sorting by instanceCount
} else { } else {
sortDirection = this.props.facet.sortDirection === 'asc' sortDirection = this.props.facet.sortDirection === 'asc'
? 'desc' : 'asc' ? 'desc'
: 'asc'
} }
} }
this.props.updateFacetOption({ this.props.updateFacetOption({
......
...@@ -62,7 +62,8 @@ class HierarchicalFacet extends Component { ...@@ -62,7 +62,8 @@ class HierarchicalFacet extends Component {
super(props) super(props)
this.state = { this.state = {
treeData: this.props.facetedSearchMode === 'clientFS' || this.props.facetedSearchMode === 'storybook' treeData: this.props.facetedSearchMode === 'clientFS' || this.props.facetedSearchMode === 'storybook'
? this.props.facet.values : [], ? this.props.facet.values
: [],
searchString: '', searchString: '',
searchFocusIndex: 0, searchFocusIndex: 0,
searchFoundCount: null, searchFoundCount: null,
...@@ -84,7 +85,8 @@ class HierarchicalFacet extends Component { ...@@ -84,7 +85,8 @@ class HierarchicalFacet extends Component {
// console.log(this.props.facetedSearchMode) // console.log(this.props.facetedSearchMode)
// console.log(this.props) // console.log(this.props)
this.props.facetedSearchMode === 'clientFS' this.props.facetedSearchMode === 'clientFS'
? this.clientFScomponentDidUpdate(prevProps) : this.serverFScomponentDidUpdate(prevProps) ? this.clientFScomponentDidUpdate(prevProps)
: this.serverFScomponentDidUpdate(prevProps)
} }
clientFScomponentDidUpdate = prevProps => { clientFScomponentDidUpdate = prevProps => {
...@@ -304,72 +306,74 @@ class HierarchicalFacet extends Component { ...@@ -304,72 +306,74 @@ class HierarchicalFacet extends Component {
return ( return (
<> <>
{isFetching ? ( {isFetching
<div className={classes.spinnerContainer}> ? (
<CircularProgress style={{ color: purple[500] }} thickness={5} /> <div className={classes.spinnerContainer}>
</div> <CircularProgress style={{ color: purple[500] }} thickness={5} />
) : ( </div>
<> )
{searchField && facet.filterType !== 'spatialFilter' && : (
<div className={classes.facetSearchContainer}> <>
<Input {searchField && facet.filterType !== 'spatialFilter' &&
placeholder={intl.get('facetBar.facetSearchFieldPlaceholder')} <div className={classes.facetSearchContainer}>
onChange={this.handleSearchFieldOnChange} <Input
value={this.state.searchString} placeholder={intl.get('facetBar.facetSearchFieldPlaceholder')}
/> onChange={this.handleSearchFieldOnChange}
{searchFoundCount > 0 && value={this.state.searchString}
<> />
<IconButton {searchFoundCount > 0 &&
className={classes.facetSearchIconButton} <>
aria-label='Previous' <IconButton
onClick={selectPrevMatch} className={classes.facetSearchIconButton}
> aria-label='Previous'
<NavigateBeforeIcon /> onClick={selectPrevMatch}
</IconButton> >
<IconButton <NavigateBeforeIcon />
className={classes.facetSearchIconButton} </IconButton>
aria-label='Next' <IconButton
onClick={selectNextMatch} className={classes.facetSearchIconButton}
> aria-label='Next'
<NavigateNextIcon /> onClick={selectNextMatch}
</IconButton> >
<Typography> <NavigateNextIcon />
{searchFoundCount > 0 ? searchFocusIndex + 1 : 0} / {searchFoundCount || 0} </IconButton>
</Typography> <Typography>
</>} {searchFoundCount > 0 ? searchFocusIndex + 1 : 0} / {searchFoundCount || 0}
</div>} </Typography>
{facet.filterType !== 'spatialFilter' && </>}
<div className={searchField ? classes.treeContainerWithSearchField : classes.treeContainer}> </div>}
<SortableTree {facet.filterType !== 'spatialFilter' &&
treeData={this.state.treeData} <div className={searchField ? classes.treeContainerWithSearchField : classes.treeContainer}>
onChange={treeData => this.setState({ treeData })} <SortableTree
canDrag={false} treeData={this.state.treeData}
rowHeight={30} onChange={treeData => this.setState({ treeData })}
searchMethod={customSearchMethod} canDrag={false}
searchQuery={searchString} rowHeight={30}
searchFocusOffset={searchFocusIndex} searchMethod={customSearchMethod}
searchFinishCallback={matches => { searchQuery={searchString}
this.setState({ searchFocusOffset={searchFocusIndex}
searchFoundCount: matches.length, searchFinishCallback={matches => {
searchFocusIndex: this.setState({
searchFoundCount: matches.length,
searchFocusIndex:
matches.length > 0 ? searchFocusIndex % matches.length : 0, matches.length > 0 ? searchFocusIndex % matches.length : 0,
matches matches
}) })
}} }}
onlyExpandSearchedNodes onlyExpandSearchedNodes
theme={FileExplorerTheme} theme={FileExplorerTheme}
generateNodeProps={this.generateNodeProps} generateNodeProps={this.generateNodeProps}
isVirtualized={this.props.facetedSearchMode !== 'storybook'} // virtualization does not work in Storybook isVirtualized={this.props.facetedSearchMode !== 'storybook'}
/> />
</div>} </div>}
{facet.filterType === 'spatialFilter' && {facet.filterType === 'spatialFilter' &&
<div className={classes.spinnerContainer}> <div className={classes.spinnerContainer}>
<Typography> <Typography>
Draw a bounding box on the map to filter by {intl.get(`perspectives.${facetClass}.properties.${facetID}.label`)}. Draw a bounding box on the map to filter by {intl.get(`perspectives.${facetClass}.properties.${facetID}.label`)}.
</Typography> </Typography>
</div>} </div>}
</> </>
)} )}
</> </>
) )
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment