Commit 796a9c53f517c6c11c3a06ed6a8e597011fca904
1 parent
1d1a74ecec
Exists in
master
add student form
Showing
6 changed files
with
111 additions
and
46 deletions
Show diff stats
imports/client/views/org/admin/students/FabMenu.js
... | ... | @@ -7,13 +7,11 @@ import { FormGroup,Panel,Table, |
7 | 7 | ButtonToolbar,Modal, |
8 | 8 | FormControl,Glyphicon,Button } from 'react-bootstrap'; |
9 | 9 | import { AddStudentForm } from './addStudentForm'; |
10 | -import FloatingActionButton from 'material-ui/FloatingActionButton'; | |
11 | -import ContentAdd from 'material-ui/svg-icons/content/add'; | |
10 | + | |
12 | 11 | const style = { |
13 | - marginRight: 20, | |
12 | + margin: 12, | |
14 | 13 | }; |
15 | 14 | export class FabMenuView extends Component { |
16 | - | |
17 | 15 | constructor(props) { |
18 | 16 | super(props); |
19 | 17 | this.state = { |
... | ... | @@ -28,9 +26,8 @@ export class FabMenuView extends Component { |
28 | 26 | render() { |
29 | 27 | return ( |
30 | 28 | <div> |
31 | - <FloatingActionButton> | |
32 | - <ContentAdd /> | |
33 | - </FloatingActionButton> | |
29 | + <Button bsStyle="primary">Add Student</Button> | |
30 | + <Button bsStyle="info">Upload CSV</Button> | |
34 | 31 | </div> |
35 | 32 | ); |
36 | 33 | }; | ... | ... |
imports/client/views/org/admin/students/StudentTable.js
imports/client/views/org/admin/students/StudentView.js
... | ... | @@ -6,10 +6,10 @@ import { Link,browserHistory } from 'react-router'; |
6 | 6 | import { FormGroup,Panel,Table, |
7 | 7 | ButtonToolbar,Modal, |
8 | 8 | FormControl,Glyphicon,Button } from 'react-bootstrap'; |
9 | -import { AddStudentForm } from './addStudentForm'; | |
9 | +import { AddStudent } from './addStudent'; | |
10 | 10 | import { StudentTable } from './StudentTable'; |
11 | 11 | import { Header } from './Header'; |
12 | -import { FabMenuView } from './FabMenu'; | |
12 | +import { FabMenuView } from './FabMenu'; | |
13 | 13 | |
14 | 14 | export class StudentView extends Component { |
15 | 15 | |
... | ... | @@ -43,7 +43,7 @@ export class StudentView extends Component { |
43 | 43 | <StudentTable |
44 | 44 | data = {this.props.data} |
45 | 45 | /> |
46 | - <FabMenuView/> | |
46 | + <AddStudent/> | |
47 | 47 | |
48 | 48 | </div> |
49 | 49 | </div> |
... | ... | @@ -79,25 +79,7 @@ export class StudentView extends Component { |
79 | 79 | </div> |
80 | 80 | </form> |
81 | 81 | </div> |
82 | - <div className="category-content"> | |
83 | - <form action="#"> | |
84 | - <div className="has-feedback has-feedback-left"> | |
85 | - <div className="btn-group"> | |
86 | - <button type="button" className="dropdown-toggle form-control" data-toggle="dropdown"> | |
87 | - <span data-bind="label">Select className</span> <span className="caret"></span> | |
88 | - </button> | |
89 | - <ul className="dropdown-menu" role="menu"> | |
90 | - <li><a href="#">Item 1</a></li> | |
91 | - <li><a href="#">Another item</a></li> | |
92 | - <li><a href="#">This is a longer item that will not fit properly</a></li> | |
93 | - </ul> | |
94 | - </div> | |
95 | - <div className="form-control-feedback"> | |
96 | - <i className="icon-search4 text-size-base text-muted"></i> | |
97 | - </div> | |
98 | - </div> | |
99 | - </form> | |
100 | - </div> | |
82 | + | |
101 | 83 | </div> |
102 | 84 | |
103 | 85 | ... | ... |
imports/client/views/org/admin/students/addStudent.js
... | ... | @@ -0,0 +1,64 @@ |
1 | +import _ from 'lodash'; | |
2 | +import { Meteor } from 'meteor/meteor'; | |
3 | + | |
4 | +import React, { Component } from 'react'; | |
5 | +import { Link,browserHistory } from 'react-router'; | |
6 | +import { FormGroup,Panel,Table, | |
7 | + ButtonToolbar,Modal, | |
8 | + FormControl,Glyphicon,Button } from 'react-bootstrap'; | |
9 | +import { AddStudentForm } from './addStudentForm'; | |
10 | + | |
11 | +const style = { | |
12 | + margin: 12, | |
13 | +}; | |
14 | +export class AddStudent extends Component { | |
15 | + constructor(props) { | |
16 | + super(props); | |
17 | + this.state = { | |
18 | + show: false | |
19 | + }; | |
20 | + this.showModal = this.showModal.bind(this); | |
21 | + this.hideModal = this.hideModal.bind(this); | |
22 | + this.onUpdate = this.onUpdate.bind(this); | |
23 | + }; | |
24 | + | |
25 | + showModal() { | |
26 | + this.setState({show: true}); | |
27 | + } | |
28 | + | |
29 | + hideModal() { | |
30 | + this.setState({show: false}); | |
31 | + } | |
32 | + onUpdate(key, value) { | |
33 | + this.setState({[key]: value}); | |
34 | + }; | |
35 | + | |
36 | + render() { | |
37 | + return ( | |
38 | + <div> | |
39 | + <ButtonToolbar> | |
40 | + <Button bsStyle="primary" onClick={this.showModal}> | |
41 | + Add Student | |
42 | + </Button> | |
43 | + <Modal | |
44 | + {...this.props} | |
45 | + show={this.state.show} | |
46 | + onHide={this.hideModal} | |
47 | + dialogClassName="custom-modal" | |
48 | + > | |
49 | + <Modal.Header closeButton> | |
50 | + <Modal.Title id="contained-modal-title-lg">New Student</Modal.Title> | |
51 | + </Modal.Header> | |
52 | + <Modal.Body> | |
53 | + <AddStudentForm /> | |
54 | + </Modal.Body> | |
55 | + <Modal.Footer> | |
56 | + <Button onClick={this.hideModal}>Close</Button> | |
57 | + </Modal.Footer> | |
58 | + </Modal> | |
59 | + </ButtonToolbar> | |
60 | + </div> | |
61 | + ); | |
62 | + }; | |
63 | + | |
64 | +}; | ... | ... |
imports/client/views/org/admin/students/addStudentForm.js
... | ... | @@ -3,7 +3,7 @@ import { Meteor } from 'meteor/meteor'; |
3 | 3 | |
4 | 4 | import React, { Component } from 'react'; |
5 | 5 | import { Link,browserHistory } from 'react-router'; |
6 | -import { FormGroup,InputGroup, | |
6 | +import { Form, FormGroup,InputGroup, | |
7 | 7 | DropdownButton,MenuItem,ControlLabel, |
8 | 8 | SplitButton, |
9 | 9 | FormControl,Glyphicon,Button } from 'react-bootstrap'; |
... | ... | @@ -15,22 +15,38 @@ export class AddStudentForm extends Component { |
15 | 15 | constructor(props) { |
16 | 16 | super(props); |
17 | 17 | this.state = { |
18 | - firstName: "", | |
19 | - lastName: "", | |
20 | - middleName: "", | |
21 | - dob: "", | |
18 | + admissionId: "", | |
19 | + firstName: "", | |
20 | + lastName: "", | |
21 | + middleName: "", | |
22 | + email: "", | |
23 | + dob: "", | |
24 | + gender: "", | |
25 | + rollNo: "", | |
26 | + class: "", | |
27 | + section: "", | |
28 | + bloodGroup: "", | |
29 | + phone: "", | |
30 | + address: "", | |
31 | + city: "", | |
32 | + state: "", | |
33 | + parentName: "", | |
34 | + parentEmail: "", | |
35 | + relation: "", | |
36 | + profession: "", | |
37 | + parentGender: "", | |
38 | + parentPhone: "", | |
39 | + parentAddress: "", | |
40 | + parentCity: "", | |
41 | + parentState: "", | |
42 | + parentZipcode: "", | |
22 | 43 | }; |
23 | 44 | this.onUpdate = this.onUpdate.bind(this); |
24 | - this.aFunction = this.aFunction.bind(this); | |
25 | 45 | }; |
26 | 46 | |
27 | 47 | onUpdate(key, value) { |
28 | 48 | this.setState({[key]: value}); |
29 | 49 | }; |
30 | - aFunction(e){ | |
31 | - console.log(e); | |
32 | - console.log(e); | |
33 | - } | |
34 | 50 | addStudent(e){ |
35 | 51 | e.preventDefault(); |
36 | 52 | e.persist(); |
... | ... | @@ -54,7 +70,17 @@ export class AddStudentForm extends Component { |
54 | 70 | } |
55 | 71 | render() { |
56 | 72 | return ( |
57 | - <form onSubmit={ (e) => this.addStudent(e) }> | |
73 | + <Form onSubmit={ (e) => this.addStudent(e) }> | |
74 | + <FormGroup controlId="formBasicText"> | |
75 | + <ControlLabel>Admission Id</ControlLabel> | |
76 | + <FormControl | |
77 | + type="text" | |
78 | + value={this.state.firstName} | |
79 | + placeholder="First Name" | |
80 | + onChange={e=>this.onUpdate('firstName',e.target.value)} | |
81 | + /> | |
82 | + </FormGroup> | |
83 | + | |
58 | 84 | <FormGroup controlId="formBasicText"> |
59 | 85 | <ControlLabel>First Name</ControlLabel> |
60 | 86 | <FormControl |
... | ... | @@ -83,7 +109,7 @@ export class AddStudentForm extends Component { |
83 | 109 | /> |
84 | 110 | </FormGroup> |
85 | 111 | <Button type="submit" bsStyle="default">Add Student</Button> |
86 | - </form> | |
112 | + </Form> | |
87 | 113 | ); |
88 | 114 | }; |
89 | 115 | ... | ... |
imports/collections/students/methods.js
... | ... | @@ -31,9 +31,6 @@ export const addStudentManually = new ValidatedMethod({ |
31 | 31 | }).validator(), |
32 | 32 | |
33 | 33 | run({firstName,middleName,lastName}) { |
34 | - console.log(firstName); | |
35 | - console.log(middleName); | |
36 | - console.log(lastName); | |
37 | 34 | const user = Users.findOne({_id: this.userId}); |
38 | 35 | orgId = user.orgId; |
39 | 36 | newUserId = Users.insert({ |
... | ... | @@ -44,7 +41,6 @@ export const addStudentManually = new ValidatedMethod({ |
44 | 41 | orgId: orgId, |
45 | 42 | role: 'STUDENT' |
46 | 43 | }); |
47 | - log(newUserId); | |
48 | 44 | if(newUserId){ |
49 | 45 | Students.insert({ |
50 | 46 | userId: newUserId, | ... | ... |