From cf979336e5dfd45aec7460a0b4dae9f62c2e2e27 Mon Sep 17 00:00:00 2001 From: Frode Sjovatsen Date: Wed, 26 Sep 2018 13:49:21 +0200 Subject: [PATCH] fixed issues #18, #26 and #27 --- client/src/common/utils/Sort.js | 17 +++++++++++++++++ client/src/features/adapter/AdapterList.js | 5 ++++- client/src/features/clients/ClientList.js | 5 ++++- client/src/features/component/ComponentList.js | 4 +++- 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 client/src/common/utils/Sort.js diff --git a/client/src/common/utils/Sort.js b/client/src/common/utils/Sort.js new file mode 100644 index 0000000..f685849 --- /dev/null +++ b/client/src/common/utils/Sort.js @@ -0,0 +1,17 @@ +class Sort { + + static alphabetically(a, b) { + if (a.description) { + if (a.description < b.description) return -1; + else if (a.description > b.description) return 1; + return 0; + } + if (a.shortDescription) { + if (a.shortDescription < b.shortDescription) return -1; + else if (a.shortDescription > b.shortDescription) return 1; + return 0; + } + } +} + +export default Sort; diff --git a/client/src/features/adapter/AdapterList.js b/client/src/features/adapter/AdapterList.js index eda7d8e..6cd3916 100644 --- a/client/src/features/adapter/AdapterList.js +++ b/client/src/features/adapter/AdapterList.js @@ -18,6 +18,7 @@ import { withContext } from "../../data/context/withContext"; import PropTypes from "prop-types"; import FeatureHelperText from "../../common/help/FeatureHelperText"; import WarningMessageBox from "../../common/message-box/WarningMessageBox"; +import Sort from "../../common/utils/Sort"; const styles = theme => ({ root: { @@ -104,6 +105,8 @@ class AdapterList extends Component { render() { const { classes } = this.props; + const adapters = this.props.adapters.sort(Sort.alphabetically); + return (
Adapter - {this.props.adapters.map((adapter) => + {adapters.map((adapter) => diff --git a/client/src/features/clients/ClientList.js b/client/src/features/clients/ClientList.js index a016be6..7925d74 100644 --- a/client/src/features/clients/ClientList.js +++ b/client/src/features/clients/ClientList.js @@ -19,6 +19,7 @@ import ClientView from "./view/ClientView"; import { withContext } from "../../data/context/withContext"; import FeatureHelperText from "../../common/help/FeatureHelperText"; import WarningMessageBox from "../../common/message-box/WarningMessageBox"; +import Sort from "../../common/utils/Sort"; const styles = theme => ({ root: { @@ -105,6 +106,8 @@ class ClientList extends Component { render() { const { classes } = this.props; + const clients = this.props.clients.sort(Sort.alphabetically); + return (
Klienter - {this.props.clients.map((client) => + {clients.map((client) => diff --git a/client/src/features/component/ComponentList.js b/client/src/features/component/ComponentList.js index 7081575..5462ebd 100644 --- a/client/src/features/component/ComponentList.js +++ b/client/src/features/component/ComponentList.js @@ -25,6 +25,7 @@ import CommonComponentLabel from "../../common/label/CommonComponentLabel"; import RemoveButton from "../../common/button/RemoveButton"; import AddButton from "../../common/button/AddButton"; import FeatureHelperText from "../../common/help/FeatureHelperText"; +import Sort from "../../common/utils/Sort"; const styles = theme => ({ @@ -167,6 +168,7 @@ class ComponentList extends Component { render() { const { classes, organisation } = this.props; + const components = this.props.components.sort(Sort.alphabetically); return (
@@ -206,7 +208,7 @@ class ComponentList extends Component { Komponenter - {this.props.components.map((component) => + {components.map((component) =>