Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix link from tasks list to task type #2769

Merged
merged 2 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/assets/javascripts/admin/tasktype/task_type_list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const { Search } = Input;

type Props = {
history: RouterHistory,
initialSearchValue?: string,
};

type State = {
Expand All @@ -41,6 +42,11 @@ class TaskTypeListView extends React.PureComponent<Props, State> {

componentWillMount() {
this.setState(persistence.load(this.props.history));
if (this.props.initialSearchValue && this.props.initialSearchValue !== "") {
this.setState({
searchQuery: this.props.initialSearchValue,
});
}
}

componentDidMount() {
Expand Down
5 changes: 4 additions & 1 deletion app/assets/javascripts/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ class ReactRouter extends React.Component<Props> {
<SecuredRoute
isAuthenticated={isAuthenticated}
path="/taskTypes"
component={TaskTypeListView}
render={({ location }: ContextRouter) => (
// Strip the leading # away. If there is no hash, "".slice(1) will evaluate to "", too.
<TaskTypeListView initialSearchValue={location.hash.slice(1)} />
)}
exact
/>
<SecuredRoute
Expand Down