mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
ui search field done, started adding filter functionality
This commit is contained in:
@@ -9,6 +9,10 @@ import classNames from "classnames";
|
||||
import PageActions from "./PageActions";
|
||||
import ErrorBoundary from "../ErrorBoundary";
|
||||
|
||||
type State = {
|
||||
value: string
|
||||
};
|
||||
|
||||
type Props = {
|
||||
title?: string,
|
||||
subtitle?: string,
|
||||
@@ -16,19 +20,49 @@ type Props = {
|
||||
error?: Error,
|
||||
showContentOnError?: boolean,
|
||||
children: React.Node,
|
||||
filter: string => void,
|
||||
|
||||
// context props
|
||||
classes: Object
|
||||
};
|
||||
|
||||
const styles = {
|
||||
spacing: {
|
||||
actions: {
|
||||
display: "flex",
|
||||
justifyContent: "flex-end"
|
||||
},
|
||||
inputField: {
|
||||
float: "right",
|
||||
marginTop: "1.25rem",
|
||||
textAlign: "right"
|
||||
marginRight: "1.25rem"
|
||||
},
|
||||
inputHeight: {
|
||||
height: "2.5rem"
|
||||
},
|
||||
button: {
|
||||
float: "right",
|
||||
marginTop: "1.25rem"
|
||||
}
|
||||
};
|
||||
|
||||
class Page extends React.Component<Props> {
|
||||
class Page extends React.Component<Props, State> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { value: "" };
|
||||
|
||||
this.handleChange = this.handleChange.bind(this);
|
||||
this.handleSubmit = this.handleSubmit.bind(this);
|
||||
}
|
||||
|
||||
handleChange(event) {
|
||||
this.setState({ value: event.target.value });
|
||||
}
|
||||
|
||||
handleSubmit(event) {
|
||||
this.props.filter(this.state.value);
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { error } = this.props;
|
||||
return (
|
||||
@@ -41,7 +75,6 @@ class Page extends React.Component<Props> {
|
||||
</ErrorBoundary>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,11 +86,30 @@ class Page extends React.Component<Props> {
|
||||
React.Children.forEach(children, child => {
|
||||
if (child && child.type.name === PageActions.name) {
|
||||
pageActions = (
|
||||
<div className="column is-two-fifths">
|
||||
<div
|
||||
className={classNames(classes.actions, "column is-three-fifths is-mobile-action-spacing")}
|
||||
>
|
||||
<form className={classNames(classes.inputField, "input-field")}>
|
||||
<div
|
||||
className="control has-icons-left"
|
||||
onSubmit={this.handleSubmit}
|
||||
>
|
||||
<input
|
||||
className={classNames(classes.inputHeight, "input")}
|
||||
type="search"
|
||||
placeholder="filter text"
|
||||
value={this.state.value}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
<span className="icon is-small is-left">
|
||||
<i className="fas fa-search" />
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
<div
|
||||
className={classNames(
|
||||
classes.spacing,
|
||||
"is-mobile-create-button-spacing"
|
||||
classes.button,
|
||||
"input-button control"
|
||||
)}
|
||||
>
|
||||
{child}
|
||||
|
||||
@@ -39,7 +39,7 @@ type Props = {
|
||||
history: History,
|
||||
|
||||
// dispatch functions
|
||||
fetchUsersByPage: (link: string, page: number) => void,
|
||||
fetchUsersByPage: (link: string, page: number, filter?: string) => void,
|
||||
fetchUsersByLink: (link: string) => void
|
||||
};
|
||||
|
||||
@@ -74,6 +74,9 @@ class Users extends React.Component<Props> {
|
||||
subtitle={t("users.subtitle")}
|
||||
loading={loading || !users}
|
||||
error={error}
|
||||
filter={filter => {
|
||||
this.props.fetchUsersByPage(this.props.usersLink, this.props.page, filter);
|
||||
}}
|
||||
>
|
||||
<UserTable users={users} />
|
||||
{this.renderPaginator()}
|
||||
@@ -152,8 +155,8 @@ const mapStateToProps = (state, ownProps) => {
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
fetchUsersByPage: (link: string, page: number) => {
|
||||
dispatch(fetchUsersByPage(link, page));
|
||||
fetchUsersByPage: (link: string, page: number, filter?: string) => {
|
||||
dispatch(fetchUsersByPage(link, page, filter));
|
||||
},
|
||||
fetchUsersByLink: (link: string) => {
|
||||
dispatch(fetchUsersByLink(link));
|
||||
|
||||
@@ -43,8 +43,11 @@ export function fetchUsers(link: string) {
|
||||
return fetchUsersByLink(link);
|
||||
}
|
||||
|
||||
export function fetchUsersByPage(link: string, page: number) {
|
||||
export function fetchUsersByPage(link: string, page: number, filter?: string) {
|
||||
// backend start counting by 0
|
||||
if(filter) {
|
||||
return fetchUsersByLink(link + "?page=" + (page - 1) + "&q=" + decodeURIComponent(filter));
|
||||
}
|
||||
return fetchUsersByLink(link + "?page=" + (page - 1));
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,16 @@ hr.header-with-actions {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.is-mobile-create-button-spacing {
|
||||
.is-mobile-action-spacing {
|
||||
@media screen and (max-width: 768px) {
|
||||
display: flow-root !important;
|
||||
|
||||
.input-field {
|
||||
padding: 0;
|
||||
margin: 0 0 1.25rem 0 !important;
|
||||
width: 100%;
|
||||
}
|
||||
.input-button {
|
||||
border: 2px solid #e9f7fd;
|
||||
padding: 1em 1em;
|
||||
margin-top: 0 !important;
|
||||
@@ -58,6 +66,7 @@ hr.header-with-actions {
|
||||
text-align: center !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.footer {
|
||||
height: 50px;
|
||||
@@ -102,10 +111,12 @@ $fa-font-path: "webfonts";
|
||||
&.is-primary {
|
||||
background-color: #00d1df;
|
||||
}
|
||||
&.is-primary:hover, &.is-primary.is-hovered {
|
||||
&.is-primary:hover,
|
||||
&.is-primary.is-hovered {
|
||||
background-color: #00b9c6;
|
||||
}
|
||||
&.is-primary:active, &.is-primary.is-active {
|
||||
&.is-primary:active,
|
||||
&.is-primary.is-active {
|
||||
background-color: #00a1ac;
|
||||
}
|
||||
&.is-primary[disabled] {
|
||||
|
||||
Reference in New Issue
Block a user