Commit af71e7fcd51532e7038343c4b4be94e5070573c8

Authored by Deepak
1 parent 1c4a8cc5d4
Exists in master

added search functionality

imports/client/views/org/admin/students/StudentTable.js
1 import _ from 'lodash'; 1 import _ from 'lodash';
2 import { Meteor } from 'meteor/meteor'; 2 import { Meteor } from 'meteor/meteor';
3 3
4 import React, { Component } from 'react'; 4 import React, { Component } from 'react';
5 import { Link,browserHistory } from 'react-router'; 5 import { Link,browserHistory } from 'react-router';
6 import { FormGroup,Panel,Table, 6 import { FormGroup,Panel,Table,
7 ButtonToolbar,Modal, 7 ButtonToolbar,Modal,
8 FormControl,Glyphicon,Button } from 'react-bootstrap'; 8 FormControl,Glyphicon,Button } from 'react-bootstrap';
9 import { AddStudentForm } from './addStudentForm'; 9 import { AddStudentForm } from './addStudentForm';
10 10
11 export class StudentTable extends Component { 11 export class StudentTable extends Component {
12 12
13 constructor(props) { 13 constructor(props) {
14 super(props); 14 super(props);
15 this.state = { 15 this.state = {
16 show: false 16 show: false
17 }; 17 };
18 this.onUpdate = this.onUpdate.bind(this); 18 this.onUpdate = this.onUpdate.bind(this);
19 }; 19 };
20 onUpdate(key, value) { 20 onUpdate(key, value) {
21 this.setState({[key]: value}); 21 this.setState({[key]: value});
22 }; 22 };
23 23
24 render() { 24 render() {
25 return ( 25 return (
26 <div className="panel panel-flat"> 26 <div className="panel panel-flat">
27 <div className="panel-heading"> 27 <div className="panel-heading">
28 <h5 className="panel-title">Student Details</h5> 28 <h5 className="panel-title">Student Details</h5>
29 <div className="heading-elements"> 29 <div className="heading-elements">
30 <ul className="icons-list"> 30 <ul className="icons-list">
31 <li><a data-action="collapse"></a></li> 31 <li><a data-action="collapse"></a></li>
32 <li><a data-action="reload"></a></li> 32 <li><a data-action="reload"></a></li>
33 </ul> 33 </ul>
34 </div> 34 </div>
35 </div> 35 </div>
36
37
38 <Table striped bordered condensed hover> 36 <Table striped bordered condensed hover>
39 <thead> 37 <thead>
40 <tr> 38 <tr>
41 <th>First Name</th> 39 <th>First Name</th>
42 <th>Last Name</th> 40 <th>Last Name</th>
43 <th>className</th> 41 <th>className</th>
44 <th>DOB</th> 42 <th>DOB</th>
45 <th>Status</th> 43 <th>Status</th>
46 <th className="text-center">Actions</th> 44 <th className="text-center">Actions</th>
47 </tr> 45 </tr>
48 </thead> 46 </thead>
49 <tbody> 47 <tbody>
50 { 48 {
51 this.props.data.students.map(function(student, i) 49 this.props.students.map(function(student, i)
52 { 50 {
53 return( 51 return(
54 <tr key={i}> 52 <tr key={i}>
55 <td>{student.firstName}</td> 53 <td>{student.firstName}</td>
56 <td>{student.lastName}</td> 54 <td>{student.lastName}</td>
57 <td>VII</td> 55 <td>{student.class}</td>
58 <td>22 Jun 1972</td> 56 <td>{}</td>
59 <td><span className="label label-success">Active</span></td> 57 <td><span className="label label-success">Active</span></td>
60 <td className="text-center"> 58 <td className="text-center">
61 <ul className="icons-list"> 59 <ul className="icons-list">
62 <li className="dropdown"> 60 <li className="dropdown">
63 <a href="#" className="dropdown-toggle" data-toggle="dropdown"> 61 <a href="#" className="dropdown-toggle" data-toggle="dropdown">
64 <i className="icon-menu9"></i> 62 <i className="icon-menu9"></i>
65 </a> 63 </a>
66 64 <ul className="dropdown-menu dropdown-menu-right">
67 <ul className="dropdown-menu dropdown-menu-right"> 65 <li><a href="#"><i className="icon-file-pdf"></i> Export to .pdf</a></li>
68 <li><a href="#"><i className="icon-file-pdf"></i> Export to .pdf</a></li> 66 <li><a href="#"><i className="icon-file-excel"></i> Export to .csv</a></li>
69 <li><a href="#"><i className="icon-file-excel"></i> Export to .csv</a></li> 67 <li><a href="#"><i className="icon-file-word"></i> Export to .doc</a></li>
70 <li><a href="#"><i className="icon-file-word"></i> Export to .doc</a></li> 68 </ul>
71 </ul> 69 </li>
72 </li> 70 </ul>
73 </ul> 71 </td>
74 </td> 72 </tr>
75 </tr> 73 )
76 ) 74 })
77 }) 75 }
78 }
79 <tr>
80 <td>Jackelyn</td>
81 <td>Weible</td>
82 <td><a href="#">XI</a></td>
83 <td>3 Oct 1981</td>
84 <td><span className="label label-default">Inactive</span></td>
85 <td className="text-center">
86 <ul className="icons-list">
87 <li className="dropdown">
88 <a href="#" className="dropdown-toggle" data-toggle="dropdown">
89 <i className="icon-menu9"></i>
90 </a>
91
92 <ul className="dropdown-menu dropdown-menu-right">
93 <li><a href="#"><i className="icon-file-pdf"></i> Export to .pdf</a></li>
94 <li><a href="#"><i className="icon-file-excel"></i> Export to .csv</a></li>
95 <li><a href="#"><i className="icon-file-word"></i> Export to .doc</a></li>
96 </ul>
97 </li>
98 </ul>
99 </td>
100 </tr>
101 </tbody> 76 </tbody>
102 </Table> 77 </Table>
103 </div> 78 </div>
104 ); 79 );
105 }; 80 };
106 81
107 }; 82 };
108 83
imports/client/views/org/admin/students/StudentView.js
1 import _ from 'lodash'; 1 import _ from 'lodash';
2 import { Meteor } from 'meteor/meteor'; 2 import { Meteor } from 'meteor/meteor';
3 3
4 import React, { Component } from 'react'; 4 import React, { Component } from 'react';
5 import { Link,browserHistory } from 'react-router'; 5 import { Link,browserHistory } from 'react-router';
6 import { FormGroup,Panel,Table, 6 import { FormGroup,Panel,Table,
7 ButtonToolbar,Modal, 7 ButtonToolbar,Modal,
8 FormControl,Glyphicon,Button } from 'react-bootstrap'; 8 FormControl,Glyphicon,Button } from 'react-bootstrap';
9 import { AddStudent } from './addStudent'; 9 import { AddStudent } from './addStudent';
10 import { StudentTable } from './StudentTable'; 10 import { StudentTable } from './StudentTable';
11 import { Header } from './Header'; 11 import { Header } from './Header';
12 import { FabMenuView } from './FabMenu'; 12 import { FabMenuView } from './FabMenu';
13 import { UploadCsv } from './UploadCsv'; 13 import { UploadCsv } from './UploadCsv';
14 14
15 15
16 export class StudentView extends Component { 16 export class StudentView extends Component {
17 17
18 constructor(props) { 18 constructor(props) {
19 super(props); 19 super(props);
20 this.state = { 20 this.state = {
21 show: false 21 show: false,
22 firstNameSearch: "",
23 lastNameSearch: "",
22 }; 24 };
23 this.showModal = this.showModal.bind(this); 25 this.showModal = this.showModal.bind(this);
24 this.hideModal = this.hideModal.bind(this); 26 this.hideModal = this.hideModal.bind(this);
25 this.onUpdate = this.onUpdate.bind(this); 27 this.onUpdate = this.onUpdate.bind(this);
26 }; 28 };
27 29
28 showModal() { 30 showModal() {
29 this.setState({show: true}); 31 this.setState({show: true});
30 } 32 }
31 33
32 hideModal() { 34 hideModal() {
33 this.setState({show: false}); 35 this.setState({show: false});
34 } 36 }
35 onUpdate(key, value) { 37 onUpdate(key, value) {
36 this.setState({[key]: value}); 38 this.setState({[key]: value});
37 }; 39 };
38 40
39 render() { 41 render() {
42 firstNameSearch = this.state.firstNameSearch;
43 var students =_.filter(this.props.data.students,function(item){
44 console.log(item);
45 return _.includes(item.firstName.toLowerCase(),firstNameSearch.toLowerCase());
46 });
47 console.log(students);
40 return ( 48 return (
41 <div className="content has-detached-left"> 49 <div className="content has-detached-left">
42 <div className="container-detached"> 50 <div className="container-detached">
43 <div className="content-detached"> 51 <div className="content-detached">
44 <Header/> 52 <Header/>
45 <StudentTable 53 <StudentTable
46 data = {this.props.data} 54 data = {this.props.data}
55 students = {students}
47 /> 56 />
48 <AddStudent/> 57 <AddStudent/>
49 <UploadCsv /> 58 <UploadCsv />
50 </div> 59 </div>
51 </div> 60 </div>
52 <div className="sidebar-detached affix-top"> 61 <div className="sidebar-detached affix-top">
53 <div className="sidebar sidebar-default"> 62 <div className="sidebar sidebar-default">
54 <div className="sidebar-content"> 63 <div className="sidebar-content">
55 64
56 <div className="sidebar-category"> 65 <div className="sidebar-category">
57 <div className="category-title"> 66 <div className="category-title">
58 <span>Advanced Search</span> 67 <span>Advanced Search</span>
59 <ul className="icons-list"> 68 <ul className="icons-list">
60 <li><a href="#" data-action="collapse"></a></li> 69 <li><a href="#" data-action="collapse"></a></li>
61 </ul> 70 </ul>
62 </div> 71 </div>
63 72
64 <div className="category-content"> 73 <div className="category-content">
65 <form action="#"> 74 <form action="#">
66 <div className="has-feedback has-feedback-left"> 75 <div className="has-feedback has-feedback-left">
67 <input type="search" className="form-control" placeholder="First Name" /> 76 <input type="search" className="form-control"
77 value={this.state.firstNameSearch}
78 onChange={e=>this.onUpdate('firstNameSearch',e.target.value)}
79 placeholder="First Name"
80 />
68 <div className="form-control-feedback"> 81 <div className="form-control-feedback">
69 <i className="icon-search4 text-size-base text-muted"></i> 82 <i className="icon-search4 text-size-base text-muted"></i>
70 </div> 83 </div>
71 </div> 84 </div>
72 </form> 85 </form>
73 </div> 86 </div>
74 <div className="category-content"> 87 <div className="category-content">
75 <form action="#"> 88 <form action="#">
76 <div className="has-feedback has-feedback-left"> 89 <div className="has-feedback has-feedback-left">
77 <input type="search" className="form-control" placeholder="Last Name" /> 90 <input type="search" className="form-control"
91 value={this.state.lastNameSearch}
92 onChange={e=>this.onUpdate('lastNameSearch',e.target.value)}
93 placeholder="Last Name" />
78 <div className="form-control-feedback"> 94 <div className="form-control-feedback">
79 <i className="icon-search4 text-size-base text-muted"></i> 95 <i className="icon-search4 text-size-base text-muted"></i>
80 </div> 96 </div>
81 </div> 97 </div>
82 </form> 98 </form>
83 </div> 99 </div>
84 100
85 </div> 101 </div>
86 102
87 103
88 </div> 104 </div>
89 </div> 105 </div>
90 </div> 106 </div>
91 </div> 107 </div>
92 ); 108 );
93 }; 109 };
94 110
95 }; 111 };
96 112
imports/client/views/org/admin/students/index.js
1 // import { StudentDataController } from '/imports/client/views/org/admin/students/index' 1 // import { StudentDataController } from '/imports/client/views/org/admin/students/index'
2 import _ from 'lodash'; 2 import _ from 'lodash';
3 import { 3 import {
4 composeWithTracker, 4 composeWithTracker,
5 compose, 5 compose,
6 composeAll 6 composeAll
7 } from 'react-komposer'; 7 } from 'react-komposer';
8 import { Loading } from '/imports/client/components/Loading'; 8 import { Loading } from '/imports/client/components/Loading';
9 9
10 import { Orgs } from '/imports/collections/orgs/index'; 10 import { Orgs } from '/imports/collections/orgs/index';
11 import { Users } from '/imports/collections/users/index'; 11 import { Users } from '/imports/collections/users/index';
12 import { StudentView } from './StudentView'; 12 import { StudentView } from './StudentView';
13 import { Students } from '/imports/collections/students/methods' 13 import { Students } from '/imports/collections/students/methods'
14 14
15 15
16 const meteorTick = (props, onData) => { 16 const meteorTick = (props, onData) => {
17 17
18 const handles = [ 18 const handles = [
19 Meteor.subscribe('users.current'), 19 Meteor.subscribe('users.current'),
20 Meteor.subscribe('orgs.current'), 20 Meteor.subscribe('orgs.current'),
21 Meteor.subscribe('users.forMyOrg') 21 Meteor.subscribe('users.forMyOrg')
22 ]; 22 ];
23 23
24 if(_.every(handles, (handle) => (handle.ready()) )) { 24 if(_.every(handles, (handle) => (handle.ready()) )) {
25 const user = Users.current(); 25 const user = Users.current();
26 const org = Orgs.current(); 26 const org = Orgs.current();
27 const students = Users.find({"role":"STUDENT"}).fetch(); 27 const students = Users.find({"role":"STUDENT"}).fetch();
28 console.log(students);
29 onData(null, { 28 onData(null, {
30 data: { 29 data: {
31 user: user, 30 user: user,
32 org: org, 31 org: org,
33 students:students 32 students:students
34 }, 33 },
35 }); 34 });
36 } 35 }
37 36
38 return () => { 37 return () => {
39 _.each(handles, (handle) => handle.stop() ); 38 _.each(handles, (handle) => handle.stop() );
40 }; 39 };
41 }; 40 };
42 41
43 42
44 const reduxTick = (props, onData) => { 43 const reduxTick = (props, onData) => {
45 onData(null, { 44 onData(null, {
46 data: {} 45 data: {}
47 }); 46 });
48 }; 47 };
49 48
50 49
51 export const StudentDataController = composeAll( 50 export const StudentDataController = composeAll(
52 composeWithTracker(meteorTick, Loading), 51 composeWithTracker(meteorTick, Loading),
53 compose(reduxTick, Loading), 52 compose(reduxTick, Loading),
54 )(StudentView); 53 )(StudentView);
55 54