Skip to content

Commit

Permalink
fixed issues #18, #26 and #27
Browse files Browse the repository at this point in the history
  • Loading branch information
Frode Sjovatsen committed Sep 26, 2018
1 parent 2a2127a commit cf97933
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
17 changes: 17 additions & 0 deletions client/src/common/utils/Sort.js
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 4 additions & 1 deletion client/src/features/adapter/AdapterList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -104,6 +105,8 @@ class AdapterList extends Component {

render() {
const { classes } = this.props;
const adapters = this.props.adapters.sort(Sort.alphabetically);

return (
<div>
<AutoHideNotification
Expand Down Expand Up @@ -133,7 +136,7 @@ class AdapterList extends Component {
<Typography variant="headline" className={classes.title}>Adapter</Typography>
<Divider/>
<List>
{this.props.adapters.map((adapter) =>
{adapters.map((adapter) =>
<ListItem className={classes.listItem} key={adapter.dn}>
<ListItemAvatar>
<Avatar className={classes.itemAvatar}>
Expand Down
5 changes: 4 additions & 1 deletion client/src/features/clients/ClientList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -105,6 +106,8 @@ class ClientList extends Component {

render() {
const { classes } = this.props;
const clients = this.props.clients.sort(Sort.alphabetically);

return (
<div>
<AutoHideNotification
Expand Down Expand Up @@ -134,7 +137,7 @@ class ClientList extends Component {
<Typography variant="headline" className={classes.title}>Klienter</Typography>
<Divider/>
<List>
{this.props.clients.map((client) =>
{clients.map((client) =>
<ListItem className={classes.listItem} key={client.dn}>
<ListItemAvatar>
<Avatar className={classes.itemAvatar}>
Expand Down
4 changes: 3 additions & 1 deletion client/src/features/component/ComponentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ({
Expand Down Expand Up @@ -167,6 +168,7 @@ class ComponentList extends Component {

render() {
const { classes, organisation } = this.props;
const components = this.props.components.sort(Sort.alphabetically);

return (
<div className={classes.root}>
Expand Down Expand Up @@ -206,7 +208,7 @@ class ComponentList extends Component {
<Typography variant="headline" className={classes.title}>Komponenter</Typography>
<Divider/>
<List>
{this.props.components.map((component) =>
{components.map((component) =>
<ListItem className={classes.listItem} key={component.dn}>
<ListItemAvatar>
<Avatar className={classes.itemAvatar}>
Expand Down

0 comments on commit cf97933

Please sign in to comment.