From 80f4281ab1b0ca457e999709721954698d479a1c Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Thu, 8 Dec 2016 01:01:57 -0300 Subject: [PATCH] Max - Add filter by department in staff members [skip ci] --- .../panel/staff/admin-panel-staff-members.js | 25 +++++++++++-------- .../staff/admin-panel-staff-members.scss | 0 2 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 client/src/app/admin/panel/staff/admin-panel-staff-members.scss diff --git a/client/src/app/admin/panel/staff/admin-panel-staff-members.js b/client/src/app/admin/panel/staff/admin-panel-staff-members.js index 2cf7fda1..ddd49eec 100644 --- a/client/src/app/admin/panel/staff/admin-panel-staff-members.js +++ b/client/src/app/admin/panel/staff/admin-panel-staff-members.js @@ -1,4 +1,5 @@ import React from 'react'; +import _ from 'lodash'; import i18n from 'lib-app/i18n'; import API from 'lib-app/api-call'; @@ -13,14 +14,6 @@ import Loading from 'core-components/loading'; class AdminPanelStaffMembers extends React.Component { - static propTypes = { - departments: React.PropTypes.array - }; - - static defaultProps = { - departments: [] - }; - state = { selectedDepartment: 0, staffList: [], @@ -35,6 +28,7 @@ class AdminPanelStaffMembers extends React.Component { } render() { + console.log(this.state.staffList); return (
@@ -42,7 +36,7 @@ class AdminPanelStaffMembers extends React.Component { - {(this.state.loading) ? : } + {(this.state.loading) ? : }
); } @@ -51,14 +45,25 @@ class AdminPanelStaffMembers extends React.Component { return { items: this.getDepartments(), onChange: (event) => { + let departments = SessionStore.getDepartments(); this.setState({ - selectedDepartment: event.index && this.props.departments[event.index - 1].id + selectedDepartment: event.index && departments[event.index - 1].id }); }, size: 'medium' }; } + getStaffList() { + if(!this.state.selectedDepartment) { + return this.state.staffList; + } + + return _.filter(this.state.staffList, (o) => { + return _.findIndex(o.departments, {id: this.state.selectedDepartment}) !== -1; + }); + } + getDepartments() { let departments = SessionStore.getDepartments().map((department) => { return {content: department.name}; diff --git a/client/src/app/admin/panel/staff/admin-panel-staff-members.scss b/client/src/app/admin/panel/staff/admin-panel-staff-members.scss new file mode 100644 index 00000000..e69de29b