-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
a7483e0
commit 719a192
Showing
9 changed files
with
191 additions
and
51 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
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,98 @@ | ||
import React from "react"; | ||
|
||
import { Select } from "antd"; | ||
const Option = Select.Option; | ||
|
||
class ColumnFilter extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
showColumns: [], | ||
}; | ||
} | ||
|
||
componentDidMount = () => { | ||
this.setColumns(this.props.columns); | ||
}; | ||
|
||
componentDidUpdate = (nextProps) => { | ||
if (!this.props.columns || this.props.columns.length === 0) { | ||
this.setColumns(nextProps.columns); | ||
} | ||
}; | ||
setColumns = (columns) => { | ||
let excludeColumns = JSON.parse( | ||
localStorage.getItem("colplus_datasetlist_hide_columns") | ||
) || [ | ||
"creator", | ||
"version", | ||
"confidence", | ||
"editor", | ||
"geographicScope", | ||
"private", | ||
"modified", | ||
"created", | ||
"completeness", | ||
]; | ||
// Handle metadata update | ||
if (excludeColumns.includes("organisations")) { | ||
excludeColumns = [ | ||
"creator", | ||
"version", | ||
"confidence", | ||
"editor", | ||
"geographicScope", | ||
"private", | ||
"modified", | ||
"created", | ||
"completeness", | ||
]; | ||
} | ||
|
||
this.setState({ | ||
showColumns: columns | ||
.filter((c) => !excludeColumns.includes(c.key)) | ||
.map((c) => c.key), | ||
}); | ||
}; | ||
|
||
handleHideColumnChange = (showColumns) => { | ||
const { columns } = this.props; | ||
const excludeColumns = columns | ||
.filter((c) => !showColumns.includes(c.key)) | ||
.map((c) => c.key); | ||
localStorage.setItem( | ||
"colplus_datasetlist_hide_columns", | ||
JSON.stringify(excludeColumns) | ||
); | ||
this.setState({ showColumns }, () => { | ||
this.props.onChange(excludeColumns); | ||
}); | ||
}; | ||
|
||
render = () => { | ||
const { showColumns } = this.state; | ||
const { columns } = this.props; | ||
return ( | ||
<Select | ||
style={{ width: "100%" }} | ||
mode="multiple" | ||
placeholder="Please select" | ||
value={showColumns} | ||
onChange={this.handleHideColumnChange} | ||
showSearch | ||
maxTagCount={4} | ||
> | ||
{columns.map((f) => { | ||
return ( | ||
<Option key={f.key} value={f.key}> | ||
{f.title} | ||
</Option> | ||
); | ||
})} | ||
</Select> | ||
); | ||
}; | ||
} | ||
|
||
export default ColumnFilter; |
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,13 @@ | ||
import React from "react"; | ||
import Layout from "../../components/LayoutNew"; | ||
import { withRouter } from "react-router"; | ||
import NameSearch from "./index"; | ||
const NameUsageSearch = ({ location }) => { | ||
return ( | ||
<Layout selectedKeys={"NameUsageSearch"}> | ||
<NameSearch location={location} /> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default withRouter(NameUsageSearch); |
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