Skip to content
This repository has been archived by the owner on May 28, 2018. It is now read-only.

Commit

Permalink
Add status filter
Browse files Browse the repository at this point in the history
  • Loading branch information
nbrohee committed Jul 21, 2017
1 parent eb3c13e commit 750d10c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
6 changes: 4 additions & 2 deletions client/src/components/admin/AdminPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export class AdminPage extends React.Component {
pepite: 0,
name: '',
establishment: '',
email: ''
email: '',
status: ''
},
applications: [],
activePage: 1,
Expand Down Expand Up @@ -83,7 +84,8 @@ export class AdminPage extends React.Component {
pepite: 0,
name: '',
establishment: '',
email: ''
email: '',
status: ''
}
})
}
Expand Down
8 changes: 8 additions & 0 deletions client/src/components/admin/ApplicationFilterForm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { PropTypes } from 'react'
import { FormGroup, ControlLabel, FormControl, Button, ButtonToolbar, Panel } from 'react-bootstrap'
import applicationStatuses from './applicationStatuses'

const ApplicationFilterForm = ({ onClearFilter, onFilter, filter, pepiteList, onChange }) => {
return (
Expand All @@ -17,6 +18,13 @@ const ApplicationFilterForm = ({ onClearFilter, onFilter, filter, pepiteList, on
<ControlLabel>Établissement</ControlLabel>
<FormControl name="establishment" placeholder="Établissement" onChange={onChange} value={filter.establishment} />
</FormGroup>
<FormGroup>
<ControlLabel>Statut</ControlLabel>
<FormControl name="status" componentClass="select" onChange={onChange} value={filter.status}>
<option value={''}>Tous les statuts</option>
{applicationStatuses.map((status) => { return (<option key={status.value} value={status.value}>{status.name}</option>) })}
</FormControl>
</FormGroup>
<FormGroup>
<ControlLabel>PEPITE</ControlLabel>
<FormControl name="pepite" componentClass="select" onChange={onChange} value={filter.pepite}>
Expand Down
20 changes: 20 additions & 0 deletions client/src/components/admin/applicationStatuses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const statuses = [
{
name: 'sauvegardée',
value: 'saved'
},
{
name: 'refusée',
value: 'refused'
},
{
name: 'en attente',
value: 'sent'
},
{
name: 'acceptée',
value: 'accepted'
}
]

export default statuses
3 changes: 3 additions & 0 deletions server/api/application/application.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ function getFindQuery(flatFilter) {
if (flatFilter.pepite) {
findFilter['pepite.pepite'] = flatFilter.pepite
}
if (flatFilter.status) {
findFilter['status'] = flatFilter.status
}
if (flatFilter.establishment) {
findFilter['career.diploma.establishment'] = {
$regex: `${flatFilter.establishment}`,
Expand Down
20 changes: 20 additions & 0 deletions server/api/application/test/application.api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,26 @@ describe('api: application', () => {
})
})

describe('When filter is on status', () => {
it('should give all applications containing the filter', (done) => {
const filter = {
status: 'saved'
}
supertest(app)
.get(`/api/application?${qs.stringify({ filter }, { encode: false })}`)
.set('Authorization', `Bearer ${validToken.token}`)
.expect(200)
.expect('Content-Range', 2)
.end((err, res) => {
if (err) {
return done(err)
}
expect(res.body.length).toBe(2)
done()
})
})
})

describe('When filter is on establishment', () => {
it('should give all applications containing the filter', (done) => {
const filter = {
Expand Down

0 comments on commit 750d10c

Please sign in to comment.