mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
removed FilterInput functionality from page and added new ui-component
This commit is contained in:
@@ -0,0 +1,69 @@
|
|||||||
|
//@flow
|
||||||
|
import React from "react";
|
||||||
|
import injectSheet from "react-jss";
|
||||||
|
import classNames from "classnames";
|
||||||
|
import { translate } from "react-i18next";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
filter: string => void,
|
||||||
|
|
||||||
|
// context props
|
||||||
|
classes: Object,
|
||||||
|
t: string => string
|
||||||
|
};
|
||||||
|
|
||||||
|
type State = {
|
||||||
|
value: string
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = {
|
||||||
|
inputField: {
|
||||||
|
float: "right",
|
||||||
|
marginTop: "1.25rem",
|
||||||
|
marginRight: "1.25rem"
|
||||||
|
},
|
||||||
|
inputHeight: {
|
||||||
|
height: "2.5rem"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class FilterInput extends React.Component<Props, State> {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { value: "" };
|
||||||
|
}
|
||||||
|
|
||||||
|
handleChange = event => {
|
||||||
|
this.setState({ value: event.target.value });
|
||||||
|
};
|
||||||
|
|
||||||
|
handleSubmit = event => {
|
||||||
|
this.props.filter(this.state.value);
|
||||||
|
event.preventDefault();
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { classes, t } = this.props;
|
||||||
|
return (
|
||||||
|
<form
|
||||||
|
className={classNames(classes.inputField, "input-field")}
|
||||||
|
onSubmit={this.handleSubmit}
|
||||||
|
>
|
||||||
|
<div className="control has-icons-left">
|
||||||
|
<input
|
||||||
|
className={classNames(classes.inputHeight, "input")}
|
||||||
|
type="search"
|
||||||
|
placeholder={t("filterEntries")}
|
||||||
|
value={this.state.value}
|
||||||
|
onChange={this.handleChange}
|
||||||
|
/>
|
||||||
|
<span className="icon is-small is-left">
|
||||||
|
<i className="fas fa-search" />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default injectSheet(styles)(translate("commons")(FilterInput));
|
||||||
@@ -5,6 +5,7 @@ export { default as AutocompleteAddEntryToTableField } from "./AutocompleteAddEn
|
|||||||
export { default as MemberNameTable } from "./MemberNameTable.js";
|
export { default as MemberNameTable } from "./MemberNameTable.js";
|
||||||
export { default as Checkbox } from "./Checkbox.js";
|
export { default as Checkbox } from "./Checkbox.js";
|
||||||
export { default as Radio } from "./Radio.js";
|
export { default as Radio } from "./Radio.js";
|
||||||
|
export { default as FilterInput } from "./FilterInput.js";
|
||||||
export { default as InputField } from "./InputField.js";
|
export { default as InputField } from "./InputField.js";
|
||||||
export { default as Select } from "./Select.js";
|
export { default as Select } from "./Select.js";
|
||||||
export { default as Textarea } from "./Textarea.js";
|
export { default as Textarea } from "./Textarea.js";
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import injectSheet from "react-jss";
|
import injectSheet from "react-jss";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { translate } from "react-i18next";
|
|
||||||
import Loading from "./../Loading";
|
import Loading from "./../Loading";
|
||||||
import ErrorNotification from "./../ErrorNotification";
|
import ErrorNotification from "./../ErrorNotification";
|
||||||
import Title from "./Title";
|
import Title from "./Title";
|
||||||
@@ -10,10 +9,6 @@ import Subtitle from "./Subtitle";
|
|||||||
import PageActions from "./PageActions";
|
import PageActions from "./PageActions";
|
||||||
import ErrorBoundary from "../ErrorBoundary";
|
import ErrorBoundary from "../ErrorBoundary";
|
||||||
|
|
||||||
type State = {
|
|
||||||
value: string
|
|
||||||
};
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
title?: string,
|
title?: string,
|
||||||
subtitle?: string,
|
subtitle?: string,
|
||||||
@@ -21,46 +16,19 @@ type Props = {
|
|||||||
error?: Error,
|
error?: Error,
|
||||||
showContentOnError?: boolean,
|
showContentOnError?: boolean,
|
||||||
children: React.Node,
|
children: React.Node,
|
||||||
filter: string => void,
|
|
||||||
|
|
||||||
// context props
|
// context props
|
||||||
classes: Object,
|
classes: Object
|
||||||
t: string => string
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
actions: {
|
actions: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "flex-end"
|
justifyContent: "flex-end"
|
||||||
},
|
|
||||||
inputField: {
|
|
||||||
float: "right",
|
|
||||||
marginTop: "1.25rem",
|
|
||||||
marginRight: "1.25rem"
|
|
||||||
},
|
|
||||||
inputHeight: {
|
|
||||||
height: "2.5rem"
|
|
||||||
},
|
|
||||||
button: {
|
|
||||||
float: "right",
|
|
||||||
marginTop: "1.25rem"
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Page extends React.Component<Props, State> {
|
class Page extends React.Component<Props> {
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = { value: "" };
|
|
||||||
}
|
|
||||||
|
|
||||||
handleChange = event => {
|
|
||||||
this.setState({ value: event.target.value });
|
|
||||||
};
|
|
||||||
|
|
||||||
handleSubmit = event => {
|
|
||||||
this.props.filter(this.state.value);
|
|
||||||
event.preventDefault();
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { error } = this.props;
|
const { error } = this.props;
|
||||||
@@ -78,7 +46,7 @@ class Page extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderPageHeader() {
|
renderPageHeader() {
|
||||||
const { error, title, subtitle, children, classes, t } = this.props;
|
const { error, title, subtitle, children, classes } = this.props;
|
||||||
|
|
||||||
let pageActions = null;
|
let pageActions = null;
|
||||||
let pageActionsExists = false;
|
let pageActionsExists = false;
|
||||||
@@ -91,26 +59,7 @@ class Page extends React.Component<Props, State> {
|
|||||||
"column is-three-fifths is-mobile-action-spacing"
|
"column is-three-fifths is-mobile-action-spacing"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<form
|
{child}
|
||||||
className={classNames(classes.inputField, "input-field")}
|
|
||||||
onSubmit={this.handleSubmit}
|
|
||||||
>
|
|
||||||
<div className="control has-icons-left">
|
|
||||||
<input
|
|
||||||
className={classNames(classes.inputHeight, "input")}
|
|
||||||
type="search"
|
|
||||||
placeholder={t("filterEntries")}
|
|
||||||
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.button, "input-button control")}>
|
|
||||||
{child}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
pageActionsExists = true;
|
pageActionsExists = true;
|
||||||
@@ -154,4 +103,4 @@ class Page extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default injectSheet(styles)(translate("commons")(Page));
|
export default injectSheet(styles)(Page);
|
||||||
|
|||||||
Reference in New Issue
Block a user