Commit dbafa68d2adb056b4146c8733aa9a104f9176765
1 parent
def5858c91
Exists in
master
added teachers modal admin panel
Showing
20 changed files
with
2425 additions
and
1198 deletions
Show diff stats
imports/client/views/nonOrg/NotFound.css
File was created | 1 | .NotFound | |
2 | { | ||
3 | margin: 20px auto; | ||
4 | width: 400px; | ||
5 | height: auto; | ||
6 | padding: 20px; | ||
7 | -webkit-border-radius: 8px/7px; | ||
8 | -moz-border-radius: 8px/7px; | ||
9 | border-radius: 8px/7px; | ||
10 | background-color: white; | ||
11 | -webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.31); | ||
12 | -moz-box-shadow: 1px 2px 5px rgba(0,0,0,.31); | ||
13 | box-shadow: 1px 2px 5px rgba(0,0,0,.31); | ||
14 | border: solid 1px #cbc9c9; | ||
15 | font-family: 'Ubuntu', sans-serif; | ||
16 | color:crimson; | ||
17 | } | ||
18 |
imports/client/views/nonOrg/NotFound.js
1 | import React from 'react'; | 1 | import React from 'react'; |
2 | import { Alert } from 'react-bootstrap'; | 2 | import { Alert } from 'react-bootstrap'; |
3 | 3 | import 'NotFound.css' | |
4 | const NotFound = () => ( | 4 | const NotFound = () => ( |
5 | <div className="NotFound"> | 5 | <div className="NotFound"> |
6 | <Alert bsStyle="danger"> | 6 | <Alert bsStyle="danger"> |
7 | <p><strong>Error [404]</strong>: { window.location.pathname } does not exist.</p> | 7 | <p><strong>Error [404]</strong>: { window.location.pathname } does not exist.</p> |
8 | </Alert> | 8 | </Alert> |
9 | </div> | 9 | </div> |
10 | ); | 10 | ); |
11 | 11 | ||
12 | export default NotFound; | 12 | export default NotFound; |
13 | 13 |
imports/client/views/org/admin/Sidebar.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 { Navbar,Modal, Nav, NavItem, | 6 | import { Navbar,Modal, Nav, NavItem, |
7 | Glyphicon, Collapse, FormGroup, FormControl, Panel, | 7 | Glyphicon, Collapse, FormGroup, FormControl, Panel, |
8 | NavbarToggler, NavbarBrand, Table, ButtonToolbar, | 8 | NavbarToggler, NavbarBrand, Table, ButtonToolbar, |
9 | NavLink, DropdownItem, DropdownToggle, DropdownMenu, | 9 | NavLink, DropdownItem, DropdownToggle, DropdownMenu, |
10 | NavDropdown, MenuItem, Breadcrumb, Button } from 'react-bootstrap'; | 10 | NavDropdown, MenuItem, Breadcrumb, Button } from 'react-bootstrap'; |
11 | 11 | ||
12 | 12 | ||
13 | export class AdminSidebar extends Component { | 13 | export class AdminSidebar extends Component { |
14 | 14 | ||
15 | constructor(props) { | 15 | constructor(props) { |
16 | super(props); | 16 | super(props); |
17 | this.state = { | 17 | this.state = { |
18 | 18 | ||
19 | }; | 19 | }; |
20 | this.onUpdate = this.onUpdate.bind(this); | 20 | this.onUpdate = this.onUpdate.bind(this); |
21 | }; | 21 | }; |
22 | 22 | ||
23 | onUpdate(key, value) { | 23 | onUpdate(key, value) { |
24 | this.setState({[key]: value}); | 24 | this.setState({[key]: value}); |
25 | }; | 25 | }; |
26 | 26 | ||
27 | render() { | 27 | render() { |
28 | const {user, org} = this.props; | 28 | const {user, org} = this.props; |
29 | return ( | 29 | return ( |
30 | <div className="sidebar sidebar-main sidebar-default"> | 30 | <div className="sidebar sidebar-main sidebar-default"> |
31 | <div className="sidebar-content"> | 31 | <div className="sidebar-content"> |
32 | <div className="sidebar-category sidebar-category-visible"> | 32 | <div className="sidebar-category sidebar-category-visible"> |
33 | <div className="category-content no-padding"> | 33 | <div className="category-content no-padding"> |
34 | <Nav className="navigation navigation-main navigation-accordion"> | 34 | <Nav className="navigation navigation-main navigation-accordion"> |
35 | <NavItem className="navigation-header"><span>#schoolname</span> <i className="icon-menu" title="Main pages"></i></NavItem> | 35 | <NavItem className="navigation-header"><span>{org.name}</span> <i className="icon-menu" title="Main pages"></i></NavItem> |
36 | <NavItem className="active" eventKey={1} href="#"><i className="icon-home4"></i> <span>Dashboard</span></NavItem> | 36 | <NavItem className="active" eventKey={1} href="#"><i className="icon-home4"></i> <span>Dashboard</span></NavItem> |
37 | 37 | ||
38 | <NavDropdown eventKey={2} title="Settings" name="Settings" id="setting"> | 38 | <NavDropdown eventKey={2} title="Settings" name="Settings" id="setting"> |
39 | <MenuItem eventKey={2.1}>Information</MenuItem> | 39 | <MenuItem eventKey={2.1}>Information</MenuItem> |
40 | <MenuItem eventKey={2.2}>Infrastructure</MenuItem> | 40 | <MenuItem eventKey={2.2}>Infrastructure</MenuItem> |
41 | <MenuItem eventKey={2.3}>Users</MenuItem> | 41 | <MenuItem eventKey={2.3}>Users</MenuItem> |
42 | <MenuItem eventKey={2.4}>Academic Settings</MenuItem> | 42 | <MenuItem eventKey={2.4}>Academic Settings</MenuItem> |
43 | <MenuItem eventKey={2.5}>Account Configuration</MenuItem> | 43 | <MenuItem eventKey={2.5}>Account Configuration</MenuItem> |
44 | </NavDropdown> | 44 | </NavDropdown> |
45 | <NavDropdown eventKey={3} title="Academic" name="Academic" id="academic"> | 45 | <NavDropdown eventKey={3} title="Academic" name="Academic" id="academic"> |
46 | <MenuItem eventKey={3.1}>Layout 1</MenuItem> | 46 | <MenuItem eventKey={3.1}>Layout 1</MenuItem> |
47 | <MenuItem eventKey={3.2}>Layout 2</MenuItem> | 47 | <MenuItem eventKey={3.2}>Layout 2</MenuItem> |
48 | <MenuItem eventKey={3.3}>Layout 3</MenuItem> | 48 | <MenuItem eventKey={3.3}>Layout 3</MenuItem> |
49 | <MenuItem eventKey={3.4}>Layout 4</MenuItem> | 49 | <MenuItem eventKey={3.4}>Layout 4</MenuItem> |
50 | <MenuItem eventKey={3.5}>Layout 5</MenuItem> | 50 | <MenuItem eventKey={3.5}>Layout 5</MenuItem> |
51 | </NavDropdown> | 51 | </NavDropdown> |
52 | <NavDropdown eventKey={4} title="Communication" name="Communication" id="communication"> | 52 | <NavDropdown eventKey={4} title="Communication" name="Communication" id="communication"> |
53 | <MenuItem eventKey={4.1}>Primary palett</MenuItem> | 53 | <MenuItem eventKey={4.1}>Primary palett</MenuItem> |
54 | <MenuItem eventKey={4.2}>Danger palett</MenuItem> | 54 | <MenuItem eventKey={4.2}>Danger palett</MenuItem> |
55 | <MenuItem eventKey={4.3}>Success palett</MenuItem> | 55 | <MenuItem eventKey={4.3}>Success palett</MenuItem> |
56 | <MenuItem eventKey={4.4}>Warning palett</MenuItem> | 56 | <MenuItem eventKey={4.4}>Warning palett</MenuItem> |
57 | <MenuItem divider /> | 57 | <MenuItem divider /> |
58 | <MenuItem eventKey={4.5}>Info palett</MenuItem> | 58 | <MenuItem eventKey={4.5}>Info palett</MenuItem> |
59 | <MenuItem eventKey={4.6}>Info palett</MenuItem> | 59 | <MenuItem eventKey={4.6}>Info palett</MenuItem> |
60 | <MenuItem eventKey={4.7}>Info palett</MenuItem> | 60 | <MenuItem eventKey={4.7}>Info palett</MenuItem> |
61 | <MenuItem eventKey={4.8}>Info palett</MenuItem> | 61 | <MenuItem eventKey={4.8}>Info palett</MenuItem> |
62 | </NavDropdown> | 62 | </NavDropdown> |
63 | <NavDropdown eventKey={5} title="Finance" name="Finance" id="finance"> | 63 | <NavDropdown eventKey={5} title="Finance" name="Finance" id="finance"> |
64 | <MenuItem eventKey={5.1}>Primary palett</MenuItem> | 64 | <MenuItem eventKey={5.1}>Primary palett</MenuItem> |
65 | <MenuItem eventKey={5.2}>Danger palett</MenuItem> | 65 | <MenuItem eventKey={5.2}>Danger palett</MenuItem> |
66 | <MenuItem eventKey={5.3}>Success palett</MenuItem> | 66 | <MenuItem eventKey={5.3}>Success palett</MenuItem> |
67 | <MenuItem eventKey={5.4}>Warning palett</MenuItem> | 67 | <MenuItem eventKey={5.4}>Warning palett</MenuItem> |
68 | <NavDropdown eventKey={5.5} title="Calumns" id="calumns"> | 68 | <NavDropdown eventKey={5.5} title="Calumns" id="calumns"> |
69 | <MenuItem>Success palett</MenuItem> | 69 | <MenuItem>Success palett</MenuItem> |
70 | <MenuItem>Warning palett</MenuItem> | 70 | <MenuItem>Warning palett</MenuItem> |
71 | </NavDropdown> | 71 | </NavDropdown> |
72 | </NavDropdown> | 72 | </NavDropdown> |
73 | 73 | ||
74 | <NavItem eventKey={6} href="#"><i className="icon-file-stats"></i><span> Reports </span></NavItem> | 74 | <NavItem eventKey={6} href="#"><i className="icon-file-stats"></i><span> Reports </span></NavItem> |
75 | <NavItem eventKey={7} href="#"><i className="icon-design"></i> <span>Examinations</span></NavItem> | 75 | <NavItem eventKey={7} href="#"><i className="icon-design"></i> <span>Examinations</span></NavItem> |
76 | 76 | ||
77 | </Nav> | 77 | </Nav> |
78 | </div> | 78 | </div> |
79 | </div> | 79 | </div> |
80 | </div> | 80 | </div> |
81 | </div> | 81 | </div> |
82 | ); | 82 | ); |
83 | }; | 83 | }; |
84 | 84 | ||
85 | }; | 85 | }; |
86 | 86 |
imports/client/views/org/admin/students/AddStudentFormContainer.js
1 | import React, { Component } from 'react' | File was deleted | |
2 | import { AddStudentForm } from './addStudentForm' | ||
3 | import StudentForm from './StudentForm' | ||
4 | import Form from '/imports/client/views/core/Form' | ||
5 | import Validator from '/imports/client/views/core/Validator' | ||
6 | import { isRequired, isValidEmail } from '/imports/client/views/core/validations' | ||
7 | import { addStudentManually } from '/imports/collections/students/methods'; | ||
8 | |||
9 | export class AddStudentFormContainer extends Component { | ||
10 | |||
11 | constructor(props) { | ||
12 | super(props) | ||
13 | this.state = { currentStep: 0 } | ||
14 | this.handleNextClick = this.handleNextClick.bind(this) | ||
15 | this.handleBackClick = this.handleBackClick.bind(this) | ||
16 | this.handleSubmit = this.handleSubmit.bind(this) | ||
17 | } | ||
18 | |||
19 | handleNextClick() { | ||
20 | this.form.handleSubmit() | ||
21 | if (this.validator.getErrors() && Object.keys(this.validator.getErrors()).length > 0) return | ||
22 | this.setState({ currentStep: this.state.currentStep + 1 }) | ||
23 | this.form.resetSubmitted() | ||
24 | } | ||
25 | |||
26 | handleBackClick() { | ||
27 | this.setState({ currentStep: this.state.currentStep + -1 }) | ||
28 | } | ||
29 | |||
30 | handleSubmit() { | ||
31 | if (this.state.currentStep === 3) { | ||
32 | addStudentManually.call(this.form.state.values) | ||
33 | } | ||
34 | } | ||
35 | |||
36 | //render callback | ||
37 | render() { | ||
38 | return ( | ||
39 | <Form | ||
40 | onSubmit={this.handleSubmit} | ||
41 | ref={form => this.form = form} | ||
42 | initialValues={{ | ||
43 | gender: 'male', | ||
44 | parentGender: 'male', | ||
45 | }} | ||
46 | > | ||
47 | {({ values, setValue, getValue, isSubmitted, isDirty }) => ( | ||
48 | <Validator | ||
49 | values={values} | ||
50 | ref={validator => this.validator = validator} | ||
51 | validations={{ | ||
52 | admissionId: [(value) => isRequired('Admission id', value)], | ||
53 | firstName: [(value) => isRequired('First name', value)], | ||
54 | lastName: [(value) => isRequired('Last name', value)], | ||
55 | email: [(value) => isRequired('Email', value), isValidEmail], | ||
56 | dob: [(value) => isRequired('Date of birth', value)], | ||
57 | gender: [(value) => isRequired('Gender', value)], | ||
58 | rollNo: [(value) => this.state.currentStep === 1 && isRequired('Roll no', value)], | ||
59 | studentClass: [(value) => this.state.currentStep === 1 && isRequired('Class', value)], | ||
60 | section: [(value) => this.state.currentStep === 1 && isRequired('Section', value)], | ||
61 | community: [(value) => this.state.currentStep === 1 && isRequired('Community', value)], | ||
62 | bloodGroup: [(value) => this.state.currentStep === 1 && isRequired('Blood group', value)], | ||
63 | phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], | ||
64 | address: [(value) => this.state.currentStep === 2 && isRequired('Address', value)], | ||
65 | city: [(value) => this.state.currentStep === 2 && isRequired('City', value)], | ||
66 | state: [(value) => this.state.currentStep === 2 && isRequired('State', value)], | ||
67 | parentName: [(value) => this.state.currentStep === 3 && isRequired('Parent name', value)], | ||
68 | parentEmail: [(value) => this.state.currentStep === 3 && isRequired('Parent email', value), (value) => this.state.currentStep === 3 && isValidEmail(value)], | ||
69 | relation: [(value) => this.state.currentStep === 3 && isRequired('Relation', value)], | ||
70 | profession: [(value) => this.state.currentStep === 3 && isRequired('Profession', value)], | ||
71 | parentGender: [(value) => this.state.currentStep === 3 && isRequired('Parent gender', value)], | ||
72 | parentPhone: [(value) => this.state.currentStep === 3 && isRequired('Parent phone', value)], | ||
73 | parentAddress: [(value) => this.state.currentStep === 3 && isRequired('Parent address', value)], | ||
74 | parentCity: [(value) => this.state.currentStep === 3 && isRequired('Parent city', value)], | ||
75 | parentState: [(value) => this.state.currentStep === 3 && isRequired('Parent state', value)], | ||
76 | parentZipcode: [(value) => this.state.currentStep === 3 && isRequired('Parent zip code', value)], | ||
77 | }} | ||
78 | > | ||
79 | {({ errors }) => ( | ||
80 | <StudentForm | ||
81 | isDirty={isDirty} | ||
82 | setValue={setValue} | ||
83 | getValue={getValue} | ||
84 | isSubmitted={isSubmitted} | ||
85 | errors={errors} | ||
86 | onNextClick={this.handleNextClick} | ||
87 | onBackClick={this.handleBackClick} | ||
88 | currentStep={this.state.currentStep} | ||
89 | /> | ||
90 | )} | ||
91 | </Validator> | ||
92 | )} | ||
93 | </Form> | ||
94 | ) | ||
95 | } | ||
96 | } | ||
97 | 1 | import React, { Component } from 'react' |
imports/client/views/org/admin/students/FabMenu.js
1 | import _ from 'lodash'; | File was deleted | |
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 FabMenuView extends Component { | ||
15 | constructor(props) { | ||
16 | super(props); | ||
17 | this.state = { | ||
18 | show: false | ||
19 | }; | ||
20 | this.onUpdate = this.onUpdate.bind(this); | ||
21 | }; | ||
22 | onUpdate(key, value) { | ||
23 | this.setState({[key]: value}); | ||
24 | }; | ||
25 | |||
26 | render() { | ||
27 | return ( | ||
28 | <div> | ||
29 | <Button bsStyle="primary">Add Student</Button> | ||
30 | <Button bsStyle="info">Upload CSV</Button> | ||
31 | </div> | ||
32 | ); | ||
33 | }; | ||
34 | |||
35 | }; | ||
36 | 1 | import _ from 'lodash'; |
imports/client/views/org/admin/students/StudentForm.js
1 | import React, { PropTypes } from 'react' | File was deleted | |
2 | import { | ||
3 | Row, | ||
4 | Col, | ||
5 | FormGroup, | ||
6 | FormControl, | ||
7 | Button | ||
8 | } from 'react-bootstrap' | ||
9 | import DatePicker from '/imports/client/views/core/DatePicker' | ||
10 | import Label from '/imports/client/views/core/Label' | ||
11 | import Stepper from '/imports/client/views/core/Stepper' | ||
12 | import ErrorLabel from '/imports/client/views/core/ErrorLabel' | ||
13 | |||
14 | const StudentForm = props => ( | ||
15 | <div className="stepy-validation"> | ||
16 | <Stepper | ||
17 | steps={[ | ||
18 | { | ||
19 | label: 'Personal data', | ||
20 | active: props.currentStep === 0, | ||
21 | }, | ||
22 | { | ||
23 | label: 'Academic', | ||
24 | active: props.currentStep === 1, | ||
25 | }, | ||
26 | { | ||
27 | label: 'Address', | ||
28 | active: props.currentStep === 2, | ||
29 | }, | ||
30 | { | ||
31 | label: 'Parent info', | ||
32 | active: props.currentStep === 3, | ||
33 | } | ||
34 | ]} | ||
35 | /> | ||
36 | {props.currentStep === 0 && ( | ||
37 | <fieldset title="1"> | ||
38 | <legend className="text-semibold">Personal data</legend> | ||
39 | <Row> | ||
40 | <Col xs={12} sm={6}> | ||
41 | <FormGroup controlId="admissionId"> | ||
42 | <Label required>Admission Id</Label> | ||
43 | <FormControl | ||
44 | type="text" | ||
45 | value={props.getValue('admissionId')} | ||
46 | placeholder="admission Id" | ||
47 | onChange={e => props.setValue('admissionId', e.target.value)} | ||
48 | /> | ||
49 | {props.isSubmitted() && props.errors && props.errors.admissionId && ( | ||
50 | <ErrorLabel> {props.errors.admissionId} </ErrorLabel> | ||
51 | )} | ||
52 | </FormGroup> | ||
53 | </Col> | ||
54 | <Col xs={12} sm={6}> | ||
55 | <FormGroup controlId="firstName"> | ||
56 | <Label required>First Name</Label> | ||
57 | <FormControl | ||
58 | type="text" | ||
59 | value={props.getValue('firstName')} | ||
60 | placeholder="First Name" | ||
61 | onChange={e => props.setValue('firstName', e.target.value)} | ||
62 | /> | ||
63 | {props.isSubmitted() && props.errors && props.errors.firstName && ( | ||
64 | <ErrorLabel> {props.errors.firstName} </ErrorLabel> | ||
65 | )} | ||
66 | </FormGroup> | ||
67 | </Col> | ||
68 | </Row> | ||
69 | <Row> | ||
70 | <Col xs={12} sm={6}> | ||
71 | <FormGroup controlId="lastName"> | ||
72 | <Label required>Last Name</Label> | ||
73 | <FormControl | ||
74 | type="text" | ||
75 | value={props.getValue('lastName')} | ||
76 | placeholder="Last Name" | ||
77 | onChange={e => props.setValue('lastName', e.target.value)} | ||
78 | /> | ||
79 | {props.isSubmitted() && props.errors && props.errors.lastName && ( | ||
80 | <ErrorLabel> {props.errors.lastName} </ErrorLabel> | ||
81 | )} | ||
82 | </FormGroup> | ||
83 | </Col> | ||
84 | <Col xs={12} sm={6}> | ||
85 | <FormGroup controlId="formControlsSelect"> | ||
86 | <Label>Gender</Label> | ||
87 | <FormControl componentClass="select" | ||
88 | placeholder="select" | ||
89 | value={props.getValue('gender')} | ||
90 | onChange={e => props.setValue('gender', e.target.value)} | ||
91 | > | ||
92 | <option value="male">Male</option> | ||
93 | <option value="female">Female</option> | ||
94 | </FormControl> | ||
95 | {props.isSubmitted() && props.errors && props.errors.gender && ( | ||
96 | <ErrorLabel> {props.errors.gender} </ErrorLabel> | ||
97 | )} | ||
98 | </FormGroup> | ||
99 | </Col> | ||
100 | </Row> | ||
101 | <Row> | ||
102 | <Col xs={12} sm={6}> | ||
103 | <FormGroup controlId="email"> | ||
104 | <Label required>Email</Label> | ||
105 | <FormControl | ||
106 | type="email" | ||
107 | value={props.getValue('email')} | ||
108 | placeholder="Email" | ||
109 | onChange={e => props.setValue('email', e.target.value)} | ||
110 | /> | ||
111 | {props.isSubmitted() && props.errors && props.errors.email && ( | ||
112 | <ErrorLabel> {props.errors.email} </ErrorLabel> | ||
113 | )} | ||
114 | </FormGroup> | ||
115 | </Col> | ||
116 | <Col xs={12} sm={6}> | ||
117 | <FormGroup> | ||
118 | <Label required>Date of birth</Label> | ||
119 | <DatePicker | ||
120 | id="dob" | ||
121 | setValue = {props.setValue} | ||
122 | value={props.getValue('dob')} | ||
123 | onChange={(e) => { | ||
124 | props.setValue('dob', e.target.value) | ||
125 | }} | ||
126 | /> | ||
127 | {props.isSubmitted() && props.errors && props.errors.dob && ( | ||
128 | <ErrorLabel> {props.errors.dob} </ErrorLabel> | ||
129 | )} | ||
130 | </FormGroup> | ||
131 | </Col> | ||
132 | </Row> | ||
133 | <Row> | ||
134 | |||
135 | </Row> | ||
136 | </fieldset> | ||
137 | )} | ||
138 | {props.currentStep === 1 && ( | ||
139 | <fieldset title="Academic"> | ||
140 | <legend className="text-semibold">Academic</legend> | ||
141 | <Row> | ||
142 | <Col xs={12} sm={6}> | ||
143 | <FormGroup controlId="rollNo"> | ||
144 | <Label required>Roll No</Label> | ||
145 | <FormControl | ||
146 | type="text" | ||
147 | value={props.getValue('rollNo')} | ||
148 | placeholder="Roll No" | ||
149 | onChange={e => props.setValue('rollNo', e.target.value)} | ||
150 | /> | ||
151 | {props.isSubmitted() && props.errors && props.errors.rollNo && ( | ||
152 | <ErrorLabel> {props.errors.rollNo} </ErrorLabel> | ||
153 | )} | ||
154 | </FormGroup> | ||
155 | </Col> | ||
156 | <Col xs={12} sm={6}> | ||
157 | <FormGroup controlId="class"> | ||
158 | <Label required>Class</Label> | ||
159 | <FormControl | ||
160 | type="text" | ||
161 | value={props.getValue('studentClass')} | ||
162 | placeholder="7" | ||
163 | onChange={e => props.setValue('studentClass', e.target.value)} | ||
164 | /> | ||
165 | {props.isSubmitted() && props.errors && props.errors.studentClass && ( | ||
166 | <ErrorLabel> {props.errors.studentClass} </ErrorLabel> | ||
167 | )} | ||
168 | </FormGroup> | ||
169 | </Col> | ||
170 | </Row> | ||
171 | <Row> | ||
172 | <Col xs={12} sm={6}> | ||
173 | <FormGroup controlId="section"> | ||
174 | <Label required>Section</Label> | ||
175 | <FormControl | ||
176 | type="text" | ||
177 | value={props.getValue('section')} | ||
178 | placeholder="B" | ||
179 | onChange={e => props.setValue('section', e.target.value)} | ||
180 | /> | ||
181 | {props.isSubmitted() && props.errors && props.errors.section && ( | ||
182 | <ErrorLabel> {props.errors.section} </ErrorLabel> | ||
183 | )} | ||
184 | </FormGroup> | ||
185 | </Col> | ||
186 | <Col xs={12} sm={6}> | ||
187 | <FormGroup controlId="community"> | ||
188 | <Label required>Community</Label> | ||
189 | <FormControl | ||
190 | type="text" | ||
191 | value={props.getValue('community')} | ||
192 | placeholder="General" | ||
193 | onChange={e => props.setValue('community', e.target.value)} | ||
194 | /> | ||
195 | {props.isSubmitted() && props.errors && props.errors.community && ( | ||
196 | <ErrorLabel> {props.errors.community} </ErrorLabel> | ||
197 | )} | ||
198 | </FormGroup> | ||
199 | </Col> | ||
200 | </Row> | ||
201 | <Row> | ||
202 | <Col xs={12} sm={6}> | ||
203 | <FormGroup controlId="bloodGroup"> | ||
204 | <Label required>bloodGroup</Label> | ||
205 | <FormControl | ||
206 | type="text" | ||
207 | value={props.getValue('bloodGroup')} | ||
208 | placeholder="B+" | ||
209 | onChange={e => props.setValue('bloodGroup', e.target.value)} | ||
210 | /> | ||
211 | {props.isSubmitted() && props.errors && props.errors.bloodGroup && ( | ||
212 | <ErrorLabel> {props.errors.bloodGroup} </ErrorLabel> | ||
213 | )} | ||
214 | </FormGroup> | ||
215 | </Col> | ||
216 | <Col xs={12} sm={6}> | ||
217 | <FormGroup controlId="phone"> | ||
218 | <Label required>Phone</Label> | ||
219 | <FormControl | ||
220 | type="text" | ||
221 | value={props.getValue('phone')} | ||
222 | placeholder="9999999999" | ||
223 | onChange={e => props.setValue('phone', e.target.value)} | ||
224 | /> | ||
225 | {props.isSubmitted() && props.errors && props.errors.phone && ( | ||
226 | <ErrorLabel> {props.errors.phone} </ErrorLabel> | ||
227 | )} | ||
228 | </FormGroup> | ||
229 | </Col> | ||
230 | </Row> | ||
231 | </fieldset> | ||
232 | )} | ||
233 | {props.currentStep === 2 && ( | ||
234 | <fieldset title="Address"> | ||
235 | <legend className="text-semibold">Address</legend> | ||
236 | <Row> | ||
237 | <Col xs={12} sm={6}> | ||
238 | <FormGroup controlId="address"> | ||
239 | <Label required>Address</Label> | ||
240 | <FormControl | ||
241 | type="text" | ||
242 | value={props.getValue('address')} | ||
243 | placeholder="#876, Street, town" | ||
244 | onChange={e => props.setValue('address', e.target.value)} | ||
245 | /> | ||
246 | {props.isSubmitted() && props.errors && props.errors.address && ( | ||
247 | <ErrorLabel> {props.errors.address} </ErrorLabel> | ||
248 | )} | ||
249 | </FormGroup> | ||
250 | </Col> | ||
251 | <Col xs={12} sm={6}> | ||
252 | <FormGroup controlId="city"> | ||
253 | <Label required>City</Label> | ||
254 | <FormControl | ||
255 | type="text" | ||
256 | value={props.getValue('city')} | ||
257 | placeholder="Chennai" | ||
258 | onChange={e => props.setValue('city', e.target.value)} | ||
259 | /> | ||
260 | {props.isSubmitted() && props.errors && props.errors.city && ( | ||
261 | <ErrorLabel> {props.errors.city} </ErrorLabel> | ||
262 | )} | ||
263 | </FormGroup> | ||
264 | </Col> | ||
265 | </Row> | ||
266 | <Row> | ||
267 | <Col xs={12} sm={6}> | ||
268 | <FormGroup controlId="state"> | ||
269 | <Label required>State</Label> | ||
270 | <FormControl | ||
271 | type="text" | ||
272 | value={props.getValue('state')} | ||
273 | placeholder="Tamilnadu" | ||
274 | onChange={e => props.setValue('state', e.target.value)} | ||
275 | /> | ||
276 | {props.isSubmitted() && props.errors && props.errors.state && ( | ||
277 | <ErrorLabel> {props.errors.state} </ErrorLabel> | ||
278 | )} | ||
279 | </FormGroup> | ||
280 | </Col> | ||
281 | </Row> | ||
282 | </fieldset> | ||
283 | )} | ||
284 | {props.currentStep === 3 && ( | ||
285 | <fieldset title="2"> | ||
286 | <legend className="text-semibold">Parent information</legend> | ||
287 | <Row> | ||
288 | <Col xs={12} sm={6}> | ||
289 | <FormGroup controlId="parentName"> | ||
290 | <Label required>Parent Name</Label> | ||
291 | <FormControl | ||
292 | type="text" | ||
293 | value={props.getValue('parentName')} | ||
294 | placeholder="John" | ||
295 | onChange={e => props.setValue('parentName', e.target.value)} | ||
296 | /> | ||
297 | {props.isSubmitted() && props.errors && props.errors.parentName && ( | ||
298 | <ErrorLabel> {props.errors.parentName} </ErrorLabel> | ||
299 | )} | ||
300 | </FormGroup> | ||
301 | </Col> | ||
302 | <Col xs={12} sm={6}> | ||
303 | <FormGroup controlId="parentEmail"> | ||
304 | <Label required>Parent Email</Label> | ||
305 | <FormControl | ||
306 | type="text" | ||
307 | value={props.getValue('parentEmail')} | ||
308 | placeholder="john@email.com" | ||
309 | onChange={e => props.setValue('parentEmail', e.target.value)} | ||
310 | /> | ||
311 | {props.isSubmitted() && props.errors && props.errors.parentEmail && ( | ||
312 | <ErrorLabel> {props.errors.parentEmail} </ErrorLabel> | ||
313 | )} | ||
314 | </FormGroup> | ||
315 | </Col> | ||
316 | </Row> | ||
317 | <Row> | ||
318 | <Col xs={12} sm={6}> | ||
319 | <FormGroup controlId="relation"> | ||
320 | <Label required>Relation</Label> | ||
321 | <FormControl | ||
322 | type="text" | ||
323 | value={props.getValue('relation')} | ||
324 | placeholder="Father" | ||
325 | onChange={e => props.setValue('relation', e.target.value)} | ||
326 | /> | ||
327 | {props.isSubmitted() && props.errors && props.errors.relation && ( | ||
328 | <ErrorLabel> {props.errors.relation} </ErrorLabel> | ||
329 | )} | ||
330 | </FormGroup> | ||
331 | </Col> | ||
332 | <Col xs={12} sm={6}> | ||
333 | <FormGroup controlId="profession"> | ||
334 | <Label required>Profession</Label> | ||
335 | <FormControl | ||
336 | type="text" | ||
337 | value={props.getValue('profession')} | ||
338 | placeholder="Farmer" | ||
339 | onChange={e => props.setValue('profession', e.target.value)} | ||
340 | /> | ||
341 | {props.isSubmitted() && props.errors && props.errors.profession && ( | ||
342 | <ErrorLabel> {props.errors.profession} </ErrorLabel> | ||
343 | )} | ||
344 | </FormGroup> | ||
345 | </Col> | ||
346 | </Row> | ||
347 | <Row> | ||
348 | <Col xs={12} sm={6}> | ||
349 | <FormGroup controlId="parentGender"> | ||
350 | <Label>Parent Gender</Label> | ||
351 | <FormControl componentClass="select" | ||
352 | placeholder="select" | ||
353 | value={props.getValue('parentGender')} | ||
354 | onChange={e => props.setValue('parentGender', e.target.value)} | ||
355 | > | ||
356 | <option value="male">Male</option> | ||
357 | <option value="female">Female</option> | ||
358 | </FormControl> | ||
359 | {props.isSubmitted() && props.errors && props.errors.parentGender && ( | ||
360 | <ErrorLabel> {props.errors.parentGender} </ErrorLabel> | ||
361 | )} | ||
362 | </FormGroup> | ||
363 | </Col> | ||
364 | <Col xs={12} sm={6}> | ||
365 | <FormGroup controlId="parentPhone"> | ||
366 | <Label required>Parent Phone</Label> | ||
367 | <FormControl | ||
368 | type="text" | ||
369 | value={props.getValue('parentPhone')} | ||
370 | placeholder="9876543210" | ||
371 | onChange={e => props.setValue('parentPhone', e.target.value)} | ||
372 | /> | ||
373 | {props.isSubmitted() && props.errors && props.errors.parentPhone && ( | ||
374 | <ErrorLabel> {props.errors.parentPhone} </ErrorLabel> | ||
375 | )} | ||
376 | </FormGroup> | ||
377 | </Col> | ||
378 | </Row> | ||
379 | <Row> | ||
380 | <Col xs={12} sm={6}> | ||
381 | <FormGroup controlId="parentAddress"> | ||
382 | <Label required>Parent Address</Label> | ||
383 | <FormControl | ||
384 | type="text" | ||
385 | value={props.getValue('parentAddress')} | ||
386 | placeholder="#12, street, town" | ||
387 | onChange={e => props.setValue('parentAddress', e.target.value)} | ||
388 | /> | ||
389 | {props.isSubmitted() && props.errors && props.errors.parentAddress && ( | ||
390 | <ErrorLabel> {props.errors.parentAddress} </ErrorLabel> | ||
391 | )} | ||
392 | </FormGroup> | ||
393 | </Col> | ||
394 | <Col xs={12} sm={6}> | ||
395 | <FormGroup controlId="parentCity"> | ||
396 | <Label required>Parent City</Label> | ||
397 | <FormControl | ||
398 | type="text" | ||
399 | value={props.getValue('parentCity')} | ||
400 | placeholder="Chennai" | ||
401 | onChange={e => props.setValue('parentCity', e.target.value)} | ||
402 | /> | ||
403 | {props.isSubmitted() && props.errors && props.errors.parentCity && ( | ||
404 | <ErrorLabel> {props.errors.parentCity} </ErrorLabel> | ||
405 | )} | ||
406 | </FormGroup> | ||
407 | </Col> | ||
408 | </Row> | ||
409 | <Row> | ||
410 | <Col xs={12} sm={6}> | ||
411 | <FormGroup controlId="parentState"> | ||
412 | <Label required>Parent State</Label> | ||
413 | <FormControl | ||
414 | type="text" | ||
415 | value={props.getValue('parentState')} | ||
416 | placeholder="600031" | ||
417 | onChange={e => props.setValue('parentState', e.target.value)} | ||
418 | /> | ||
419 | {props.isSubmitted() && props.errors && props.errors.parentState && ( | ||
420 | <ErrorLabel> {props.errors.parentState} </ErrorLabel> | ||
421 | )} | ||
422 | </FormGroup> | ||
423 | </Col> | ||
424 | <Col xs={12} sm={6}> | ||
425 | <FormGroup controlId="parentZipcode"> | ||
426 | <Label required>Parent Zipcode</Label> | ||
427 | <FormControl | ||
428 | type="text" | ||
429 | value={props.getValue('parentZipcode')} | ||
430 | placeholder="600031" | ||
431 | onChange={e => props.setValue('parentZipcode', e.target.value)} | ||
432 | /> | ||
433 | {props.isSubmitted() && props.errors && props.errors.parentZipcode && ( | ||
434 | <ErrorLabel> {props.errors.parentZipcode} </ErrorLabel> | ||
435 | )} | ||
436 | </FormGroup> | ||
437 | </Col> | ||
438 | </Row> | ||
439 | </fieldset> | ||
440 | )} | ||
441 | <div style={{ textAlign: 'left' }}> | ||
442 | {props.currentStep > 0 && ( | ||
443 | <div style={{ display: 'inline-block', marginRight: 10 }}> | ||
444 | <Button onClick={props.onBackClick}> | ||
445 | <i className="icon-arrow-left13 position-left"></i> | ||
446 | BACK | ||
447 | </Button> | ||
448 | |||
449 | </div> | ||
450 | )} | ||
451 | {props.currentStep < 3 && ( | ||
452 | <div style={{ display: 'inline-block' }}> | ||
453 | <Button | ||
454 | bsStyle="primary" | ||
455 | onClick={props.onNextClick} | ||
456 | > | ||
457 | NEXT | ||
458 | <i className="icon-arrow-right14 position-right" /> | ||
459 | </Button> | ||
460 | </div> | ||
461 | )} | ||
462 | {props.currentStep === 3 && ( | ||
463 | <div style={{ display: 'inline-block' }}> | ||
464 | <Button | ||
465 | bsStyle="primary" | ||
466 | onClick={props.onNextClick} | ||
467 | > | ||
468 | SAVE | ||
469 | <i className="fa fa-check" /> | ||
470 | </Button> | ||
471 | </div> | ||
472 | )} | ||
473 | </div> | ||
474 | </div> | ||
475 | ) | ||
476 | |||
477 | StudentForm.propTypes = { | ||
478 | currentStep: PropTypes.number.isRequired, | ||
479 | onNextClick: PropTypes.func.isRequired, | ||
480 | onBackClick: PropTypes.func.isRequired, | ||
481 | setValue: PropTypes.func.isRequired, | ||
482 | getValue: PropTypes.func.isRequired, | ||
483 | } | ||
484 | |||
485 | export default StudentForm | ||
486 | 1 | import React, { PropTypes } from 'react' |
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 { Navbar,Modal, Nav, NavItem, | 6 | import { Navbar,Modal, Nav, NavItem, |
7 | Glyphicon, Collapse, FormGroup, FormControl, Panel, | 7 | Glyphicon, Collapse, FormGroup, FormControl, Panel, |
8 | NavbarToggler, NavbarBrand, Table, ButtonToolbar, | 8 | NavbarToggler, NavbarBrand, Table, ButtonToolbar, |
9 | NavLink, DropdownItem, DropdownToggle, DropdownMenu, | 9 | NavLink, DropdownItem, DropdownToggle, DropdownMenu, |
10 | NavDropdown, MenuItem, Breadcrumb, Button } from 'react-bootstrap'; | 10 | NavDropdown, MenuItem, Breadcrumb, Button } from 'react-bootstrap'; |
11 | import { StudentTable } from './view/StudentTable'; | 11 | import { StudentTable } from './view/StudentTable'; |
12 | import { Header } from '../Header'; | 12 | import { Header } from '../Header'; |
13 | import { AdminSidebar } from '../Sidebar' | 13 | import { AdminSidebar } from '../Sidebar' |
14 | import { AdminBreadcrumb } from '../Breadcrumb' | 14 | import { AdminBreadcrumb } from '../Breadcrumb' |
15 | import { FabMenuView } from './FabMenu'; | ||
16 | import { UploadCsv } from './UploadCsv'; | 15 | import { UploadCsv } from './UploadCsv'; |
17 | import { AddStudent } from './addStudent'; | 16 | import { AddStudent } from './add/addStudent'; |
18 | import { Students } from '/imports/collections/students/index'; | 17 | import { Students } from '/imports/collections/students/index'; |
19 | 18 | import './student.css' | |
20 | 19 | ||
21 | export class StudentView extends Component { | 20 | export class StudentView extends Component { |
22 | 21 | ||
23 | constructor(props) { | 22 | constructor(props) { |
24 | super(props); | 23 | super(props); |
25 | this.state = { | 24 | this.state = { |
26 | show: false, | 25 | show: false, |
27 | firstNameSearch: "", | 26 | firstNameSearch: "", |
28 | lastNameSearch: "", | 27 | lastNameSearch: "", |
29 | }; | 28 | }; |
30 | this.showModal = this.showModal.bind(this); | 29 | this.showModal = this.showModal.bind(this); |
31 | this.hideModal = this.hideModal.bind(this); | 30 | this.hideModal = this.hideModal.bind(this); |
32 | this.onUpdate = this.onUpdate.bind(this); | 31 | this.onUpdate = this.onUpdate.bind(this); |
33 | }; | 32 | }; |
34 | 33 | ||
35 | showModal() { | 34 | showModal() { |
36 | this.setState({show: true}); | 35 | this.setState({show: true}); |
37 | } | 36 | } |
38 | 37 | ||
39 | hideModal() { | 38 | hideModal() { |
40 | this.setState({show: false}); | 39 | this.setState({show: false}); |
41 | } | 40 | } |
42 | onUpdate(key, value) { | 41 | onUpdate(key, value) { |
43 | this.setState({[key]: value}); | 42 | this.setState({[key]: value}); |
44 | }; | 43 | }; |
45 | 44 | ||
46 | render() { | 45 | render() { |
47 | firstNameSearch = this.state.firstNameSearch; | 46 | firstNameSearch = this.state.firstNameSearch; |
48 | lastNameSearch = this.state.lastNameSearch; | 47 | lastNameSearch = this.state.lastNameSearch; |
49 | var students =_.filter(this.props.data.students,function(item){ | 48 | var students =_.filter(this.props.data.students,function(item){ |
50 | if(item.firstName){ | 49 | if(item.firstName){ |
51 | return _.includes(item.firstName.toLowerCase(),firstNameSearch.toLowerCase()); | 50 | return _.includes(item.firstName.toLowerCase(),firstNameSearch.toLowerCase()); |
52 | } | 51 | } |
53 | }); | 52 | }); |
54 | return ( | 53 | return ( |
55 | <div className="appLayout-box"> | 54 | <div className="appLayout-box"> |
56 | <div className="page-container"> | 55 | <div className="page-container"> |
57 | <div className="page-content"> | 56 | <div className="page-content"> |
58 | <AdminSidebar | 57 | <AdminSidebar |
59 | user = {this.props.data.user} | 58 | user = {this.props.data.user} |
60 | org = {this.props.data.org} | 59 | org = {this.props.data.org} |
61 | /> | 60 | /> |
62 | {/*end sidebar*/} | 61 | {/*end sidebar*/} |
63 | <div className="content-wrapper"> | 62 | <div className="content-wrapper"> |
64 | <AdminBreadcrumb /> | 63 | <AdminBreadcrumb /> |
65 | {/*content*/} | 64 | {/*content*/} |
66 | 65 | ||
67 | <div className="content has-detached-left"> | 66 | <div className="content has-detached-left"> |
68 | <div className="container-detached"> | 67 | <div className="container-detached"> |
69 | <div className="content-detached"> | 68 | <div className="content-detached"> |
70 | <Header/> | 69 | <Header/> |
71 | <StudentTable | 70 | <StudentTable |
72 | data = {this.props.data} | 71 | data = {this.props.data} |
73 | students = {students} | 72 | students = {students} |
74 | /> | 73 | /> |
75 | <AddStudent/> | 74 | <AddStudent/> |
76 | <UploadCsv /> | 75 | <UploadCsv /> |
77 | </div> | 76 | </div> |
78 | </div> | 77 | </div> |
79 | <div className="sidebar-detached affix-top"> | 78 | <div className="sidebar-detached affix-top"> |
80 | <div className="sidebar sidebar-default"> | 79 | <div className="sidebar sidebar-default"> |
81 | <div className="sidebar-content"> | 80 | <div className="sidebar-content"> |
82 | 81 | ||
83 | <div className="sidebar-category"> | 82 | <div className="sidebar-category"> |
84 | <div className="category-title"> | 83 | <div className="category-title"> |
85 | <span>Advanced Search</span> | 84 | <span>Advanced Search</span> |
86 | <ul className="icons-list"> | 85 | <ul className="icons-list"> |
87 | <li><a href="#" data-action="collapse"></a></li> | 86 | <li><a href="#" data-action="collapse"></a></li> |
88 | </ul> | 87 | </ul> |
89 | </div> | 88 | </div> |
90 | 89 | ||
91 | <div className="category-content"> | 90 | <div className="category-content"> |
92 | <form action="#"> | 91 | <form action="#"> |
93 | <div className="has-feedback has-feedback-left"> | 92 | <div className="has-feedback has-feedback-left"> |
94 | <input type="search" className="form-control" | 93 | <input type="search" className="form-control" |
95 | value={this.state.firstNameSearch} | 94 | value={this.state.firstNameSearch} |
96 | onChange={e=>this.onUpdate('firstNameSearch',e.target.value)} | 95 | onChange={e=>this.onUpdate('firstNameSearch',e.target.value)} |
97 | placeholder="First Name" | 96 | placeholder="First Name" |
98 | /> | 97 | /> |
99 | <div className="form-control-feedback"> | 98 | <div className="form-control-feedback"> |
100 | <i className="icon-search4 text-size-base text-muted"></i> | 99 | <i className="icon-search4 text-size-base text-muted"></i> |
101 | </div> | 100 | </div> |
102 | </div> | 101 | </div> |
103 | </form> | 102 | </form> |
104 | </div> | 103 | </div> |
105 | <div className="category-content"> | 104 | <div className="category-content"> |
106 | <form action="#"> | 105 | <form action="#"> |
107 | <div className="has-feedback has-feedback-left"> | 106 | <div className="has-feedback has-feedback-left"> |
108 | <input type="search" className="form-control" | 107 | <input type="search" className="form-control" |
109 | value={this.state.lastNameSearch} | 108 | value={this.state.lastNameSearch} |
110 | onChange={e=>this.onUpdate('lastNameSearch',e.target.value)} | 109 | onChange={e=>this.onUpdate('lastNameSearch',e.target.value)} |
111 | placeholder="Last Name" /> | 110 | placeholder="Last Name" /> |
112 | <div className="form-control-feedback"> | 111 | <div className="form-control-feedback"> |
113 | <i className="icon-search4 text-size-base text-muted"></i> | 112 | <i className="icon-search4 text-size-base text-muted"></i> |
114 | </div> | 113 | </div> |
115 | </div> | 114 | </div> |
116 | </form> | 115 | </form> |
117 | </div> | 116 | </div> |
118 | </div> | 117 | </div> |
119 | </div> | 118 | </div> |
120 | </div> | 119 | </div> |
121 | </div> | 120 | </div> |
122 | </div> | 121 | </div> |
123 | </div> | 122 | </div> |
124 | </div> | 123 | </div> |
125 | </div> | 124 | </div> |
126 | </div> | 125 | </div> |
127 | ); | 126 | ); |
128 | }; | 127 | }; |
129 | 128 | ||
130 | }; | 129 | }; |
131 | 130 |
imports/client/views/org/admin/students/add/AddStudentFormContainer.js
File was created | 1 | import React, { Component } from 'react' | |
2 | import { AddStudentForm } from './addStudentForm' | ||
3 | import StudentForm from './StudentForm' | ||
4 | import Form from '/imports/client/views/core/Form' | ||
5 | import Validator from '/imports/client/views/core/Validator' | ||
6 | import { isRequired, isValidEmail } from '/imports/client/views/core/validations' | ||
7 | import { addStudentManually } from '/imports/collections/students/methods'; | ||
8 | |||
9 | export class AddStudentFormContainer extends Component { | ||
10 | |||
11 | constructor(props) { | ||
12 | super(props) | ||
13 | this.state = { currentStep: 0 } | ||
14 | this.handleNextClick = this.handleNextClick.bind(this) | ||
15 | this.handleBackClick = this.handleBackClick.bind(this) | ||
16 | this.handleSubmit = this.handleSubmit.bind(this) | ||
17 | } | ||
18 | |||
19 | handleNextClick() { | ||
20 | this.form.handleSubmit() | ||
21 | if (this.validator.getErrors() && Object.keys(this.validator.getErrors()).length > 0) return | ||
22 | this.setState({ currentStep: this.state.currentStep + 1 }) | ||
23 | this.form.resetSubmitted() | ||
24 | } | ||
25 | |||
26 | handleBackClick() { | ||
27 | this.setState({ currentStep: this.state.currentStep + -1 }) | ||
28 | } | ||
29 | |||
30 | handleSubmit() { | ||
31 | if (this.state.currentStep === 3) { | ||
32 | addStudentManually.call(this.form.state.values) | ||
33 | } | ||
34 | } | ||
35 | |||
36 | //render callback | ||
37 | render() { | ||
38 | return ( | ||
39 | <Form | ||
40 | onSubmit={this.handleSubmit} | ||
41 | ref={form => this.form = form} | ||
42 | initialValues={{ | ||
43 | gender: 'male', | ||
44 | parentGender: 'male', | ||
45 | }} | ||
46 | > | ||
47 | {({ values, setValue, getValue, isSubmitted, isDirty }) => ( | ||
48 | <Validator | ||
49 | values={values} | ||
50 | ref={validator => this.validator = validator} | ||
51 | validations={{ | ||
52 | admissionId: [(value) => isRequired('Admission id', value)], | ||
53 | firstName: [(value) => isRequired('First name', value)], | ||
54 | lastName: [(value) => isRequired('Last name', value)], | ||
55 | email: [(value) => isRequired('Email', value), isValidEmail], | ||
56 | dob: [(value) => isRequired('Date of birth', value)], | ||
57 | gender: [(value) => isRequired('Gender', value)], | ||
58 | rollNo: [(value) => this.state.currentStep === 1 && isRequired('Roll no', value)], | ||
59 | studentClass: [(value) => this.state.currentStep === 1 && isRequired('Class', value)], | ||
60 | section: [(value) => this.state.currentStep === 1 && isRequired('Section', value)], | ||
61 | community: [(value) => this.state.currentStep === 1 && isRequired('Community', value)], | ||
62 | bloodGroup: [(value) => this.state.currentStep === 1 && isRequired('Blood group', value)], | ||
63 | phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], | ||
64 | address: [(value) => this.state.currentStep === 2 && isRequired('Address', value)], | ||
65 | city: [(value) => this.state.currentStep === 2 && isRequired('City', value)], | ||
66 | state: [(value) => this.state.currentStep === 2 && isRequired('State', value)], | ||
67 | parentName: [(value) => this.state.currentStep === 3 && isRequired('Parent name', value)], | ||
68 | parentEmail: [(value) => this.state.currentStep === 3 && isRequired('Parent email', value), (value) => this.state.currentStep === 3 && isValidEmail(value)], | ||
69 | relation: [(value) => this.state.currentStep === 3 && isRequired('Relation', value)], | ||
70 | profession: [(value) => this.state.currentStep === 3 && isRequired('Profession', value)], | ||
71 | parentGender: [(value) => this.state.currentStep === 3 && isRequired('Parent gender', value)], | ||
72 | parentPhone: [(value) => this.state.currentStep === 3 && isRequired('Parent phone', value)], | ||
73 | parentAddress: [(value) => this.state.currentStep === 3 && isRequired('Parent address', value)], | ||
74 | parentCity: [(value) => this.state.currentStep === 3 && isRequired('Parent city', value)], | ||
75 | parentState: [(value) => this.state.currentStep === 3 && isRequired('Parent state', value)], | ||
76 | parentZipcode: [(value) => this.state.currentStep === 3 && isRequired('Parent zip code', value)], | ||
77 | }} | ||
78 | > | ||
79 | {({ errors }) => ( | ||
80 | <StudentForm | ||
81 | isDirty={isDirty} | ||
82 | setValue={setValue} | ||
83 | getValue={getValue} | ||
84 | isSubmitted={isSubmitted} | ||
85 | errors={errors} | ||
86 | onNextClick={this.handleNextClick} | ||
87 | onBackClick={this.handleBackClick} | ||
88 | currentStep={this.state.currentStep} | ||
89 | /> | ||
90 | )} | ||
91 | </Validator> | ||
92 | )} | ||
93 | </Form> | ||
94 | ) | ||
95 | } | ||
96 | } | ||
97 |
imports/client/views/org/admin/students/add/StudentForm.js
File was created | 1 | import React, { PropTypes } from 'react' | |
2 | import { | ||
3 | Row, | ||
4 | Col, | ||
5 | FormGroup, | ||
6 | FormControl, | ||
7 | Button | ||
8 | } from 'react-bootstrap' | ||
9 | import DatePicker from '/imports/client/views/core/DatePicker' | ||
10 | import Label from '/imports/client/views/core/Label' | ||
11 | import Stepper from '/imports/client/views/core/Stepper' | ||
12 | import ErrorLabel from '/imports/client/views/core/ErrorLabel' | ||
13 | |||
14 | const StudentForm = props => ( | ||
15 | <div className="stepy-validation"> | ||
16 | <Stepper | ||
17 | steps={[ | ||
18 | { | ||
19 | label: 'Personal data', | ||
20 | active: props.currentStep === 0, | ||
21 | }, | ||
22 | { | ||
23 | label: 'Academic', | ||
24 | active: props.currentStep === 1, | ||
25 | }, | ||
26 | { | ||
27 | label: 'Address', | ||
28 | active: props.currentStep === 2, | ||
29 | }, | ||
30 | { | ||
31 | label: 'Parent info', | ||
32 | active: props.currentStep === 3, | ||
33 | } | ||
34 | ]} | ||
35 | /> | ||
36 | {props.currentStep === 0 && ( | ||
37 | <fieldset title="1"> | ||
38 | <legend className="text-semibold">Personal data</legend> | ||
39 | <Row> | ||
40 | <Col xs={12} sm={6}> | ||
41 | <FormGroup controlId="admissionId"> | ||
42 | <Label required>Admission Id</Label> | ||
43 | <FormControl | ||
44 | type="text" | ||
45 | value={props.getValue('admissionId')} | ||
46 | placeholder="admission Id" | ||
47 | onChange={e => props.setValue('admissionId', e.target.value)} | ||
48 | /> | ||
49 | {props.isSubmitted() && props.errors && props.errors.admissionId && ( | ||
50 | <ErrorLabel> {props.errors.admissionId} </ErrorLabel> | ||
51 | )} | ||
52 | </FormGroup> | ||
53 | </Col> | ||
54 | <Col xs={12} sm={6}> | ||
55 | <FormGroup controlId="firstName"> | ||
56 | <Label required>First Name</Label> | ||
57 | <FormControl | ||
58 | type="text" | ||
59 | value={props.getValue('firstName')} | ||
60 | placeholder="First Name" | ||
61 | onChange={e => props.setValue('firstName', e.target.value)} | ||
62 | /> | ||
63 | {props.isSubmitted() && props.errors && props.errors.firstName && ( | ||
64 | <ErrorLabel> {props.errors.firstName} </ErrorLabel> | ||
65 | )} | ||
66 | </FormGroup> | ||
67 | </Col> | ||
68 | </Row> | ||
69 | <Row> | ||
70 | <Col xs={12} sm={6}> | ||
71 | <FormGroup controlId="lastName"> | ||
72 | <Label required>Last Name</Label> | ||
73 | <FormControl | ||
74 | type="text" | ||
75 | value={props.getValue('lastName')} | ||
76 | placeholder="Last Name" | ||
77 | onChange={e => props.setValue('lastName', e.target.value)} | ||
78 | /> | ||
79 | {props.isSubmitted() && props.errors && props.errors.lastName && ( | ||
80 | <ErrorLabel> {props.errors.lastName} </ErrorLabel> | ||
81 | )} | ||
82 | </FormGroup> | ||
83 | </Col> | ||
84 | <Col xs={12} sm={6}> | ||
85 | <FormGroup controlId="formControlsSelect"> | ||
86 | <Label>Gender</Label> | ||
87 | <FormControl componentClass="select" | ||
88 | placeholder="select" | ||
89 | value={props.getValue('gender')} | ||
90 | onChange={e => props.setValue('gender', e.target.value)} | ||
91 | > | ||
92 | <option value="male">Male</option> | ||
93 | <option value="female">Female</option> | ||
94 | </FormControl> | ||
95 | {props.isSubmitted() && props.errors && props.errors.gender && ( | ||
96 | <ErrorLabel> {props.errors.gender} </ErrorLabel> | ||
97 | )} | ||
98 | </FormGroup> | ||
99 | </Col> | ||
100 | </Row> | ||
101 | <Row> | ||
102 | <Col xs={12} sm={6}> | ||
103 | <FormGroup controlId="email"> | ||
104 | <Label required>Email</Label> | ||
105 | <FormControl | ||
106 | type="email" | ||
107 | value={props.getValue('email')} | ||
108 | placeholder="Email" | ||
109 | onChange={e => props.setValue('email', e.target.value)} | ||
110 | /> | ||
111 | {props.isSubmitted() && props.errors && props.errors.email && ( | ||
112 | <ErrorLabel> {props.errors.email} </ErrorLabel> | ||
113 | )} | ||
114 | </FormGroup> | ||
115 | </Col> | ||
116 | <Col xs={12} sm={6}> | ||
117 | <FormGroup> | ||
118 | <Label required>Date of birth</Label> | ||
119 | <DatePicker | ||
120 | id="dob" | ||
121 | setValue = {props.setValue} | ||
122 | value={props.getValue('dob')} | ||
123 | onChange={(e) => { | ||
124 | props.setValue('dob', e.target.value) | ||
125 | }} | ||
126 | /> | ||
127 | {props.isSubmitted() && props.errors && props.errors.dob && ( | ||
128 | <ErrorLabel> {props.errors.dob} </ErrorLabel> | ||
129 | )} | ||
130 | </FormGroup> | ||
131 | </Col> | ||
132 | </Row> | ||
133 | <Row> | ||
134 | |||
135 | </Row> | ||
136 | </fieldset> | ||
137 | )} | ||
138 | {props.currentStep === 1 && ( | ||
139 | <fieldset title="Academic"> | ||
140 | <legend className="text-semibold">Academic</legend> | ||
141 | <Row> | ||
142 | <Col xs={12} sm={6}> | ||
143 | <FormGroup controlId="rollNo"> | ||
144 | <Label required>Roll No</Label> | ||
145 | <FormControl | ||
146 | type="text" | ||
147 | value={props.getValue('rollNo')} | ||
148 | placeholder="Roll No" | ||
149 | onChange={e => props.setValue('rollNo', e.target.value)} | ||
150 | /> | ||
151 | {props.isSubmitted() && props.errors && props.errors.rollNo && ( | ||
152 | <ErrorLabel> {props.errors.rollNo} </ErrorLabel> | ||
153 | )} | ||
154 | </FormGroup> | ||
155 | </Col> | ||
156 | <Col xs={12} sm={6}> | ||
157 | <FormGroup controlId="class"> | ||
158 | <Label required>Class</Label> | ||
159 | <FormControl | ||
160 | type="text" | ||
161 | value={props.getValue('studentClass')} | ||
162 | placeholder="7" | ||
163 | onChange={e => props.setValue('studentClass', e.target.value)} | ||
164 | /> | ||
165 | {props.isSubmitted() && props.errors && props.errors.studentClass && ( | ||
166 | <ErrorLabel> {props.errors.studentClass} </ErrorLabel> | ||
167 | )} | ||
168 | </FormGroup> | ||
169 | </Col> | ||
170 | </Row> | ||
171 | <Row> | ||
172 | <Col xs={12} sm={6}> | ||
173 | <FormGroup controlId="section"> | ||
174 | <Label required>Section</Label> | ||
175 | <FormControl | ||
176 | type="text" | ||
177 | value={props.getValue('section')} | ||
178 | placeholder="B" | ||
179 | onChange={e => props.setValue('section', e.target.value)} | ||
180 | /> | ||
181 | {props.isSubmitted() && props.errors && props.errors.section && ( | ||
182 | <ErrorLabel> {props.errors.section} </ErrorLabel> | ||
183 | )} | ||
184 | </FormGroup> | ||
185 | </Col> | ||
186 | <Col xs={12} sm={6}> | ||
187 | <FormGroup controlId="community"> | ||
188 | <Label required>Community</Label> | ||
189 | <FormControl | ||
190 | type="text" | ||
191 | value={props.getValue('community')} | ||
192 | placeholder="General" | ||
193 | onChange={e => props.setValue('community', e.target.value)} | ||
194 | /> | ||
195 | {props.isSubmitted() && props.errors && props.errors.community && ( | ||
196 | <ErrorLabel> {props.errors.community} </ErrorLabel> | ||
197 | )} | ||
198 | </FormGroup> | ||
199 | </Col> | ||
200 | </Row> | ||
201 | <Row> | ||
202 | <Col xs={12} sm={6}> | ||
203 | <FormGroup controlId="bloodGroup"> | ||
204 | <Label required>bloodGroup</Label> | ||
205 | <FormControl | ||
206 | type="text" | ||
207 | value={props.getValue('bloodGroup')} | ||
208 | placeholder="B+" | ||
209 | onChange={e => props.setValue('bloodGroup', e.target.value)} | ||
210 | /> | ||
211 | {props.isSubmitted() && props.errors && props.errors.bloodGroup && ( | ||
212 | <ErrorLabel> {props.errors.bloodGroup} </ErrorLabel> | ||
213 | )} | ||
214 | </FormGroup> | ||
215 | </Col> | ||
216 | <Col xs={12} sm={6}> | ||
217 | <FormGroup controlId="phone"> | ||
218 | <Label required>Phone</Label> | ||
219 | <FormControl | ||
220 | type="text" | ||
221 | value={props.getValue('phone')} | ||
222 | placeholder="9999999999" | ||
223 | onChange={e => props.setValue('phone', e.target.value)} | ||
224 | /> | ||
225 | {props.isSubmitted() && props.errors && props.errors.phone && ( | ||
226 | <ErrorLabel> {props.errors.phone} </ErrorLabel> | ||
227 | )} | ||
228 | </FormGroup> | ||
229 | </Col> | ||
230 | </Row> | ||
231 | </fieldset> | ||
232 | )} | ||
233 | {props.currentStep === 2 && ( | ||
234 | <fieldset title="Address"> | ||
235 | <legend className="text-semibold">Address</legend> | ||
236 | <Row> | ||
237 | <Col xs={12} sm={6}> | ||
238 | <FormGroup controlId="address"> | ||
239 | <Label required>Address</Label> | ||
240 | <FormControl | ||
241 | type="text" | ||
242 | value={props.getValue('address')} | ||
243 | placeholder="#876, Street, town" | ||
244 | onChange={e => props.setValue('address', e.target.value)} | ||
245 | /> | ||
246 | {props.isSubmitted() && props.errors && props.errors.address && ( | ||
247 | <ErrorLabel> {props.errors.address} </ErrorLabel> | ||
248 | )} | ||
249 | </FormGroup> | ||
250 | </Col> | ||
251 | <Col xs={12} sm={6}> | ||
252 | <FormGroup controlId="city"> | ||
253 | <Label required>City</Label> | ||
254 | <FormControl | ||
255 | type="text" | ||
256 | value={props.getValue('city')} | ||
257 | placeholder="Chennai" | ||
258 | onChange={e => props.setValue('city', e.target.value)} | ||
259 | /> | ||
260 | {props.isSubmitted() && props.errors && props.errors.city && ( | ||
261 | <ErrorLabel> {props.errors.city} </ErrorLabel> | ||
262 | )} | ||
263 | </FormGroup> | ||
264 | </Col> | ||
265 | </Row> | ||
266 | <Row> | ||
267 | <Col xs={12} sm={6}> | ||
268 | <FormGroup controlId="state"> | ||
269 | <Label required>State</Label> | ||
270 | <FormControl | ||
271 | type="text" | ||
272 | value={props.getValue('state')} | ||
273 | placeholder="Tamilnadu" | ||
274 | onChange={e => props.setValue('state', e.target.value)} | ||
275 | /> | ||
276 | {props.isSubmitted() && props.errors && props.errors.state && ( | ||
277 | <ErrorLabel> {props.errors.state} </ErrorLabel> | ||
278 | )} | ||
279 | </FormGroup> | ||
280 | </Col> | ||
281 | </Row> | ||
282 | </fieldset> | ||
283 | )} | ||
284 | {props.currentStep === 3 && ( | ||
285 | <fieldset title="2"> | ||
286 | <legend className="text-semibold">Parent information</legend> | ||
287 | <Row> | ||
288 | <Col xs={12} sm={6}> | ||
289 | <FormGroup controlId="parentName"> | ||
290 | <Label required>Parent Name</Label> | ||
291 | <FormControl | ||
292 | type="text" | ||
293 | value={props.getValue('parentName')} | ||
294 | placeholder="John" | ||
295 | onChange={e => props.setValue('parentName', e.target.value)} | ||
296 | /> | ||
297 | {props.isSubmitted() && props.errors && props.errors.parentName && ( | ||
298 | <ErrorLabel> {props.errors.parentName} </ErrorLabel> | ||
299 | )} | ||
300 | </FormGroup> | ||
301 | </Col> | ||
302 | <Col xs={12} sm={6}> | ||
303 | <FormGroup controlId="parentEmail"> | ||
304 | <Label required>Parent Email</Label> | ||
305 | <FormControl | ||
306 | type="text" | ||
307 | value={props.getValue('parentEmail')} | ||
308 | placeholder="john@email.com" | ||
309 | onChange={e => props.setValue('parentEmail', e.target.value)} | ||
310 | /> | ||
311 | {props.isSubmitted() && props.errors && props.errors.parentEmail && ( | ||
312 | <ErrorLabel> {props.errors.parentEmail} </ErrorLabel> | ||
313 | )} | ||
314 | </FormGroup> | ||
315 | </Col> | ||
316 | </Row> | ||
317 | <Row> | ||
318 | <Col xs={12} sm={6}> | ||
319 | <FormGroup controlId="relation"> | ||
320 | <Label required>Relation</Label> | ||
321 | <FormControl | ||
322 | type="text" | ||
323 | value={props.getValue('relation')} | ||
324 | placeholder="Father" | ||
325 | onChange={e => props.setValue('relation', e.target.value)} | ||
326 | /> | ||
327 | {props.isSubmitted() && props.errors && props.errors.relation && ( | ||
328 | <ErrorLabel> {props.errors.relation} </ErrorLabel> | ||
329 | )} | ||
330 | </FormGroup> | ||
331 | </Col> | ||
332 | <Col xs={12} sm={6}> | ||
333 | <FormGroup controlId="profession"> | ||
334 | <Label required>Profession</Label> | ||
335 | <FormControl | ||
336 | type="text" | ||
337 | value={props.getValue('profession')} | ||
338 | placeholder="Farmer" | ||
339 | onChange={e => props.setValue('profession', e.target.value)} | ||
340 | /> | ||
341 | {props.isSubmitted() && props.errors && props.errors.profession && ( | ||
342 | <ErrorLabel> {props.errors.profession} </ErrorLabel> | ||
343 | )} | ||
344 | </FormGroup> | ||
345 | </Col> | ||
346 | </Row> | ||
347 | <Row> | ||
348 | <Col xs={12} sm={6}> | ||
349 | <FormGroup controlId="parentGender"> | ||
350 | <Label>Parent Gender</Label> | ||
351 | <FormControl componentClass="select" | ||
352 | placeholder="select" | ||
353 | value={props.getValue('parentGender')} | ||
354 | onChange={e => props.setValue('parentGender', e.target.value)} | ||
355 | > | ||
356 | <option value="male">Male</option> | ||
357 | <option value="female">Female</option> | ||
358 | </FormControl> | ||
359 | {props.isSubmitted() && props.errors && props.errors.parentGender && ( | ||
360 | <ErrorLabel> {props.errors.parentGender} </ErrorLabel> | ||
361 | )} | ||
362 | </FormGroup> | ||
363 | </Col> | ||
364 | <Col xs={12} sm={6}> | ||
365 | <FormGroup controlId="parentPhone"> | ||
366 | <Label required>Parent Phone</Label> | ||
367 | <FormControl | ||
368 | type="text" | ||
369 | value={props.getValue('parentPhone')} | ||
370 | placeholder="9876543210" | ||
371 | onChange={e => props.setValue('parentPhone', e.target.value)} | ||
372 | /> | ||
373 | {props.isSubmitted() && props.errors && props.errors.parentPhone && ( | ||
374 | <ErrorLabel> {props.errors.parentPhone} </ErrorLabel> | ||
375 | )} | ||
376 | </FormGroup> | ||
377 | </Col> | ||
378 | </Row> | ||
379 | <Row> | ||
380 | <Col xs={12} sm={6}> | ||
381 | <FormGroup controlId="parentAddress"> | ||
382 | <Label required>Parent Address</Label> | ||
383 | <FormControl | ||
384 | type="text" | ||
385 | value={props.getValue('parentAddress')} | ||
386 | placeholder="#12, street, town" | ||
387 | onChange={e => props.setValue('parentAddress', e.target.value)} | ||
388 | /> | ||
389 | {props.isSubmitted() && props.errors && props.errors.parentAddress && ( | ||
390 | <ErrorLabel> {props.errors.parentAddress} </ErrorLabel> | ||
391 | )} | ||
392 | </FormGroup> | ||
393 | </Col> | ||
394 | <Col xs={12} sm={6}> | ||
395 | <FormGroup controlId="parentCity"> | ||
396 | <Label required>Parent City</Label> | ||
397 | <FormControl | ||
398 | type="text" | ||
399 | value={props.getValue('parentCity')} | ||
400 | placeholder="Chennai" | ||
401 | onChange={e => props.setValue('parentCity', e.target.value)} | ||
402 | /> | ||
403 | {props.isSubmitted() && props.errors && props.errors.parentCity && ( | ||
404 | <ErrorLabel> {props.errors.parentCity} </ErrorLabel> | ||
405 | )} | ||
406 | </FormGroup> | ||
407 | </Col> | ||
408 | </Row> | ||
409 | <Row> | ||
410 | <Col xs={12} sm={6}> | ||
411 | <FormGroup controlId="parentState"> | ||
412 | <Label required>Parent State</Label> | ||
413 | <FormControl | ||
414 | type="text" | ||
415 | value={props.getValue('parentState')} | ||
416 | placeholder="600031" | ||
417 | onChange={e => props.setValue('parentState', e.target.value)} | ||
418 | /> | ||
419 | {props.isSubmitted() && props.errors && props.errors.parentState && ( | ||
420 | <ErrorLabel> {props.errors.parentState} </ErrorLabel> | ||
421 | )} | ||
422 | </FormGroup> | ||
423 | </Col> | ||
424 | <Col xs={12} sm={6}> | ||
425 | <FormGroup controlId="parentZipcode"> | ||
426 | <Label required>Parent Zipcode</Label> | ||
427 | <FormControl | ||
428 | type="text" | ||
429 | value={props.getValue('parentZipcode')} | ||
430 | placeholder="600031" | ||
431 | onChange={e => props.setValue('parentZipcode', e.target.value)} | ||
432 | /> | ||
433 | {props.isSubmitted() && props.errors && props.errors.parentZipcode && ( | ||
434 | <ErrorLabel> {props.errors.parentZipcode} </ErrorLabel> | ||
435 | )} | ||
436 | </FormGroup> | ||
437 | </Col> | ||
438 | </Row> | ||
439 | </fieldset> | ||
440 | )} | ||
441 | <div style={{ textAlign: 'left' }}> | ||
442 | {props.currentStep > 0 && ( | ||
443 | <div style={{ display: 'inline-block', marginRight: 10 }}> | ||
444 | <Button onClick={props.onBackClick}> | ||
445 | <i className="icon-arrow-left13 position-left"></i> | ||
446 | BACK | ||
447 | </Button> | ||
448 | |||
449 | </div> | ||
450 | )} | ||
451 | {props.currentStep < 3 && ( | ||
452 | <div style={{ display: 'inline-block' }}> | ||
453 | <Button | ||
454 | bsStyle="primary" | ||
455 | onClick={props.onNextClick} | ||
456 | > | ||
457 | NEXT | ||
458 | <i className="icon-arrow-right14 position-right" /> | ||
459 | </Button> | ||
460 | </div> | ||
461 | )} | ||
462 | {props.currentStep === 3 && ( | ||
463 | <div style={{ display: 'inline-block' }}> | ||
464 | <Button | ||
465 | bsStyle="primary" | ||
466 | onClick={props.onNextClick} | ||
467 | > | ||
468 | SAVE | ||
469 | <i className="fa fa-check" /> | ||
470 | </Button> | ||
471 | </div> | ||
472 | )} | ||
473 | </div> | ||
474 | </div> | ||
475 | ) | ||
476 | |||
477 | StudentForm.propTypes = { | ||
478 | currentStep: PropTypes.number.isRequired, | ||
479 | onNextClick: PropTypes.func.isRequired, | ||
480 | onBackClick: PropTypes.func.isRequired, | ||
481 | setValue: PropTypes.func.isRequired, | ||
482 | getValue: PropTypes.func.isRequired, | ||
483 | } | ||
484 | |||
485 | export default StudentForm | ||
486 |
imports/client/views/org/admin/students/add/addStudent.js
File was created | 1 | import _ from 'lodash'; | |
2 | import { Meteor } from 'meteor/meteor'; | ||
3 | import React, { Component } from 'react'; | ||
4 | import { Link,browserHistory } from 'react-router'; | ||
5 | import { FormGroup,Panel,Table, | ||
6 | ButtonToolbar,Modal, | ||
7 | FormControl,Glyphicon,Button } from 'react-bootstrap'; | ||
8 | import { AddStudentFormContainer } from './AddStudentFormContainer'; | ||
9 | |||
10 | const style = { | ||
11 | margin: 12, | ||
12 | }; | ||
13 | export class AddStudent extends Component { | ||
14 | constructor(props) { | ||
15 | super(props); | ||
16 | this.state = { | ||
17 | show: false | ||
18 | }; | ||
19 | this.showModal = this.showModal.bind(this); | ||
20 | this.hideModal = this.hideModal.bind(this); | ||
21 | this.onUpdate = this.onUpdate.bind(this); | ||
22 | }; | ||
23 | |||
24 | showModal() { | ||
25 | this.setState({show: true}); | ||
26 | } | ||
27 | |||
28 | hideModal() { | ||
29 | this.setState({show: false}); | ||
30 | } | ||
31 | onUpdate(key, value) { | ||
32 | this.setState({[key]: value}); | ||
33 | }; | ||
34 | |||
35 | render() { | ||
36 | return ( | ||
37 | <ButtonToolbar> | ||
38 | <Button bsStyle="primary" onClick={this.showModal}> | ||
39 | Add Student | ||
40 | </Button> | ||
41 | <Modal | ||
42 | {...this.props} | ||
43 | show={this.state.show} | ||
44 | onHide={this.hideModal} | ||
45 | dialogClassName="custom-modal" | ||
46 | > | ||
47 | <Modal.Header closeButton> | ||
48 | <Modal.Title id="contained-modal-title-lg">New Student</Modal.Title> | ||
49 | </Modal.Header> | ||
50 | <Modal.Body> | ||
51 | <AddStudentFormContainer /> | ||
52 | </Modal.Body> | ||
53 | {/* | ||
54 | <Modal.Footer> | ||
55 | <Button onClick={this.hideModal}>Close</Button> | ||
56 | </Modal.Footer> | ||
57 | */} | ||
58 | </Modal> | ||
59 | </ButtonToolbar> | ||
60 | ); | ||
61 | }; | ||
62 | |||
63 | }; | ||
64 |
imports/client/views/org/admin/students/add/addStudentForm.js
File was created | 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 { Form, FormGroup,InputGroup, | ||
7 | DropdownButton,MenuItem,ControlLabel, | ||
8 | SplitButton, | ||
9 | FormControl,Glyphicon,Button } from 'react-bootstrap'; | ||
10 | import DatePicker from 'react-bootstrap-date-picker' | ||
11 | import {addStudentManually} from '/imports/collections/students/methods'; | ||
12 | |||
13 | export class AddStudentForm extends Component { | ||
14 | |||
15 | constructor(props) { | ||
16 | super(props); | ||
17 | this.state = { | ||
18 | admissionId: "123", | ||
19 | firstName: "first", | ||
20 | lastName: "last", | ||
21 | middleName: "middle", | ||
22 | email: "deepak125.dk+21@gmail.com", | ||
23 | dob: "", | ||
24 | formattedDob: "", | ||
25 | gender: "male", | ||
26 | rollNo: "1", | ||
27 | class: "2", | ||
28 | section: "B", | ||
29 | community: "SC", | ||
30 | bloodGroup: "B+", | ||
31 | phone: "9876543321", | ||
32 | address: "address", | ||
33 | city: "chennai", | ||
34 | state: "tn", | ||
35 | parentName: "parentName", | ||
36 | parentEmail: "deepak125.dk+41@gmail.com", | ||
37 | relation: "father", | ||
38 | profession: "farmer", | ||
39 | parentGender: "male", | ||
40 | parentPhone: "987655412", | ||
41 | parentAddress: "parentAddress", | ||
42 | parentCity: "parentCity", | ||
43 | parentState: "parentState", | ||
44 | parentZipcode: "parentZipcode", | ||
45 | }; | ||
46 | this.onUpdate = this.onUpdate.bind(this); | ||
47 | this.handleDob = this.handleDob.bind(this); | ||
48 | }; | ||
49 | |||
50 | onUpdate(key, value) { | ||
51 | this.setState({[key]: value}); | ||
52 | }; | ||
53 | |||
54 | handleDob(value, formattedValue) { | ||
55 | this.setState({ | ||
56 | dob: value, // ISO String, ex: "2016-11-19T12:00:00.000Z" | ||
57 | formattedDob: formattedValue // Formatted String, ex: "11/19/2016" | ||
58 | }); | ||
59 | } | ||
60 | addStudent(e){ | ||
61 | e.preventDefault(); | ||
62 | e.persist(); | ||
63 | const firstName = this.state.firstName; | ||
64 | const middleName = this.state.middleName; | ||
65 | const lastName = this.state.lastName; | ||
66 | const admissionId = this.state.admissionId; | ||
67 | const email = this.state.email; | ||
68 | const dob = this.state.dob; | ||
69 | const formattedDob = this.state.formattedDob; | ||
70 | const gender = this.state.gender; | ||
71 | const rollNo = this.state.rollNo; | ||
72 | const studentclass = this.state.class; | ||
73 | const section = this.state.section; | ||
74 | const community = this.state.community; | ||
75 | const bloodGroup = this.state.bloodGroup; | ||
76 | const phone = this.state.phone; | ||
77 | const address = this.state.address; | ||
78 | const city = this.state.city; | ||
79 | const state = this.state.state; | ||
80 | const parentName = this.state.parentName; | ||
81 | const parentEmail = this.state.parentEmail; | ||
82 | const relation = this.state.relation; | ||
83 | const profession = this.state.profession; | ||
84 | const parentGender = this.state.parentGender; | ||
85 | const parentPhone = this.state.parentPhone; | ||
86 | const parentAddress = this.state.parentAddress; | ||
87 | const parentCity = this.state.parentCity; | ||
88 | const parentState = this.state.parentState; | ||
89 | const parentZipcode = this.state.parentZipcode; | ||
90 | if(admissionId==""){ | ||
91 | Bert.alert('Enter Admission Id!', 'danger'); | ||
92 | }else if(firstName==""){ | ||
93 | Bert.alert('Enter Fist Name', 'danger'); | ||
94 | } else if(middleName==""){ | ||
95 | Bert.alert('Enter Middle name!', 'danger'); | ||
96 | }else if(lastName==""){ | ||
97 | Bert.alert('Enter Last name!', 'danger'); | ||
98 | }else if(email==""){ | ||
99 | Bert.alert('Enter email!', 'danger'); | ||
100 | }else if(dob==""){ | ||
101 | Bert.alert('Enter DOB!', 'danger'); | ||
102 | }else if(gender==""){ | ||
103 | Bert.alert('Enter Student Gender!', 'danger'); | ||
104 | }else if(studentclass==""){ | ||
105 | Bert.alert('Enter Class!', 'danger'); | ||
106 | }else if(section==""){ | ||
107 | Bert.alert('Enter Section!', 'danger'); | ||
108 | }else if(community==""){ | ||
109 | Bert.alert('Enter Section!', 'danger'); | ||
110 | }else if(bloodGroup==""){ | ||
111 | Bert.alert('Enter Blood Group!', 'danger'); | ||
112 | }else if(phone==""){ | ||
113 | Bert.alert('Enter phone!', 'danger'); | ||
114 | }else if(address==""){ | ||
115 | Bert.alert('Enter address!', 'danger'); | ||
116 | }else if(city==""){ | ||
117 | Bert.alert('Enter city!', 'danger'); | ||
118 | }else if(state==""){ | ||
119 | Bert.alert('Enter state!', 'danger'); | ||
120 | }else if(parentName==""){ | ||
121 | Bert.alert('Enter Parent name!', 'danger'); | ||
122 | }else if(parentEmail==""){ | ||
123 | Bert.alert('Enter Parent Email!', 'danger'); | ||
124 | }else if(relation==""){ | ||
125 | Bert.alert('Enter relation!', 'danger'); | ||
126 | }else if(profession==""){ | ||
127 | Bert.alert('Enter parent profession!', 'danger'); | ||
128 | }else if(parentGender==""){ | ||
129 | Bert.alert("Enter Parent's Gender!", 'danger'); | ||
130 | }else if(parentPhone==""){ | ||
131 | Bert.alert("Enter Parent's Phone!", 'danger'); | ||
132 | }else if(parentAddress==""){ | ||
133 | Bert.alert("Enter Parent's Address!", 'danger'); | ||
134 | }else if(parentCity==""){ | ||
135 | Bert.alert("Enter Parent's City!", 'danger'); | ||
136 | }else if(parentState==""){ | ||
137 | Bert.alert("Enter Parent's State!", 'danger'); | ||
138 | }else if(parentZipcode==""){ | ||
139 | Bert.alert("Enter Parent's zipcode!", 'danger'); | ||
140 | }else{ | ||
141 | addStudentManually.call({ | ||
142 | admissionId, | ||
143 | firstName, | ||
144 | middleName, | ||
145 | lastName, | ||
146 | email, | ||
147 | dob, | ||
148 | formattedDob, | ||
149 | gender, | ||
150 | rollNo, | ||
151 | studentclass, | ||
152 | section, | ||
153 | community, | ||
154 | bloodGroup, | ||
155 | phone, | ||
156 | address, | ||
157 | city, | ||
158 | state, | ||
159 | parentName, | ||
160 | parentEmail, | ||
161 | relation, | ||
162 | profession, | ||
163 | parentGender, | ||
164 | parentPhone, | ||
165 | parentAddress, | ||
166 | parentCity, | ||
167 | parentState, | ||
168 | parentZipcode | ||
169 | }, function (error, result) { | ||
170 | console.log(error); | ||
171 | console.log(result); | ||
172 | }); | ||
173 | } | ||
174 | } | ||
175 | render() { | ||
176 | return ( | ||
177 | <Form className="steps-validation wizard clearfix" onSubmit={ (e) => this.addStudent(e) } inline> | ||
178 | <div className="steps clearfix"> | ||
179 | <ul role="tablist"> | ||
180 | <li role="tab" className="first current" aria-disabled="false" aria-selected="true"> | ||
181 | <a id="steps-uid-4-t-0" href="#steps-uid-4-h-0" aria-controls="steps-uid-4-p-0"> | ||
182 | <span className="current-info audible">current step: </span><span className="number">1</span> Personal data | ||
183 | </a> | ||
184 | </li> | ||
185 | <li role="tab" className="disabled" aria-disabled="true"> | ||
186 | <a id="steps-uid-4-t-1" href="#steps-uid-4-h-1" aria-controls="steps-uid-4-p-1"> | ||
187 | <span className="number">2</span> Your education\n\ | ||
188 | </a> | ||
189 | </li> | ||
190 | <li role="tab" className="disabled" aria-disabled="true"> | ||
191 | <a id="steps-uid-4-t-2" href="#steps-uid-4-h-2" aria-controls="steps-uid-4-p-2"> | ||
192 | <span className="number">3</span> Your experience | ||
193 | </a> | ||
194 | </li> | ||
195 | <li role="tab" className="disabled last" aria-disabled="true"> | ||
196 | <a id="steps-uid-4-t-3" href="#steps-uid-4-h-3" aria-controls="steps-uid-4-p-3"> | ||
197 | <span className="number">4</span> Additional info | ||
198 | </a> | ||
199 | </li> | ||
200 | </ul> | ||
201 | </div> | ||
202 | <div className="content clearfix"> | ||
203 | <h6 id="steps-uid-4-h-0" tabindex="-1" className="title current">Personal data</h6> | ||
204 | <div id="steps-uid-4-p-0" role="tabpanel" aria-labelledby="steps-uid-4-h-0" className="body current"> | ||
205 | <div className="row"> | ||
206 | <div className="col-md-6"> | ||
207 | |||
208 | <FormGroup controlId="admissionId"> | ||
209 | <ControlLabel>Admission Id</ControlLabel> | ||
210 | <FormControl | ||
211 | type="text" | ||
212 | value={this.state.admissionId} | ||
213 | placeholder="admission Id" | ||
214 | onChange={e=>this.onUpdate('admissionId',e.target.value)} | ||
215 | /> | ||
216 | </FormGroup> | ||
217 | |||
218 | </div> | ||
219 | |||
220 | <div className="col-md-6"> | ||
221 | |||
222 | <FormGroup controlId="firstName"> | ||
223 | <ControlLabel>First Name</ControlLabel> | ||
224 | <FormControl | ||
225 | type="text" | ||
226 | value={this.state.firstName} | ||
227 | placeholder="First Name" | ||
228 | onChange={e=>this.onUpdate('firstName',e.target.value)} | ||
229 | /> | ||
230 | </FormGroup> | ||
231 | |||
232 | </div> | ||
233 | </div> | ||
234 | </div> | ||
235 | </div> | ||
236 | |||
237 | |||
238 | <FormGroup controlId="admissionId"> | ||
239 | <ControlLabel>Admission Id</ControlLabel> | ||
240 | <FormControl | ||
241 | type="text" | ||
242 | value={this.state.admissionId} | ||
243 | placeholder="admission Id" | ||
244 | onChange={e=>this.onUpdate('admissionId',e.target.value)} | ||
245 | /> | ||
246 | </FormGroup> | ||
247 | |||
248 | <FormGroup controlId="firstName"> | ||
249 | <ControlLabel>First Name</ControlLabel> | ||
250 | <FormControl | ||
251 | type="text" | ||
252 | value={this.state.firstName} | ||
253 | placeholder="First Name" | ||
254 | onChange={e=>this.onUpdate('firstName',e.target.value)} | ||
255 | /> | ||
256 | </FormGroup> | ||
257 | <FormGroup controlId="middleName"> | ||
258 | <ControlLabel>Middle Name</ControlLabel> | ||
259 | <FormControl | ||
260 | type="text" | ||
261 | value={this.state.middleName} | ||
262 | placeholder="Middle Name" | ||
263 | onChange={e=>this.onUpdate('middleName',e.target.value)} | ||
264 | /> | ||
265 | </FormGroup> | ||
266 | |||
267 | <FormGroup controlId="lastName"> | ||
268 | <ControlLabel>Last Name</ControlLabel> | ||
269 | <FormControl | ||
270 | type="text" | ||
271 | value={this.state.lastName} | ||
272 | placeholder="Last Name" | ||
273 | onChange={e=>this.onUpdate('lastName',e.target.value)} | ||
274 | /> | ||
275 | |||
276 | </FormGroup> | ||
277 | <FormGroup controlId="email"> | ||
278 | <ControlLabel>Email</ControlLabel> | ||
279 | <FormControl | ||
280 | type="email" | ||
281 | value={this.state.email} | ||
282 | placeholder="Email" | ||
283 | onChange={e=>this.onUpdate('email',e.target.value)} | ||
284 | /> | ||
285 | </FormGroup> | ||
286 | <FormGroup> | ||
287 | <ControlLabel>Date of birth</ControlLabel> | ||
288 | <DatePicker id="dob" | ||
289 | value={this.state.dob} | ||
290 | onChange={this.handleDob} | ||
291 | /> | ||
292 | </FormGroup> | ||
293 | |||
294 | <FormGroup controlId="formControlsSelect"> | ||
295 | <ControlLabel>Gender</ControlLabel> | ||
296 | <FormControl componentClass="select" | ||
297 | placeholder="select" | ||
298 | value={this.state.gender} | ||
299 | onChange={e=>this.onUpdate('gender',e.target.value)} | ||
300 | > | ||
301 | <option value="male">Male</option> | ||
302 | <option value="female">Female</option> | ||
303 | </FormControl> | ||
304 | </FormGroup> | ||
305 | |||
306 | <FormGroup controlId="rollNo"> | ||
307 | <ControlLabel>Roll No</ControlLabel> | ||
308 | <FormControl | ||
309 | type="text" | ||
310 | value={this.state.rollNo} | ||
311 | placeholder="Roll No" | ||
312 | onChange={e=>this.onUpdate('rollNo',e.target.value)} | ||
313 | /> | ||
314 | </FormGroup> | ||
315 | <FormGroup controlId="class"> | ||
316 | <ControlLabel>Class</ControlLabel> | ||
317 | <FormControl | ||
318 | type="text" | ||
319 | value={this.state.class} | ||
320 | placeholder="7" | ||
321 | onChange={e=>this.onUpdate('class',e.target.value)} | ||
322 | /> | ||
323 | </FormGroup> | ||
324 | <FormGroup controlId="section"> | ||
325 | <ControlLabel>Section</ControlLabel> | ||
326 | <FormControl | ||
327 | type="text" | ||
328 | value={this.state.section} | ||
329 | placeholder="B" | ||
330 | onChange={e=>this.onUpdate('section',e.target.value)} | ||
331 | /> | ||
332 | </FormGroup> | ||
333 | |||
334 | <FormGroup controlId="community"> | ||
335 | <ControlLabel>Community</ControlLabel> | ||
336 | <FormControl | ||
337 | type="text" | ||
338 | value={this.state.community} | ||
339 | placeholder="General" | ||
340 | onChange={e=>this.onUpdate('community',e.target.value)} | ||
341 | /> | ||
342 | </FormGroup> | ||
343 | |||
344 | <FormGroup controlId="bloodGroup"> | ||
345 | <ControlLabel>bloodGroup</ControlLabel> | ||
346 | <FormControl | ||
347 | type="text" | ||
348 | value={this.state.bloodGroup} | ||
349 | placeholder="B+" | ||
350 | onChange={e=>this.onUpdate('bloodGroup',e.target.value)} | ||
351 | /> | ||
352 | </FormGroup> | ||
353 | |||
354 | <FormGroup controlId="phone"> | ||
355 | <ControlLabel>Phone</ControlLabel> | ||
356 | <FormControl | ||
357 | type="text" | ||
358 | value={this.state.phone} | ||
359 | placeholder="9999999999" | ||
360 | onChange={e=>this.onUpdate('phone',e.target.value)} | ||
361 | /> | ||
362 | </FormGroup> | ||
363 | |||
364 | <FormGroup controlId="address"> | ||
365 | <ControlLabel>Address</ControlLabel> | ||
366 | <FormControl | ||
367 | type="text" | ||
368 | value={this.state.address} | ||
369 | placeholder="#876, Street, town" | ||
370 | onChange={e=>this.onUpdate('address',e.target.value)} | ||
371 | /> | ||
372 | </FormGroup> | ||
373 | |||
374 | <FormGroup controlId="city"> | ||
375 | <ControlLabel>City</ControlLabel> | ||
376 | <FormControl | ||
377 | type="text" | ||
378 | value={this.state.city} | ||
379 | placeholder="Chennai" | ||
380 | onChange={e=>this.onUpdate('city',e.target.value)} | ||
381 | /> | ||
382 | </FormGroup> | ||
383 | |||
384 | <FormGroup controlId="state"> | ||
385 | <ControlLabel>State</ControlLabel> | ||
386 | <FormControl | ||
387 | type="text" | ||
388 | value={this.state.state} | ||
389 | placeholder="Tamilnadu" | ||
390 | onChange={e=>this.onUpdate('state',e.target.value)} | ||
391 | /> | ||
392 | </FormGroup> | ||
393 | |||
394 | <FormGroup controlId="parentName"> | ||
395 | <ControlLabel>Parent Name</ControlLabel> | ||
396 | <FormControl | ||
397 | type="text" | ||
398 | value={this.state.parentName} | ||
399 | placeholder="John" | ||
400 | onChange={e=>this.onUpdate('parentName',e.target.value)} | ||
401 | /> | ||
402 | </FormGroup> | ||
403 | |||
404 | <FormGroup controlId="parentEmail"> | ||
405 | <ControlLabel>Parent Email</ControlLabel> | ||
406 | <FormControl | ||
407 | type="text" | ||
408 | value={this.state.parentEmail} | ||
409 | placeholder="john@email.com" | ||
410 | onChange={e=>this.onUpdate('parentEmail',e.target.value)} | ||
411 | /> | ||
412 | </FormGroup> | ||
413 | |||
414 | <FormGroup controlId="relation"> | ||
415 | <ControlLabel>Relation</ControlLabel> | ||
416 | <FormControl | ||
417 | type="text" | ||
418 | value={this.state.relation} | ||
419 | placeholder="Father" | ||
420 | onChange={e=>this.onUpdate('relation',e.target.value)} | ||
421 | /> | ||
422 | </FormGroup> | ||
423 | |||
424 | <FormGroup controlId="profession"> | ||
425 | <ControlLabel>Profession</ControlLabel> | ||
426 | <FormControl | ||
427 | type="text" | ||
428 | value={this.state.profession} | ||
429 | placeholder="Farmer" | ||
430 | onChange={e=>this.onUpdate('profession',e.target.value)} | ||
431 | /> | ||
432 | </FormGroup> | ||
433 | |||
434 | <FormGroup controlId="parentGender"> | ||
435 | <ControlLabel>Parent Gender</ControlLabel> | ||
436 | <FormControl componentClass="select" | ||
437 | placeholder="select" | ||
438 | value={this.state.parentGender} | ||
439 | onChange={e=>this.onUpdate('parentGender',e.target.value)} | ||
440 | > | ||
441 | <option value="male">Male</option> | ||
442 | <option value="female">Female</option> | ||
443 | </FormControl> | ||
444 | </FormGroup> | ||
445 | |||
446 | <FormGroup controlId="parentPhone"> | ||
447 | <ControlLabel>Parent Phone</ControlLabel> | ||
448 | <FormControl | ||
449 | type="text" | ||
450 | value={this.state.parentPhone} | ||
451 | placeholder="9876543210" | ||
452 | onChange={e=>this.onUpdate('parentPhone',e.target.value)} | ||
453 | /> | ||
454 | </FormGroup> | ||
455 | |||
456 | <FormGroup controlId="parentAddress"> | ||
457 | <ControlLabel>Parent Address</ControlLabel> | ||
458 | <FormControl | ||
459 | type="text" | ||
460 | value={this.state.parentAddress} | ||
461 | placeholder="#12, street, town" | ||
462 | onChange={e=>this.onUpdate('parentAddress',e.target.value)} | ||
463 | /> | ||
464 | </FormGroup> | ||
465 | |||
466 | <FormGroup controlId="parentCity"> | ||
467 | <ControlLabel>Parent City</ControlLabel> | ||
468 | <FormControl | ||
469 | type="text" | ||
470 | value={this.state.parentCity} | ||
471 | placeholder="Chennai" | ||
472 | onChange={e=>this.onUpdate('parentCity',e.target.value)} | ||
473 | /> | ||
474 | </FormGroup> | ||
475 | |||
476 | <FormGroup controlId="parentState"> | ||
477 | <ControlLabel>Parent State</ControlLabel> | ||
478 | <FormControl | ||
479 | type="text" | ||
480 | value={this.state.parentState} | ||
481 | placeholder="Tamilnadu" | ||
482 | onChange={e=>this.onUpdate('parentState',e.target.value)} | ||
483 | /> | ||
484 | </FormGroup> | ||
485 | |||
486 | <FormGroup controlId="parentZipcode"> | ||
487 | <ControlLabel>Parent Zipcode</ControlLabel> | ||
488 | <FormControl | ||
489 | type="text" | ||
490 | value={this.state.parentZipcode} | ||
491 | placeholder="600031" | ||
492 | onChange={e=>this.onUpdate('parentZipcode',e.target.value)} | ||
493 | /> | ||
494 | </FormGroup> | ||
495 | <Button type="submit" bsStyle="default">Add Student</Button> | ||
496 | </Form> | ||
497 | ); | ||
498 | }; | ||
499 | |||
500 | }; | ||
501 |
imports/client/views/org/admin/students/addStudent.js
1 | import _ from 'lodash'; | File was deleted | |
2 | import { Meteor } from 'meteor/meteor'; | ||
3 | import './student.css' | ||
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 { AddStudentFormContainer } from './AddStudentFormContainer'; | ||
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 | <ButtonToolbar> | ||
39 | <Button bsStyle="primary" onClick={this.showModal}> | ||
40 | Add Student | ||
41 | </Button> | ||
42 | <Modal | ||
43 | {...this.props} | ||
44 | show={this.state.show} | ||
45 | onHide={this.hideModal} | ||
46 | dialogClassName="custom-modal" | ||
47 | > | ||
48 | <Modal.Header closeButton> | ||
49 | <Modal.Title id="contained-modal-title-lg">New Student</Modal.Title> | ||
50 | </Modal.Header> | ||
51 | <Modal.Body> | ||
52 | <AddStudentFormContainer /> | ||
53 | </Modal.Body> | ||
54 | {/* | ||
55 | <Modal.Footer> | ||
56 | <Button onClick={this.hideModal}>Close</Button> | ||
57 | </Modal.Footer> | ||
58 | */} | ||
59 | </Modal> | ||
60 | </ButtonToolbar> | ||
61 | ); | ||
62 | }; | ||
63 | |||
64 | }; | ||
65 | 1 | import _ from 'lodash'; |
imports/client/views/org/admin/students/addStudentForm.js
1 | import _ from 'lodash'; | File was deleted | |
2 | import { Meteor } from 'meteor/meteor'; | ||
3 | |||
4 | import React, { Component } from 'react'; | ||
5 | import { Link,browserHistory } from 'react-router'; | ||
6 | import { Form, FormGroup,InputGroup, | ||
7 | DropdownButton,MenuItem,ControlLabel, | ||
8 | SplitButton, | ||
9 | FormControl,Glyphicon,Button } from 'react-bootstrap'; | ||
10 | import DatePicker from 'react-bootstrap-date-picker' | ||
11 | import {addStudentManually} from '/imports/collections/students/methods'; | ||
12 | |||
13 | export class AddStudentForm extends Component { | ||
14 | |||
15 | constructor(props) { | ||
16 | super(props); | ||
17 | this.state = { | ||
18 | admissionId: "123", | ||
19 | firstName: "first", | ||
20 | lastName: "last", | ||
21 | middleName: "middle", | ||
22 | email: "deepak125.dk+21@gmail.com", | ||
23 | dob: "", | ||
24 | formattedDob: "", | ||
25 | gender: "male", | ||
26 | rollNo: "1", | ||
27 | class: "2", | ||
28 | section: "B", | ||
29 | community: "SC", | ||
30 | bloodGroup: "B+", | ||
31 | phone: "9876543321", | ||
32 | address: "address", | ||
33 | city: "chennai", | ||
34 | state: "tn", | ||
35 | parentName: "parentName", | ||
36 | parentEmail: "deepak125.dk+41@gmail.com", | ||
37 | relation: "father", | ||
38 | profession: "farmer", | ||
39 | parentGender: "male", | ||
40 | parentPhone: "987655412", | ||
41 | parentAddress: "parentAddress", | ||
42 | parentCity: "parentCity", | ||
43 | parentState: "parentState", | ||
44 | parentZipcode: "parentZipcode", | ||
45 | }; | ||
46 | this.onUpdate = this.onUpdate.bind(this); | ||
47 | this.handleDob = this.handleDob.bind(this); | ||
48 | }; | ||
49 | |||
50 | onUpdate(key, value) { | ||
51 | this.setState({[key]: value}); | ||
52 | }; | ||
53 | |||
54 | handleDob(value, formattedValue) { | ||
55 | this.setState({ | ||
56 | dob: value, // ISO String, ex: "2016-11-19T12:00:00.000Z" | ||
57 | formattedDob: formattedValue // Formatted String, ex: "11/19/2016" | ||
58 | }); | ||
59 | } | ||
60 | addStudent(e){ | ||
61 | e.preventDefault(); | ||
62 | e.persist(); | ||
63 | const firstName = this.state.firstName; | ||
64 | const middleName = this.state.middleName; | ||
65 | const lastName = this.state.lastName; | ||
66 | const admissionId = this.state.admissionId; | ||
67 | const email = this.state.email; | ||
68 | const dob = this.state.dob; | ||
69 | const formattedDob = this.state.formattedDob; | ||
70 | const gender = this.state.gender; | ||
71 | const rollNo = this.state.rollNo; | ||
72 | const studentclass = this.state.class; | ||
73 | const section = this.state.section; | ||
74 | const community = this.state.community; | ||
75 | const bloodGroup = this.state.bloodGroup; | ||
76 | const phone = this.state.phone; | ||
77 | const address = this.state.address; | ||
78 | const city = this.state.city; | ||
79 | const state = this.state.state; | ||
80 | const parentName = this.state.parentName; | ||
81 | const parentEmail = this.state.parentEmail; | ||
82 | const relation = this.state.relation; | ||
83 | const profession = this.state.profession; | ||
84 | const parentGender = this.state.parentGender; | ||
85 | const parentPhone = this.state.parentPhone; | ||
86 | const parentAddress = this.state.parentAddress; | ||
87 | const parentCity = this.state.parentCity; | ||
88 | const parentState = this.state.parentState; | ||
89 | const parentZipcode = this.state.parentZipcode; | ||
90 | if(admissionId==""){ | ||
91 | Bert.alert('Enter Admission Id!', 'danger'); | ||
92 | }else if(firstName==""){ | ||
93 | Bert.alert('Enter Fist Name', 'danger'); | ||
94 | } else if(middleName==""){ | ||
95 | Bert.alert('Enter Middle name!', 'danger'); | ||
96 | }else if(lastName==""){ | ||
97 | Bert.alert('Enter Last name!', 'danger'); | ||
98 | }else if(email==""){ | ||
99 | Bert.alert('Enter email!', 'danger'); | ||
100 | }else if(dob==""){ | ||
101 | Bert.alert('Enter DOB!', 'danger'); | ||
102 | }else if(gender==""){ | ||
103 | Bert.alert('Enter Student Gender!', 'danger'); | ||
104 | }else if(studentclass==""){ | ||
105 | Bert.alert('Enter Class!', 'danger'); | ||
106 | }else if(section==""){ | ||
107 | Bert.alert('Enter Section!', 'danger'); | ||
108 | }else if(community==""){ | ||
109 | Bert.alert('Enter Section!', 'danger'); | ||
110 | }else if(bloodGroup==""){ | ||
111 | Bert.alert('Enter Blood Group!', 'danger'); | ||
112 | }else if(phone==""){ | ||
113 | Bert.alert('Enter phone!', 'danger'); | ||
114 | }else if(address==""){ | ||
115 | Bert.alert('Enter address!', 'danger'); | ||
116 | }else if(city==""){ | ||
117 | Bert.alert('Enter city!', 'danger'); | ||
118 | }else if(state==""){ | ||
119 | Bert.alert('Enter state!', 'danger'); | ||
120 | }else if(parentName==""){ | ||
121 | Bert.alert('Enter Parent name!', 'danger'); | ||
122 | }else if(parentEmail==""){ | ||
123 | Bert.alert('Enter Parent Email!', 'danger'); | ||
124 | }else if(relation==""){ | ||
125 | Bert.alert('Enter relation!', 'danger'); | ||
126 | }else if(profession==""){ | ||
127 | Bert.alert('Enter parent profession!', 'danger'); | ||
128 | }else if(parentGender==""){ | ||
129 | Bert.alert("Enter Parent's Gender!", 'danger'); | ||
130 | }else if(parentPhone==""){ | ||
131 | Bert.alert("Enter Parent's Phone!", 'danger'); | ||
132 | }else if(parentAddress==""){ | ||
133 | Bert.alert("Enter Parent's Address!", 'danger'); | ||
134 | }else if(parentCity==""){ | ||
135 | Bert.alert("Enter Parent's City!", 'danger'); | ||
136 | }else if(parentState==""){ | ||
137 | Bert.alert("Enter Parent's State!", 'danger'); | ||
138 | }else if(parentZipcode==""){ | ||
139 | Bert.alert("Enter Parent's zipcode!", 'danger'); | ||
140 | }else{ | ||
141 | addStudentManually.call({ | ||
142 | admissionId, | ||
143 | firstName, | ||
144 | middleName, | ||
145 | lastName, | ||
146 | email, | ||
147 | dob, | ||
148 | formattedDob, | ||
149 | gender, | ||
150 | rollNo, | ||
151 | studentclass, | ||
152 | section, | ||
153 | community, | ||
154 | bloodGroup, | ||
155 | phone, | ||
156 | address, | ||
157 | city, | ||
158 | state, | ||
159 | parentName, | ||
160 | parentEmail, | ||
161 | relation, | ||
162 | profession, | ||
163 | parentGender, | ||
164 | parentPhone, | ||
165 | parentAddress, | ||
166 | parentCity, | ||
167 | parentState, | ||
168 | parentZipcode | ||
169 | }, function (error, result) { | ||
170 | console.log(error); | ||
171 | console.log(result); | ||
172 | }); | ||
173 | } | ||
174 | } | ||
175 | render() { | ||
176 | return ( | ||
177 | <Form className="steps-validation wizard clearfix" onSubmit={ (e) => this.addStudent(e) } inline> | ||
178 | <div className="steps clearfix"> | ||
179 | <ul role="tablist"> | ||
180 | <li role="tab" className="first current" aria-disabled="false" aria-selected="true"> | ||
181 | <a id="steps-uid-4-t-0" href="#steps-uid-4-h-0" aria-controls="steps-uid-4-p-0"> | ||
182 | <span className="current-info audible">current step: </span><span className="number">1</span> Personal data | ||
183 | </a> | ||
184 | </li> | ||
185 | <li role="tab" className="disabled" aria-disabled="true"> | ||
186 | <a id="steps-uid-4-t-1" href="#steps-uid-4-h-1" aria-controls="steps-uid-4-p-1"> | ||
187 | <span className="number">2</span> Your education\n\ | ||
188 | </a> | ||
189 | </li> | ||
190 | <li role="tab" className="disabled" aria-disabled="true"> | ||
191 | <a id="steps-uid-4-t-2" href="#steps-uid-4-h-2" aria-controls="steps-uid-4-p-2"> | ||
192 | <span className="number">3</span> Your experience | ||
193 | </a> | ||
194 | </li> | ||
195 | <li role="tab" className="disabled last" aria-disabled="true"> | ||
196 | <a id="steps-uid-4-t-3" href="#steps-uid-4-h-3" aria-controls="steps-uid-4-p-3"> | ||
197 | <span className="number">4</span> Additional info | ||
198 | </a> | ||
199 | </li> | ||
200 | </ul> | ||
201 | </div> | ||
202 | <div className="content clearfix"> | ||
203 | <h6 id="steps-uid-4-h-0" tabindex="-1" className="title current">Personal data</h6> | ||
204 | <div id="steps-uid-4-p-0" role="tabpanel" aria-labelledby="steps-uid-4-h-0" className="body current"> | ||
205 | <div className="row"> | ||
206 | <div className="col-md-6"> | ||
207 | |||
208 | <FormGroup controlId="admissionId"> | ||
209 | <ControlLabel>Admission Id</ControlLabel> | ||
210 | <FormControl | ||
211 | type="text" | ||
212 | value={this.state.admissionId} | ||
213 | placeholder="admission Id" | ||
214 | onChange={e=>this.onUpdate('admissionId',e.target.value)} | ||
215 | /> | ||
216 | </FormGroup> | ||
217 | |||
218 | </div> | ||
219 | |||
220 | <div className="col-md-6"> | ||
221 | |||
222 | <FormGroup controlId="firstName"> | ||
223 | <ControlLabel>First Name</ControlLabel> | ||
224 | <FormControl | ||
225 | type="text" | ||
226 | value={this.state.firstName} | ||
227 | placeholder="First Name" | ||
228 | onChange={e=>this.onUpdate('firstName',e.target.value)} | ||
229 | /> | ||
230 | </FormGroup> | ||
231 | |||
232 | </div> | ||
233 | </div> | ||
234 | </div> | ||
235 | </div> | ||
236 | |||
237 | |||
238 | <FormGroup controlId="admissionId"> | ||
239 | <ControlLabel>Admission Id</ControlLabel> | ||
240 | <FormControl | ||
241 | type="text" | ||
242 | value={this.state.admissionId} | ||
243 | placeholder="admission Id" | ||
244 | onChange={e=>this.onUpdate('admissionId',e.target.value)} | ||
245 | /> | ||
246 | </FormGroup> | ||
247 | |||
248 | <FormGroup controlId="firstName"> | ||
249 | <ControlLabel>First Name</ControlLabel> | ||
250 | <FormControl | ||
251 | type="text" | ||
252 | value={this.state.firstName} | ||
253 | placeholder="First Name" | ||
254 | onChange={e=>this.onUpdate('firstName',e.target.value)} | ||
255 | /> | ||
256 | </FormGroup> | ||
257 | <FormGroup controlId="middleName"> | ||
258 | <ControlLabel>Middle Name</ControlLabel> | ||
259 | <FormControl | ||
260 | type="text" | ||
261 | value={this.state.middleName} | ||
262 | placeholder="Middle Name" | ||
263 | onChange={e=>this.onUpdate('middleName',e.target.value)} | ||
264 | /> | ||
265 | </FormGroup> | ||
266 | |||
267 | <FormGroup controlId="lastName"> | ||
268 | <ControlLabel>Last Name</ControlLabel> | ||
269 | <FormControl | ||
270 | type="text" | ||
271 | value={this.state.lastName} | ||
272 | placeholder="Last Name" | ||
273 | onChange={e=>this.onUpdate('lastName',e.target.value)} | ||
274 | /> | ||
275 | |||
276 | </FormGroup> | ||
277 | <FormGroup controlId="email"> | ||
278 | <ControlLabel>Email</ControlLabel> | ||
279 | <FormControl | ||
280 | type="email" | ||
281 | value={this.state.email} | ||
282 | placeholder="Email" | ||
283 | onChange={e=>this.onUpdate('email',e.target.value)} | ||
284 | /> | ||
285 | </FormGroup> | ||
286 | <FormGroup> | ||
287 | <ControlLabel>Date of birth</ControlLabel> | ||
288 | <DatePicker id="dob" | ||
289 | value={this.state.dob} | ||
290 | onChange={this.handleDob} | ||
291 | /> | ||
292 | </FormGroup> | ||
293 | |||
294 | <FormGroup controlId="formControlsSelect"> | ||
295 | <ControlLabel>Gender</ControlLabel> | ||
296 | <FormControl componentClass="select" | ||
297 | placeholder="select" | ||
298 | value={this.state.gender} | ||
299 | onChange={e=>this.onUpdate('gender',e.target.value)} | ||
300 | > | ||
301 | <option value="male">Male</option> | ||
302 | <option value="female">Female</option> | ||
303 | </FormControl> | ||
304 | </FormGroup> | ||
305 | |||
306 | <FormGroup controlId="rollNo"> | ||
307 | <ControlLabel>Roll No</ControlLabel> | ||
308 | <FormControl | ||
309 | type="text" | ||
310 | value={this.state.rollNo} | ||
311 | placeholder="Roll No" | ||
312 | onChange={e=>this.onUpdate('rollNo',e.target.value)} | ||
313 | /> | ||
314 | </FormGroup> | ||
315 | <FormGroup controlId="class"> | ||
316 | <ControlLabel>Class</ControlLabel> | ||
317 | <FormControl | ||
318 | type="text" | ||
319 | value={this.state.class} | ||
320 | placeholder="7" | ||
321 | onChange={e=>this.onUpdate('class',e.target.value)} | ||
322 | /> | ||
323 | </FormGroup> | ||
324 | <FormGroup controlId="section"> | ||
325 | <ControlLabel>Section</ControlLabel> | ||
326 | <FormControl | ||
327 | type="text" | ||
328 | value={this.state.section} | ||
329 | placeholder="B" | ||
330 | onChange={e=>this.onUpdate('section',e.target.value)} | ||
331 | /> | ||
332 | </FormGroup> | ||
333 | |||
334 | <FormGroup controlId="community"> | ||
335 | <ControlLabel>Community</ControlLabel> | ||
336 | <FormControl | ||
337 | type="text" | ||
338 | value={this.state.community} | ||
339 | placeholder="General" | ||
340 | onChange={e=>this.onUpdate('community',e.target.value)} | ||
341 | /> | ||
342 | </FormGroup> | ||
343 | |||
344 | <FormGroup controlId="bloodGroup"> | ||
345 | <ControlLabel>bloodGroup</ControlLabel> | ||
346 | <FormControl | ||
347 | type="text" | ||
348 | value={this.state.bloodGroup} | ||
349 | placeholder="B+" | ||
350 | onChange={e=>this.onUpdate('bloodGroup',e.target.value)} | ||
351 | /> | ||
352 | </FormGroup> | ||
353 | |||
354 | <FormGroup controlId="phone"> | ||
355 | <ControlLabel>Phone</ControlLabel> | ||
356 | <FormControl | ||
357 | type="text" | ||
358 | value={this.state.phone} | ||
359 | placeholder="9999999999" | ||
360 | onChange={e=>this.onUpdate('phone',e.target.value)} | ||
361 | /> | ||
362 | </FormGroup> | ||
363 | |||
364 | <FormGroup controlId="address"> | ||
365 | <ControlLabel>Address</ControlLabel> | ||
366 | <FormControl | ||
367 | type="text" | ||
368 | value={this.state.address} | ||
369 | placeholder="#876, Street, town" | ||
370 | onChange={e=>this.onUpdate('address',e.target.value)} | ||
371 | /> | ||
372 | </FormGroup> | ||
373 | |||
374 | <FormGroup controlId="city"> | ||
375 | <ControlLabel>City</ControlLabel> | ||
376 | <FormControl | ||
377 | type="text" | ||
378 | value={this.state.city} | ||
379 | placeholder="Chennai" | ||
380 | onChange={e=>this.onUpdate('city',e.target.value)} | ||
381 | /> | ||
382 | </FormGroup> | ||
383 | |||
384 | <FormGroup controlId="state"> | ||
385 | <ControlLabel>State</ControlLabel> | ||
386 | <FormControl | ||
387 | type="text" | ||
388 | value={this.state.state} | ||
389 | placeholder="Tamilnadu" | ||
390 | onChange={e=>this.onUpdate('state',e.target.value)} | ||
391 | /> | ||
392 | </FormGroup> | ||
393 | |||
394 | <FormGroup controlId="parentName"> | ||
395 | <ControlLabel>Parent Name</ControlLabel> | ||
396 | <FormControl | ||
397 | type="text" | ||
398 | value={this.state.parentName} | ||
399 | placeholder="John" | ||
400 | onChange={e=>this.onUpdate('parentName',e.target.value)} | ||
401 | /> | ||
402 | </FormGroup> | ||
403 | |||
404 | <FormGroup controlId="parentEmail"> | ||
405 | <ControlLabel>Parent Email</ControlLabel> | ||
406 | <FormControl | ||
407 | type="text" | ||
408 | value={this.state.parentEmail} | ||
409 | placeholder="john@email.com" | ||
410 | onChange={e=>this.onUpdate('parentEmail',e.target.value)} | ||
411 | /> | ||
412 | </FormGroup> | ||
413 | |||
414 | <FormGroup controlId="relation"> | ||
415 | <ControlLabel>Relation</ControlLabel> | ||
416 | <FormControl | ||
417 | type="text" | ||
418 | value={this.state.relation} | ||
419 | placeholder="Father" | ||
420 | onChange={e=>this.onUpdate('relation',e.target.value)} | ||
421 | /> | ||
422 | </FormGroup> | ||
423 | |||
424 | <FormGroup controlId="profession"> | ||
425 | <ControlLabel>Profession</ControlLabel> | ||
426 | <FormControl | ||
427 | type="text" | ||
428 | value={this.state.profession} | ||
429 | placeholder="Farmer" | ||
430 | onChange={e=>this.onUpdate('profession',e.target.value)} | ||
431 | /> | ||
432 | </FormGroup> | ||
433 | |||
434 | <FormGroup controlId="parentGender"> | ||
435 | <ControlLabel>Parent Gender</ControlLabel> | ||
436 | <FormControl componentClass="select" | ||
437 | placeholder="select" | ||
438 | value={this.state.parentGender} | ||
439 | onChange={e=>this.onUpdate('parentGender',e.target.value)} | ||
440 | > | ||
441 | <option value="male">Male</option> | ||
442 | <option value="female">Female</option> | ||
443 | </FormControl> | ||
444 | </FormGroup> | ||
445 | |||
446 | <FormGroup controlId="parentPhone"> | ||
447 | <ControlLabel>Parent Phone</ControlLabel> | ||
448 | <FormControl | ||
449 | type="text" | ||
450 | value={this.state.parentPhone} | ||
451 | placeholder="9876543210" | ||
452 | onChange={e=>this.onUpdate('parentPhone',e.target.value)} | ||
453 | /> | ||
454 | </FormGroup> | ||
455 | |||
456 | <FormGroup controlId="parentAddress"> | ||
457 | <ControlLabel>Parent Address</ControlLabel> | ||
458 | <FormControl | ||
459 | type="text" | ||
460 | value={this.state.parentAddress} | ||
461 | placeholder="#12, street, town" | ||
462 | onChange={e=>this.onUpdate('parentAddress',e.target.value)} | ||
463 | /> | ||
464 | </FormGroup> | ||
465 | |||
466 | <FormGroup controlId="parentCity"> | ||
467 | <ControlLabel>Parent City</ControlLabel> | ||
468 | <FormControl | ||
469 | type="text" | ||
470 | value={this.state.parentCity} | ||
471 | placeholder="Chennai" | ||
472 | onChange={e=>this.onUpdate('parentCity',e.target.value)} | ||
473 | /> | ||
474 | </FormGroup> | ||
475 | |||
476 | <FormGroup controlId="parentState"> | ||
477 | <ControlLabel>Parent State</ControlLabel> | ||
478 | <FormControl | ||
479 | type="text" | ||
480 | value={this.state.parentState} | ||
481 | placeholder="Tamilnadu" | ||
482 | onChange={e=>this.onUpdate('parentState',e.target.value)} | ||
483 | /> | ||
484 | </FormGroup> | ||
485 | |||
486 | <FormGroup controlId="parentZipcode"> | ||
487 | <ControlLabel>Parent Zipcode</ControlLabel> | ||
488 | <FormControl | ||
489 | type="text" | ||
490 | value={this.state.parentZipcode} | ||
491 | placeholder="600031" | ||
492 | onChange={e=>this.onUpdate('parentZipcode',e.target.value)} | ||
493 | /> | ||
494 | </FormGroup> | ||
495 | <Button type="submit" bsStyle="default">Add Student</Button> | ||
496 | </Form> | ||
497 | ); | ||
498 | }; | ||
499 | |||
500 | }; | ||
501 | 1 | import _ from 'lodash'; |
imports/client/views/org/admin/students/view/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'; | ||
10 | import {moment} from 'meteor/momentjs:moment' | 9 | import {moment} from 'meteor/momentjs:moment' |
11 | import {StudentRow} from './StudentRow' | 10 | import {StudentRow} from './StudentRow' |
12 | 11 | ||
13 | export class StudentTable extends Component { | 12 | export class StudentTable extends Component { |
14 | 13 | ||
15 | constructor(props) { | 14 | constructor(props) { |
16 | super(props); | 15 | super(props); |
17 | this.state = { | 16 | this.state = { |
18 | show: false | 17 | show: false |
19 | }; | 18 | }; |
20 | this.onUpdate = this.onUpdate.bind(this); | 19 | this.onUpdate = this.onUpdate.bind(this); |
21 | }; | 20 | }; |
22 | onUpdate(key, value) { | 21 | onUpdate(key, value) { |
23 | this.setState({[key]: value}); | 22 | this.setState({[key]: value}); |
24 | }; | 23 | }; |
25 | 24 | ||
26 | render() { | 25 | render() { |
27 | return ( | 26 | return ( |
28 | <div className="panel panel-flat"> | 27 | <div className="panel panel-flat"> |
29 | <div className="panel-heading"> | 28 | <div className="panel-heading"> |
30 | <h5 className="panel-title">Student Details</h5> | 29 | <h5 className="panel-title">Student Details</h5> |
31 | <div className="heading-elements"> | 30 | <div className="heading-elements"> |
32 | <ul className="icons-list"> | 31 | <ul className="icons-list"> |
33 | <li><a data-action="collapse"></a></li> | 32 | <li><a data-action="collapse"></a></li> |
34 | <li><a data-action="reload"></a></li> | 33 | <li><a data-action="reload"></a></li> |
35 | </ul> | 34 | </ul> |
36 | </div> | 35 | </div> |
37 | </div> | 36 | </div> |
38 | <Table striped bordered condensed hover> | 37 | <Table striped bordered condensed hover> |
39 | <thead> | 38 | <thead> |
40 | <tr> | 39 | <tr> |
41 | <th>First Name</th> | 40 | <th>First Name</th> |
42 | <th>Last Name</th> | 41 | <th>Last Name</th> |
43 | <th>Class</th> | 42 | <th>Class</th> |
44 | <th>DOB</th> | 43 | <th>DOB</th> |
45 | <th>Status</th> | 44 | <th>Status</th> |
46 | <th className="text-center">Actions</th> | 45 | <th className="text-center">Actions</th> |
47 | </tr> | 46 | </tr> |
48 | </thead> | 47 | </thead> |
49 | <tbody> | 48 | <tbody> |
50 | { | 49 | { |
51 | this.props.students.map(function(student, i) | 50 | this.props.students.map(function(student, i) |
52 | { | 51 | { |
53 | return( | 52 | return( |
54 | <StudentRow | 53 | <StudentRow |
55 | student = {student} | 54 | student = {student} |
56 | /> | 55 | /> |
57 | ) | 56 | ) |
58 | }) | 57 | }) |
59 | } | 58 | } |
60 | </tbody> | 59 | </tbody> |
61 | </Table> | 60 | </Table> |
62 | </div> | 61 | </div> |
63 | ); | 62 | ); |
64 | }; | 63 | }; |
65 | 64 | ||
66 | }; | 65 | }; |
67 | 66 |
imports/client/views/org/admin/teachers/TeacherView.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, | 6 | import { FormGroup, |
7 | FormControl,Glyphicon,Button } from 'react-bootstrap'; | 7 | FormControl,Glyphicon,Button } from 'react-bootstrap'; |
8 | import { Header } from '../Header'; | 8 | import { Header } from '../Header'; |
9 | import { AdminSidebar } from '../Sidebar' | 9 | import { AdminSidebar } from '../Sidebar' |
10 | import { AdminBreadcrumb } from '../Breadcrumb' | 10 | import { AdminBreadcrumb } from '../Breadcrumb' |
11 | import { TeachersTable } from './view/TeachersTable' | 11 | import { TeachersTable } from './view/TeachersTable' |
12 | import { AddTeacher } from './add/addTeacher' | ||
13 | import { UploadCsvTeacher } from './UploadCsvTeacher' | ||
12 | 14 | ||
13 | export class TeachersView extends Component { | 15 | export class TeachersView extends Component { |
14 | constructor(props) { | 16 | constructor(props) { |
15 | super(props); | 17 | super(props); |
16 | this.state = { | 18 | this.state = { |
17 | 19 | ||
18 | }; | 20 | }; |
19 | this.onUpdate = this.onUpdate.bind(this); | 21 | this.onUpdate = this.onUpdate.bind(this); |
20 | }; | 22 | }; |
21 | 23 | ||
22 | onUpdate(key, value) { | 24 | onUpdate(key, value) { |
23 | this.setState({[key]: value}); | 25 | this.setState({[key]: value}); |
24 | }; | 26 | }; |
25 | 27 | ||
26 | render() { | 28 | render() { |
27 | const {user, org} = this.props.data; | 29 | const {user, org, teachers, teachersData} = this.props.data; |
28 | return ( | 30 | return ( |
29 | <div className="appLayout-box"> | 31 | <div className="appLayout-box"> |
30 | <div className="page-container"> | 32 | <div className="page-container"> |
31 | <div className="page-content"> | 33 | <div className="page-content"> |
32 | <AdminSidebar | 34 | <AdminSidebar |
33 | user = {this.props.data.user} | 35 | user = {user} |
34 | org = {this.props.data.org} | 36 | org = {org} |
35 | /> | 37 | /> |
36 | {/*end sidebar*/} | 38 | {/*end sidebar*/} |
37 | <div className="content-wrapper"> | 39 | <div className="content-wrapper"> |
38 | <AdminBreadcrumb /> | 40 | <AdminBreadcrumb /> |
39 | {/*content*/} | 41 | {/*content*/} |
40 | 42 | ||
41 | <div className="content has-detached-left"> | 43 | <div className="content has-detached-left"> |
42 | <div className="container-detached"> | 44 | <div className="container-detached"> |
43 | <div className="content-detached"> | 45 | <div className="content-detached"> |
44 | <Header/> | 46 | <Header |
45 | <TeachersTable | 47 | user = {user} |
48 | org = {org} | ||
49 | /> | ||
50 | <TeachersTable | ||
46 | data = {this.props.data} | 51 | data = {this.props.data} |
47 | teachers = {teachers} | 52 | teachers = {teachers} |
48 | /> | 53 | /> |
49 | { | 54 | <AddTeacher/> |
50 | /** | 55 | <UploadCsvTeacher /> |
51 | <AddTeacher/> | ||
52 | <UploadCsvTeacher /> | ||
53 | */ | ||
54 | } | ||
55 | </div> | 56 | </div> |
56 | </div> | 57 | </div> |
57 | <div className="sidebar-detached affix-top"> | 58 | <div className="sidebar-detached affix-top"> |
58 | <div className="sidebar sidebar-default"> | 59 | <div className="sidebar sidebar-default"> |
59 | <div className="sidebar-content"> | 60 | <div className="sidebar-content"> |
60 | 61 | ||
61 | <div className="sidebar-category"> | 62 | <div className="sidebar-category"> |
62 | <div className="category-title"> | 63 | <div className="category-title"> |
63 | <span>Advanced Search</span> | 64 | <span>Advanced Search</span> |
64 | <ul className="icons-list"> | 65 | <ul className="icons-list"> |
65 | <li><a href="#" data-action="collapse"></a></li> | 66 | <li><a href="#" data-action="collapse"></a></li> |
66 | </ul> | 67 | </ul> |
67 | </div> | 68 | </div> |
68 | 69 | ||
69 | <div className="category-content"> | 70 | <div className="category-content"> |
70 | <form action="#"> | 71 | <form action="#"> |
71 | <div className="has-feedback has-feedback-left"> | 72 | <div className="has-feedback has-feedback-left"> |
72 | <input type="search" className="form-control" | 73 | <input type="search" className="form-control" |
73 | value={this.state.firstNameSearch} | 74 | value={this.state.firstNameSearch} |
74 | onChange={e=>this.onUpdate('firstNameSearch',e.target.value)} | 75 | onChange={e=>this.onUpdate('firstNameSearch',e.target.value)} |
75 | placeholder="First Name" | 76 | placeholder="First Name" |
76 | /> | 77 | /> |
77 | <div className="form-control-feedback"> | 78 | <div className="form-control-feedback"> |
78 | <i className="icon-search4 text-size-base text-muted"></i> | 79 | <i className="icon-search4 text-size-base text-muted"></i> |
79 | </div> | 80 | </div> |
80 | </div> | 81 | </div> |
81 | </form> | 82 | </form> |
82 | </div> | 83 | </div> |
83 | <div className="category-content"> | 84 | <div className="category-content"> |
84 | <form action="#"> | 85 | <form action="#"> |
85 | <div className="has-feedback has-feedback-left"> | 86 | <div className="has-feedback has-feedback-left"> |
86 | <input type="search" className="form-control" | 87 | <input type="search" className="form-control" |
87 | value={this.state.lastNameSearch} | 88 | value={this.state.lastNameSearch} |
88 | onChange={e=>this.onUpdate('lastNameSearch',e.target.value)} | 89 | onChange={e=>this.onUpdate('lastNameSearch',e.target.value)} |
89 | placeholder="Last Name" /> | 90 | placeholder="Last Name" /> |
90 | <div className="form-control-feedback"> | 91 | <div className="form-control-feedback"> |
91 | <i className="icon-search4 text-size-base text-muted"></i> | 92 | <i className="icon-search4 text-size-base text-muted"></i> |
92 | </div> | 93 | </div> |
93 | </div> | 94 | </div> |
94 | </form> | 95 | </form> |
95 | </div> | 96 | </div> |
96 | </div> | 97 | </div> |
97 | </div> | 98 | </div> |
98 | </div> | 99 | </div> |
99 | </div> | 100 | </div> |
100 | </div> | 101 | </div> |
101 | </div> | 102 | </div> |
102 | </div> | 103 | </div> |
103 | </div> | 104 | </div> |
104 | </div> | 105 | </div> |
105 | ); | 106 | ); |
imports/client/views/org/admin/teachers/UploadCsvTeacher.js
File was created | 1 | // import {UploadCsv } from '/imports/collections/students/UploadCsv' | |
2 | import _ from 'lodash'; | ||
3 | import { Meteor } from 'meteor/meteor'; | ||
4 | |||
5 | import React, { Component } from 'react'; | ||
6 | import { Link,browserHistory } from 'react-router'; | ||
7 | import { FormGroup,Panel,Table, | ||
8 | ButtonToolbar,Modal,ControlLabel,HelpBlock, | ||
9 | FormControl,Glyphicon,Button } from 'react-bootstrap'; | ||
10 | // import { AddStudentForm } from './addStudentForm'; | ||
11 | import { FilesCollection } from 'meteor/ostrio:files'; | ||
12 | const Papa = this.Papa; | ||
13 | // console.log(this); | ||
14 | const style = { | ||
15 | margin: 12, | ||
16 | }; | ||
17 | function FieldGroup({ id, label, help, ...props }) { | ||
18 | return ( | ||
19 | <FormGroup controlId={id}> | ||
20 | <ControlLabel>{label}</ControlLabel> | ||
21 | <FormControl {...props} /> | ||
22 | {help && <HelpBlock>{help}</HelpBlock>} | ||
23 | </FormGroup> | ||
24 | ); | ||
25 | } | ||
26 | export class UploadCsvTeacher extends Component { | ||
27 | constructor(props) { | ||
28 | super(props); | ||
29 | this.state = { | ||
30 | show: false | ||
31 | }; | ||
32 | this.showModal = this.showModal.bind(this); | ||
33 | this.hideModal = this.hideModal.bind(this); | ||
34 | this.onUpdate = this.onUpdate.bind(this); | ||
35 | }; | ||
36 | |||
37 | showModal() { | ||
38 | this.setState({show: true}); | ||
39 | } | ||
40 | |||
41 | hideModal() { | ||
42 | this.setState({show: false}); | ||
43 | } | ||
44 | onUpdate(key, value) { | ||
45 | this.setState({[key]: value}); | ||
46 | }; | ||
47 | uploadStudentCsv(e){ | ||
48 | e.preventDefault(); | ||
49 | e.persist(); | ||
50 | var file = $('input[type="file"]').prop("files")[0]; | ||
51 | Papa.parse(file, { | ||
52 | header: true, | ||
53 | complete: function(csvData) { | ||
54 | console.log("csvData"); | ||
55 | console.log(csvData); | ||
56 | if(csvData){ | ||
57 | Meteor.call('teachers.uploadCsv', csvData, function (error, result) { | ||
58 | console.log("error"); | ||
59 | console.log(error); | ||
60 | console.log("result"); | ||
61 | console.log(result); | ||
62 | }) | ||
63 | } | ||
64 | } | ||
65 | }); | ||
66 | } | ||
67 | |||
68 | render() { | ||
69 | console.log(this.props); | ||
70 | return ( | ||
71 | <ButtonToolbar> | ||
72 | <Button bsStyle="primary" onClick={this.showModal}> | ||
73 | Upload CSV | ||
74 | </Button> | ||
75 | <Modal | ||
76 | {...this.props} | ||
77 | show={this.state.show} | ||
78 | onHide={this.hideModal} | ||
79 | dialogClassName="custom-modal" | ||
80 | > | ||
81 | <Modal.Header closeButton> | ||
82 | <Modal.Title id="contained-modal-title-lg">New Student</Modal.Title> | ||
83 | </Modal.Header> | ||
84 | <Modal.Body> | ||
85 | <form onSubmit={ (e) => this.uploadStudentCsv(e) } > | ||
86 | <FieldGroup | ||
87 | id="formControlsFile" | ||
88 | type="file" | ||
89 | label="File" | ||
90 | help="Upload you CSV here." | ||
91 | /> | ||
92 | <Button type="submit" bsStyle="default">Upload File</Button> | ||
93 | </form> | ||
94 | </Modal.Body> | ||
95 | <Modal.Footer> | ||
96 | <Button onClick={this.hideModal}>Close</Button> | ||
97 | </Modal.Footer> | ||
98 | </Modal> | ||
99 | </ButtonToolbar> | ||
100 | ); | ||
101 | }; | ||
102 | |||
103 | }; | ||
104 |
imports/client/views/org/admin/teachers/add/AddStudentFormContainer.js
File was created | 1 | import React, { Component } from 'react' | |
2 | import { AddStudentForm } from './addStudentForm' | ||
3 | import StudentForm from './StudentForm' | ||
4 | import Form from '/imports/client/views/core/Form' | ||
5 | import Validator from '/imports/client/views/core/Validator' | ||
6 | import { isRequired, isValidEmail } from '/imports/client/views/core/validations' | ||
7 | import { addStudentManually } from '/imports/collections/students/methods'; | ||
8 | |||
9 | export class AddStudentFormContainer extends Component { | ||
10 | |||
11 | constructor(props) { | ||
12 | super(props) | ||
13 | this.state = { currentStep: 0 } | ||
14 | this.handleNextClick = this.handleNextClick.bind(this) | ||
15 | this.handleBackClick = this.handleBackClick.bind(this) | ||
16 | this.handleSubmit = this.handleSubmit.bind(this) | ||
17 | } | ||
18 | |||
19 | handleNextClick() { | ||
20 | this.form.handleSubmit() | ||
21 | if (this.validator.getErrors() && Object.keys(this.validator.getErrors()).length > 0) return | ||
22 | this.setState({ currentStep: this.state.currentStep + 1 }) | ||
23 | this.form.resetSubmitted() | ||
24 | } | ||
25 | |||
26 | handleBackClick() { | ||
27 | this.setState({ currentStep: this.state.currentStep + -1 }) | ||
28 | } | ||
29 | |||
30 | handleSubmit() { | ||
31 | if (this.state.currentStep === 3) { | ||
32 | addStudentManually.call(this.form.state.values) | ||
33 | } | ||
34 | } | ||
35 | |||
36 | //render callback | ||
37 | render() { | ||
38 | return ( | ||
39 | <Form | ||
40 | onSubmit={this.handleSubmit} | ||
41 | ref={form => this.form = form} | ||
42 | initialValues={{ | ||
43 | gender: 'male', | ||
44 | parentGender: 'male', | ||
45 | }} | ||
46 | > | ||
47 | {({ values, setValue, getValue, isSubmitted, isDirty }) => ( | ||
48 | <Validator | ||
49 | values={values} | ||
50 | ref={validator => this.validator = validator} | ||
51 | validations={{ | ||
52 | admissionId: [(value) => isRequired('Admission id', value)], | ||
53 | firstName: [(value) => isRequired('First name', value)], | ||
54 | lastName: [(value) => isRequired('Last name', value)], | ||
55 | email: [(value) => isRequired('Email', value), isValidEmail], | ||
56 | dob: [(value) => isRequired('Date of birth', value)], | ||
57 | gender: [(value) => isRequired('Gender', value)], | ||
58 | rollNo: [(value) => this.state.currentStep === 1 && isRequired('Roll no', value)], | ||
59 | studentClass: [(value) => this.state.currentStep === 1 && isRequired('Class', value)], | ||
60 | section: [(value) => this.state.currentStep === 1 && isRequired('Section', value)], | ||
61 | community: [(value) => this.state.currentStep === 1 && isRequired('Community', value)], | ||
62 | bloodGroup: [(value) => this.state.currentStep === 1 && isRequired('Blood group', value)], | ||
63 | phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], | ||
64 | address: [(value) => this.state.currentStep === 2 && isRequired('Address', value)], | ||
65 | city: [(value) => this.state.currentStep === 2 && isRequired('City', value)], | ||
66 | state: [(value) => this.state.currentStep === 2 && isRequired('State', value)], | ||
67 | parentName: [(value) => this.state.currentStep === 3 && isRequired('Parent name', value)], | ||
68 | parentEmail: [(value) => this.state.currentStep === 3 && isRequired('Parent email', value), (value) => this.state.currentStep === 3 && isValidEmail(value)], | ||
69 | relation: [(value) => this.state.currentStep === 3 && isRequired('Relation', value)], | ||
70 | profession: [(value) => this.state.currentStep === 3 && isRequired('Profession', value)], | ||
71 | parentGender: [(value) => this.state.currentStep === 3 && isRequired('Parent gender', value)], | ||
72 | parentPhone: [(value) => this.state.currentStep === 3 && isRequired('Parent phone', value)], | ||
73 | parentAddress: [(value) => this.state.currentStep === 3 && isRequired('Parent address', value)], | ||
74 | parentCity: [(value) => this.state.currentStep === 3 && isRequired('Parent city', value)], | ||
75 | parentState: [(value) => this.state.currentStep === 3 && isRequired('Parent state', value)], | ||
76 | parentZipcode: [(value) => this.state.currentStep === 3 && isRequired('Parent zip code', value)], | ||
77 | }} | ||
78 | > | ||
79 | {({ errors }) => ( | ||
80 | <StudentForm | ||
81 | isDirty={isDirty} | ||
82 | setValue={setValue} | ||
83 | getValue={getValue} | ||
84 | isSubmitted={isSubmitted} | ||
85 | errors={errors} | ||
86 | onNextClick={this.handleNextClick} | ||
87 | onBackClick={this.handleBackClick} | ||
88 | currentStep={this.state.currentStep} | ||
89 | /> | ||
90 | )} | ||
91 | </Validator> | ||
92 | )} | ||
93 | </Form> | ||
94 | ) | ||
95 | } | ||
96 | } | ||
97 |
imports/client/views/org/admin/teachers/add/StudentForm.js
File was created | 1 | import React, { PropTypes } from 'react' | |
2 | import { | ||
3 | Row, | ||
4 | Col, | ||
5 | FormGroup, | ||
6 | FormControl, | ||
7 | Button | ||
8 | } from 'react-bootstrap' | ||
9 | import DatePicker from '/imports/client/views/core/DatePicker' | ||
10 | import Label from '/imports/client/views/core/Label' | ||
11 | import Stepper from '/imports/client/views/core/Stepper' | ||
12 | import ErrorLabel from '/imports/client/views/core/ErrorLabel' | ||
13 | |||
14 | const StudentForm = props => ( | ||
15 | <div className="stepy-validation"> | ||
16 | <Stepper | ||
17 | steps={[ | ||
18 | { | ||
19 | label: 'Personal data', | ||
20 | active: props.currentStep === 0, | ||
21 | }, | ||
22 | { | ||
23 | label: 'Academic', | ||
24 | active: props.currentStep === 1, | ||
25 | }, | ||
26 | { | ||
27 | label: 'Address', | ||
28 | active: props.currentStep === 2, | ||
29 | }, | ||
30 | { | ||
31 | label: 'Parent info', | ||
32 | active: props.currentStep === 3, | ||
33 | } | ||
34 | ]} | ||
35 | /> | ||
36 | {props.currentStep === 0 && ( | ||
37 | <fieldset title="1"> | ||
38 | <legend className="text-semibold">Personal data</legend> | ||
39 | <Row> | ||
40 | <Col xs={12} sm={6}> | ||
41 | <FormGroup controlId="admissionId"> | ||
42 | <Label required>Admission Id</Label> | ||
43 | <FormControl | ||
44 | type="text" | ||
45 | value={props.getValue('admissionId')} | ||
46 | placeholder="admission Id" | ||
47 | onChange={e => props.setValue('admissionId', e.target.value)} | ||
48 | /> | ||
49 | {props.isSubmitted() && props.errors && props.errors.admissionId && ( | ||
50 | <ErrorLabel> {props.errors.admissionId} </ErrorLabel> | ||
51 | )} | ||
52 | </FormGroup> | ||
53 | </Col> | ||
54 | <Col xs={12} sm={6}> | ||
55 | <FormGroup controlId="firstName"> | ||
56 | <Label required>First Name</Label> | ||
57 | <FormControl | ||
58 | type="text" | ||
59 | value={props.getValue('firstName')} | ||
60 | placeholder="First Name" | ||
61 | onChange={e => props.setValue('firstName', e.target.value)} | ||
62 | /> | ||
63 | {props.isSubmitted() && props.errors && props.errors.firstName && ( | ||
64 | <ErrorLabel> {props.errors.firstName} </ErrorLabel> | ||
65 | )} | ||
66 | </FormGroup> | ||
67 | </Col> | ||
68 | </Row> | ||
69 | <Row> | ||
70 | <Col xs={12} sm={6}> | ||
71 | <FormGroup controlId="lastName"> | ||
72 | <Label required>Last Name</Label> | ||
73 | <FormControl | ||
74 | type="text" | ||
75 | value={props.getValue('lastName')} | ||
76 | placeholder="Last Name" | ||
77 | onChange={e => props.setValue('lastName', e.target.value)} | ||
78 | /> | ||
79 | {props.isSubmitted() && props.errors && props.errors.lastName && ( | ||
80 | <ErrorLabel> {props.errors.lastName} </ErrorLabel> | ||
81 | )} | ||
82 | </FormGroup> | ||
83 | </Col> | ||
84 | <Col xs={12} sm={6}> | ||
85 | <FormGroup controlId="formControlsSelect"> | ||
86 | <Label>Gender</Label> | ||
87 | <FormControl componentClass="select" | ||
88 | placeholder="select" | ||
89 | value={props.getValue('gender')} | ||
90 | onChange={e => props.setValue('gender', e.target.value)} | ||
91 | > | ||
92 | <option value="male">Male</option> | ||
93 | <option value="female">Female</option> | ||
94 | </FormControl> | ||
95 | {props.isSubmitted() && props.errors && props.errors.gender && ( | ||
96 | <ErrorLabel> {props.errors.gender} </ErrorLabel> | ||
97 | )} | ||
98 | </FormGroup> | ||
99 | </Col> | ||
100 | </Row> | ||
101 | <Row> | ||
102 | <Col xs={12} sm={6}> | ||
103 | <FormGroup controlId="email"> | ||
104 | <Label required>Email</Label> | ||
105 | <FormControl | ||
106 | type="email" | ||
107 | value={props.getValue('email')} | ||
108 | placeholder="Email" | ||
109 | onChange={e => props.setValue('email', e.target.value)} | ||
110 | /> | ||
111 | {props.isSubmitted() && props.errors && props.errors.email && ( | ||
112 | <ErrorLabel> {props.errors.email} </ErrorLabel> | ||
113 | )} | ||
114 | </FormGroup> | ||
115 | </Col> | ||
116 | <Col xs={12} sm={6}> | ||
117 | <FormGroup> | ||
118 | <Label required>Date of birth</Label> | ||
119 | <DatePicker | ||
120 | id="dob" | ||
121 | setValue = {props.setValue} | ||
122 | value={props.getValue('dob')} | ||
123 | onChange={(e) => { | ||
124 | props.setValue('dob', e.target.value) | ||
125 | }} | ||
126 | /> | ||
127 | {props.isSubmitted() && props.errors && props.errors.dob && ( | ||
128 | <ErrorLabel> {props.errors.dob} </ErrorLabel> | ||
129 | )} | ||
130 | </FormGroup> | ||
131 | </Col> | ||
132 | </Row> | ||
133 | <Row> | ||
134 | |||
135 | </Row> | ||
136 | </fieldset> | ||
137 | )} | ||
138 | {props.currentStep === 1 && ( | ||
139 | <fieldset title="Academic"> | ||
140 | <legend className="text-semibold">Academic</legend> | ||
141 | <Row> | ||
142 | <Col xs={12} sm={6}> | ||
143 | <FormGroup controlId="rollNo"> | ||
144 | <Label required>Roll No</Label> | ||
145 | <FormControl | ||
146 | type="text" | ||
147 | value={props.getValue('rollNo')} | ||
148 | placeholder="Roll No" | ||
149 | onChange={e => props.setValue('rollNo', e.target.value)} | ||
150 | /> | ||
151 | {props.isSubmitted() && props.errors && props.errors.rollNo && ( | ||
152 | <ErrorLabel> {props.errors.rollNo} </ErrorLabel> | ||
153 | )} | ||
154 | </FormGroup> | ||
155 | </Col> | ||
156 | <Col xs={12} sm={6}> | ||
157 | <FormGroup controlId="class"> | ||
158 | <Label required>Class</Label> | ||
159 | <FormControl | ||
160 | type="text" | ||
161 | value={props.getValue('studentClass')} | ||
162 | placeholder="7" | ||
163 | onChange={e => props.setValue('studentClass', e.target.value)} | ||
164 | /> | ||
165 | {props.isSubmitted() && props.errors && props.errors.studentClass && ( | ||
166 | <ErrorLabel> {props.errors.studentClass} </ErrorLabel> | ||
167 | )} | ||
168 | </FormGroup> | ||
169 | </Col> | ||
170 | </Row> | ||
171 | <Row> | ||
172 | <Col xs={12} sm={6}> | ||
173 | <FormGroup controlId="section"> | ||
174 | <Label required>Section</Label> | ||
175 | <FormControl | ||
176 | type="text" | ||
177 | value={props.getValue('section')} | ||
178 | placeholder="B" | ||
179 | onChange={e => props.setValue('section', e.target.value)} | ||
180 | /> | ||
181 | {props.isSubmitted() && props.errors && props.errors.section && ( | ||
182 | <ErrorLabel> {props.errors.section} </ErrorLabel> | ||
183 | )} | ||
184 | </FormGroup> | ||
185 | </Col> | ||
186 | <Col xs={12} sm={6}> | ||
187 | <FormGroup controlId="community"> | ||
188 | <Label required>Community</Label> | ||
189 | <FormControl | ||
190 | type="text" | ||
191 | value={props.getValue('community')} | ||
192 | placeholder="General" | ||
193 | onChange={e => props.setValue('community', e.target.value)} | ||
194 | /> | ||
195 | {props.isSubmitted() && props.errors && props.errors.community && ( | ||
196 | <ErrorLabel> {props.errors.community} </ErrorLabel> | ||
197 | )} | ||
198 | </FormGroup> | ||
199 | </Col> | ||
200 | </Row> | ||
201 | <Row> | ||
202 | <Col xs={12} sm={6}> | ||
203 | <FormGroup controlId="bloodGroup"> | ||
204 | <Label required>bloodGroup</Label> | ||
205 | <FormControl | ||
206 | type="text" | ||
207 | value={props.getValue('bloodGroup')} | ||
208 | placeholder="B+" | ||
209 | onChange={e => props.setValue('bloodGroup', e.target.value)} | ||
210 | /> | ||
211 | {props.isSubmitted() && props.errors && props.errors.bloodGroup && ( | ||
212 | <ErrorLabel> {props.errors.bloodGroup} </ErrorLabel> | ||
213 | )} | ||
214 | </FormGroup> | ||
215 | </Col> | ||
216 | <Col xs={12} sm={6}> | ||
217 | <FormGroup controlId="phone"> | ||
218 | <Label required>Phone</Label> | ||
219 | <FormControl | ||
220 | type="text" | ||
221 | value={props.getValue('phone')} | ||
222 | placeholder="9999999999" | ||
223 | onChange={e => props.setValue('phone', e.target.value)} | ||
224 | /> | ||
225 | {props.isSubmitted() && props.errors && props.errors.phone && ( | ||
226 | <ErrorLabel> {props.errors.phone} </ErrorLabel> | ||
227 | )} | ||
228 | </FormGroup> | ||
229 | </Col> | ||
230 | </Row> | ||
231 | </fieldset> | ||
232 | )} | ||
233 | {props.currentStep === 2 && ( | ||
234 | <fieldset title="Address"> | ||
235 | <legend className="text-semibold">Address</legend> | ||
236 | <Row> | ||
237 | <Col xs={12} sm={6}> | ||
238 | <FormGroup controlId="address"> | ||
239 | <Label required>Address</Label> | ||
240 | <FormControl | ||
241 | type="text" | ||
242 | value={props.getValue('address')} | ||
243 | placeholder="#876, Street, town" | ||
244 | onChange={e => props.setValue('address', e.target.value)} | ||
245 | /> | ||
246 | {props.isSubmitted() && props.errors && props.errors.address && ( | ||
247 | <ErrorLabel> {props.errors.address} </ErrorLabel> | ||
248 | )} | ||
249 | </FormGroup> | ||
250 | </Col> | ||
251 | <Col xs={12} sm={6}> | ||
252 | <FormGroup controlId="city"> | ||
253 | <Label required>City</Label> | ||
254 | <FormControl | ||
255 | type="text" | ||
256 | value={props.getValue('city')} | ||
257 | placeholder="Chennai" | ||
258 | onChange={e => props.setValue('city', e.target.value)} | ||
259 | /> | ||
260 | {props.isSubmitted() && props.errors && props.errors.city && ( | ||
261 | <ErrorLabel> {props.errors.city} </ErrorLabel> | ||
262 | )} | ||
263 | </FormGroup> | ||
264 | </Col> | ||
265 | </Row> | ||
266 | <Row> | ||
267 | <Col xs={12} sm={6}> | ||
268 | <FormGroup controlId="state"> | ||
269 | <Label required>State</Label> | ||
270 | <FormControl | ||
271 | type="text" | ||
272 | value={props.getValue('state')} | ||
273 | placeholder="Tamilnadu" | ||
274 | onChange={e => props.setValue('state', e.target.value)} | ||
275 | /> | ||
276 | {props.isSubmitted() && props.errors && props.errors.state && ( | ||
277 | <ErrorLabel> {props.errors.state} </ErrorLabel> | ||
278 | )} | ||
279 | </FormGroup> | ||
280 | </Col> | ||
281 | </Row> | ||
282 | </fieldset> | ||
283 | )} | ||
284 | {props.currentStep === 3 && ( | ||
285 | <fieldset title="2"> | ||
286 | <legend className="text-semibold">Parent information</legend> | ||
287 | <Row> | ||
288 | <Col xs={12} sm={6}> | ||
289 | <FormGroup controlId="parentName"> | ||
290 | <Label required>Parent Name</Label> | ||
291 | <FormControl | ||
292 | type="text" | ||
293 | value={props.getValue('parentName')} | ||
294 | placeholder="John" | ||
295 | onChange={e => props.setValue('parentName', e.target.value)} | ||
296 | /> | ||
297 | {props.isSubmitted() && props.errors && props.errors.parentName && ( | ||
298 | <ErrorLabel> {props.errors.parentName} </ErrorLabel> | ||
299 | )} | ||
300 | </FormGroup> | ||
301 | </Col> | ||
302 | <Col xs={12} sm={6}> | ||
303 | <FormGroup controlId="parentEmail"> | ||
304 | <Label required>Parent Email</Label> | ||
305 | <FormControl | ||
306 | type="text" | ||
307 | value={props.getValue('parentEmail')} | ||
308 | placeholder="john@email.com" | ||
309 | onChange={e => props.setValue('parentEmail', e.target.value)} | ||
310 | /> | ||
311 | {props.isSubmitted() && props.errors && props.errors.parentEmail && ( | ||
312 | <ErrorLabel> {props.errors.parentEmail} </ErrorLabel> | ||
313 | )} | ||
314 | </FormGroup> | ||
315 | </Col> | ||
316 | </Row> | ||
317 | <Row> | ||
318 | <Col xs={12} sm={6}> | ||
319 | <FormGroup controlId="relation"> | ||
320 | <Label required>Relation</Label> | ||
321 | <FormControl | ||
322 | type="text" | ||
323 | value={props.getValue('relation')} | ||
324 | placeholder="Father" | ||
325 | onChange={e => props.setValue('relation', e.target.value)} | ||
326 | /> | ||
327 | {props.isSubmitted() && props.errors && props.errors.relation && ( | ||
328 | <ErrorLabel> {props.errors.relation} </ErrorLabel> | ||
329 | )} | ||
330 | </FormGroup> | ||
331 | </Col> | ||
332 | <Col xs={12} sm={6}> | ||
333 | <FormGroup controlId="profession"> | ||
334 | <Label required>Profession</Label> | ||
335 | <FormControl | ||
336 | type="text" | ||
337 | value={props.getValue('profession')} | ||
338 | placeholder="Farmer" | ||
339 | onChange={e => props.setValue('profession', e.target.value)} | ||
340 | /> | ||
341 | {props.isSubmitted() && props.errors && props.errors.profession && ( | ||
342 | <ErrorLabel> {props.errors.profession} </ErrorLabel> | ||
343 | )} | ||
344 | </FormGroup> | ||
345 | </Col> | ||
346 | </Row> | ||
347 | <Row> | ||
348 | <Col xs={12} sm={6}> | ||
349 | <FormGroup controlId="parentGender"> | ||
350 | <Label>Parent Gender</Label> | ||
351 | <FormControl componentClass="select" | ||
352 | placeholder="select" | ||
353 | value={props.getValue('parentGender')} | ||
354 | onChange={e => props.setValue('parentGender', e.target.value)} | ||
355 | > | ||
356 | <option value="male">Male</option> | ||
357 | <option value="female">Female</option> | ||
358 | </FormControl> | ||
359 | {props.isSubmitted() && props.errors && props.errors.parentGender && ( | ||
360 | <ErrorLabel> {props.errors.parentGender} </ErrorLabel> | ||
361 | )} | ||
362 | </FormGroup> | ||
363 | </Col> | ||
364 | <Col xs={12} sm={6}> | ||
365 | <FormGroup controlId="parentPhone"> | ||
366 | <Label required>Parent Phone</Label> | ||
367 | <FormControl | ||
368 | type="text" | ||
369 | value={props.getValue('parentPhone')} | ||
370 | placeholder="9876543210" | ||
371 | onChange={e => props.setValue('parentPhone', e.target.value)} | ||
372 | /> | ||
373 | {props.isSubmitted() && props.errors && props.errors.parentPhone && ( | ||
374 | <ErrorLabel> {props.errors.parentPhone} </ErrorLabel> | ||
375 | )} | ||
376 | </FormGroup> | ||
377 | </Col> | ||
378 | </Row> | ||
379 | <Row> | ||
380 | <Col xs={12} sm={6}> | ||
381 | <FormGroup controlId="parentAddress"> | ||
382 | <Label required>Parent Address</Label> | ||
383 | <FormControl | ||
384 | type="text" | ||
385 | value={props.getValue('parentAddress')} | ||
386 | placeholder="#12, street, town" | ||
387 | onChange={e => props.setValue('parentAddress', e.target.value)} | ||
388 | /> | ||
389 | {props.isSubmitted() && props.errors && props.errors.parentAddress && ( | ||
390 | <ErrorLabel> {props.errors.parentAddress} </ErrorLabel> | ||
391 | )} | ||
392 | </FormGroup> | ||
393 | </Col> | ||
394 | <Col xs={12} sm={6}> | ||
395 | <FormGroup controlId="parentCity"> | ||
396 | <Label required>Parent City</Label> | ||
397 | <FormControl | ||
398 | type="text" | ||
399 | value={props.getValue('parentCity')} | ||
400 | placeholder="Chennai" | ||
401 | onChange={e => props.setValue('parentCity', e.target.value)} | ||
402 | /> | ||
403 | {props.isSubmitted() && props.errors && props.errors.parentCity && ( | ||
404 | <ErrorLabel> {props.errors.parentCity} </ErrorLabel> | ||
405 | )} | ||
406 | </FormGroup> | ||
407 | </Col> | ||
408 | </Row> | ||
409 | <Row> | ||
410 | <Col xs={12} sm={6}> | ||
411 | <FormGroup controlId="parentState"> | ||
412 | <Label required>Parent State</Label> | ||
413 | <FormControl | ||
414 | type="text" | ||
415 | value={props.getValue('parentState')} | ||
416 | placeholder="600031" | ||
417 | onChange={e => props.setValue('parentState', e.target.value)} | ||
418 | /> | ||
419 | {props.isSubmitted() && props.errors && props.errors.parentState && ( | ||
420 | <ErrorLabel> {props.errors.parentState} </ErrorLabel> | ||
421 | )} | ||
422 | </FormGroup> | ||
423 | </Col> | ||
424 | <Col xs={12} sm={6}> | ||
425 | <FormGroup controlId="parentZipcode"> | ||
426 | <Label required>Parent Zipcode</Label> | ||
427 | <FormControl | ||
428 | type="text" | ||
429 | value={props.getValue('parentZipcode')} | ||
430 | placeholder="600031" | ||
431 | onChange={e => props.setValue('parentZipcode', e.target.value)} | ||
432 | /> | ||
433 | {props.isSubmitted() && props.errors && props.errors.parentZipcode && ( | ||
434 | <ErrorLabel> {props.errors.parentZipcode} </ErrorLabel> | ||
435 | )} | ||
436 | </FormGroup> | ||
437 | </Col> | ||
438 | </Row> | ||
439 | </fieldset> | ||
440 | )} | ||
441 | <div style={{ textAlign: 'left' }}> | ||
442 | {props.currentStep > 0 && ( | ||
443 | <div style={{ display: 'inline-block', marginRight: 10 }}> | ||
444 | <Button onClick={props.onBackClick}> | ||
445 | <i className="icon-arrow-left13 position-left"></i> | ||
446 | BACK | ||
447 | </Button> | ||
448 | |||
449 | </div> | ||
450 | )} | ||
451 | {props.currentStep < 3 && ( | ||
452 | <div style={{ display: 'inline-block' }}> | ||
453 | <Button | ||
454 | bsStyle="primary" | ||
455 | onClick={props.onNextClick} | ||
456 | > | ||
457 | NEXT | ||
458 | <i className="icon-arrow-right14 position-right" /> | ||
459 | </Button> | ||
460 | </div> | ||
461 | )} | ||
462 | {props.currentStep === 3 && ( | ||
463 | <div style={{ display: 'inline-block' }}> | ||
464 | <Button | ||
465 | bsStyle="primary" | ||
466 | onClick={props.onNextClick} | ||
467 | > | ||
468 | SAVE | ||
469 | <i className="fa fa-check" /> | ||
470 | </Button> | ||
471 | </div> | ||
472 | )} | ||
473 | </div> | ||
474 | </div> | ||
475 | ) | ||
476 | |||
477 | StudentForm.propTypes = { | ||
478 | currentStep: PropTypes.number.isRequired, | ||
479 | onNextClick: PropTypes.func.isRequired, | ||
480 | onBackClick: PropTypes.func.isRequired, | ||
481 | setValue: PropTypes.func.isRequired, | ||
482 | getValue: PropTypes.func.isRequired, | ||
483 | } | ||
484 | |||
485 | export default StudentForm | ||
486 |
imports/client/views/org/admin/teachers/add/addStudentForm.js
File was created | 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 { Form, FormGroup,InputGroup, | ||
7 | DropdownButton,MenuItem,ControlLabel, | ||
8 | SplitButton, | ||
9 | FormControl,Glyphicon,Button } from 'react-bootstrap'; | ||
10 | import DatePicker from 'react-bootstrap-date-picker' | ||
11 | import {addStudentManually} from '/imports/collections/students/methods'; | ||
12 | |||
13 | export class AddStudentForm extends Component { | ||
14 | |||
15 | constructor(props) { | ||
16 | super(props); | ||
17 | this.state = { | ||
18 | admissionId: "123", | ||
19 | firstName: "first", | ||
20 | lastName: "last", | ||
21 | middleName: "middle", | ||
22 | email: "deepak125.dk+21@gmail.com", | ||
23 | dob: "", | ||
24 | formattedDob: "", | ||
25 | gender: "male", | ||
26 | rollNo: "1", | ||
27 | class: "2", | ||
28 | section: "B", | ||
29 | community: "SC", | ||
30 | bloodGroup: "B+", | ||
31 | phone: "9876543321", | ||
32 | address: "address", | ||
33 | city: "chennai", | ||
34 | state: "tn", | ||
35 | parentName: "parentName", | ||
36 | parentEmail: "deepak125.dk+41@gmail.com", | ||
37 | relation: "father", | ||
38 | profession: "farmer", | ||
39 | parentGender: "male", | ||
40 | parentPhone: "987655412", | ||
41 | parentAddress: "parentAddress", | ||
42 | parentCity: "parentCity", | ||
43 | parentState: "parentState", | ||
44 | parentZipcode: "parentZipcode", | ||
45 | }; | ||
46 | this.onUpdate = this.onUpdate.bind(this); | ||
47 | this.handleDob = this.handleDob.bind(this); | ||
48 | }; | ||
49 | |||
50 | onUpdate(key, value) { | ||
51 | this.setState({[key]: value}); | ||
52 | }; | ||
53 | |||
54 | handleDob(value, formattedValue) { | ||
55 | this.setState({ | ||
56 | dob: value, // ISO String, ex: "2016-11-19T12:00:00.000Z" | ||
57 | formattedDob: formattedValue // Formatted String, ex: "11/19/2016" | ||
58 | }); | ||
59 | } | ||
60 | addStudent(e){ | ||
61 | e.preventDefault(); | ||
62 | e.persist(); | ||
63 | const firstName = this.state.firstName; | ||
64 | const middleName = this.state.middleName; | ||
65 | const lastName = this.state.lastName; | ||
66 | const admissionId = this.state.admissionId; | ||
67 | const email = this.state.email; | ||
68 | const dob = this.state.dob; | ||
69 | const formattedDob = this.state.formattedDob; | ||
70 | const gender = this.state.gender; | ||
71 | const rollNo = this.state.rollNo; | ||
72 | const studentclass = this.state.class; | ||
73 | const section = this.state.section; | ||
74 | const community = this.state.community; | ||
75 | const bloodGroup = this.state.bloodGroup; | ||
76 | const phone = this.state.phone; | ||
77 | const address = this.state.address; | ||
78 | const city = this.state.city; | ||
79 | const state = this.state.state; | ||
80 | const parentName = this.state.parentName; | ||
81 | const parentEmail = this.state.parentEmail; | ||
82 | const relation = this.state.relation; | ||
83 | const profession = this.state.profession; | ||
84 | const parentGender = this.state.parentGender; | ||
85 | const parentPhone = this.state.parentPhone; | ||
86 | const parentAddress = this.state.parentAddress; | ||
87 | const parentCity = this.state.parentCity; | ||
88 | const parentState = this.state.parentState; | ||
89 | const parentZipcode = this.state.parentZipcode; | ||
90 | if(admissionId==""){ | ||
91 | Bert.alert('Enter Admission Id!', 'danger'); | ||
92 | }else if(firstName==""){ | ||
93 | Bert.alert('Enter Fist Name', 'danger'); | ||
94 | } else if(middleName==""){ | ||
95 | Bert.alert('Enter Middle name!', 'danger'); | ||
96 | }else if(lastName==""){ | ||
97 | Bert.alert('Enter Last name!', 'danger'); | ||
98 | }else if(email==""){ | ||
99 | Bert.alert('Enter email!', 'danger'); | ||
100 | }else if(dob==""){ | ||
101 | Bert.alert('Enter DOB!', 'danger'); | ||
102 | }else if(gender==""){ | ||
103 | Bert.alert('Enter Student Gender!', 'danger'); | ||
104 | }else if(studentclass==""){ | ||
105 | Bert.alert('Enter Class!', 'danger'); | ||
106 | }else if(section==""){ | ||
107 | Bert.alert('Enter Section!', 'danger'); | ||
108 | }else if(community==""){ | ||
109 | Bert.alert('Enter Section!', 'danger'); | ||
110 | }else if(bloodGroup==""){ | ||
111 | Bert.alert('Enter Blood Group!', 'danger'); | ||
112 | }else if(phone==""){ | ||
113 | Bert.alert('Enter phone!', 'danger'); | ||
114 | }else if(address==""){ | ||
115 | Bert.alert('Enter address!', 'danger'); | ||
116 | }else if(city==""){ | ||
117 | Bert.alert('Enter city!', 'danger'); | ||
118 | }else if(state==""){ | ||
119 | Bert.alert('Enter state!', 'danger'); | ||
120 | }else if(parentName==""){ | ||
121 | Bert.alert('Enter Parent name!', 'danger'); | ||
122 | }else if(parentEmail==""){ | ||
123 | Bert.alert('Enter Parent Email!', 'danger'); | ||
124 | }else if(relation==""){ | ||
125 | Bert.alert('Enter relation!', 'danger'); | ||
126 | }else if(profession==""){ | ||
127 | Bert.alert('Enter parent profession!', 'danger'); | ||
128 | }else if(parentGender==""){ | ||
129 | Bert.alert("Enter Parent's Gender!", 'danger'); | ||
130 | }else if(parentPhone==""){ | ||
131 | Bert.alert("Enter Parent's Phone!", 'danger'); | ||
132 | }else if(parentAddress==""){ | ||
133 | Bert.alert("Enter Parent's Address!", 'danger'); | ||
134 | }else if(parentCity==""){ | ||
135 | Bert.alert("Enter Parent's City!", 'danger'); | ||
136 | }else if(parentState==""){ | ||
137 | Bert.alert("Enter Parent's State!", 'danger'); | ||
138 | }else if(parentZipcode==""){ | ||
139 | Bert.alert("Enter Parent's zipcode!", 'danger'); | ||
140 | }else{ | ||
141 | addStudentManually.call({ | ||
142 | admissionId, | ||
143 | firstName, | ||
144 | middleName, | ||
145 | lastName, | ||
146 | email, | ||
147 | dob, | ||
148 | formattedDob, | ||
149 | gender, | ||
150 | rollNo, | ||
151 | studentclass, | ||
152 | section, | ||
153 | community, | ||
154 | bloodGroup, | ||
155 | phone, | ||
156 | address, | ||
157 | city, | ||
158 | state, | ||
159 | parentName, | ||
160 | parentEmail, | ||
161 | relation, | ||
162 | profession, | ||
163 | parentGender, | ||
164 | parentPhone, | ||
165 | parentAddress, | ||
166 | parentCity, | ||
167 | parentState, | ||
168 | parentZipcode | ||
169 | }, function (error, result) { | ||
170 | console.log(error); | ||
171 | console.log(result); | ||
172 | }); | ||
173 | } | ||
174 | } | ||
175 | render() { | ||
176 | return ( | ||
177 | <Form className="steps-validation wizard clearfix" onSubmit={ (e) => this.addStudent(e) } inline> | ||
178 | <div className="steps clearfix"> | ||
179 | <ul role="tablist"> | ||
180 | <li role="tab" className="first current" aria-disabled="false" aria-selected="true"> | ||
181 | <a id="steps-uid-4-t-0" href="#steps-uid-4-h-0" aria-controls="steps-uid-4-p-0"> | ||
182 | <span className="current-info audible">current step: </span><span className="number">1</span> Personal data | ||
183 | </a> | ||
184 | </li> | ||
185 | <li role="tab" className="disabled" aria-disabled="true"> | ||
186 | <a id="steps-uid-4-t-1" href="#steps-uid-4-h-1" aria-controls="steps-uid-4-p-1"> | ||
187 | <span className="number">2</span> Your education\n\ | ||
188 | </a> | ||
189 | </li> | ||
190 | <li role="tab" className="disabled" aria-disabled="true"> | ||
191 | <a id="steps-uid-4-t-2" href="#steps-uid-4-h-2" aria-controls="steps-uid-4-p-2"> | ||
192 | <span className="number">3</span> Your experience | ||
193 | </a> | ||
194 | </li> | ||
195 | <li role="tab" className="disabled last" aria-disabled="true"> | ||
196 | <a id="steps-uid-4-t-3" href="#steps-uid-4-h-3" aria-controls="steps-uid-4-p-3"> | ||
197 | <span className="number">4</span> Additional info | ||
198 | </a> | ||
199 | </li> | ||
200 | </ul> | ||
201 | </div> | ||
202 | <div className="content clearfix"> | ||
203 | <h6 id="steps-uid-4-h-0" tabindex="-1" className="title current">Personal data</h6> | ||
204 | <div id="steps-uid-4-p-0" role="tabpanel" aria-labelledby="steps-uid-4-h-0" className="body current"> | ||
205 | <div className="row"> | ||
206 | <div className="col-md-6"> | ||
207 | |||
208 | <FormGroup controlId="admissionId"> | ||
209 | <ControlLabel>Admission Id</ControlLabel> | ||
210 | <FormControl | ||
211 | type="text" | ||
212 | value={this.state.admissionId} | ||
213 | placeholder="admission Id" | ||
214 | onChange={e=>this.onUpdate('admissionId',e.target.value)} | ||
215 | /> | ||
216 | </FormGroup> | ||
217 | |||
218 | </div> | ||
219 | |||
220 | <div className="col-md-6"> | ||
221 | |||
222 | <FormGroup controlId="firstName"> | ||
223 | <ControlLabel>First Name</ControlLabel> | ||
224 | <FormControl | ||
225 | type="text" | ||
226 | value={this.state.firstName} | ||
227 | placeholder="First Name" | ||
228 | onChange={e=>this.onUpdate('firstName',e.target.value)} | ||
229 | /> | ||
230 | </FormGroup> | ||
231 | |||
232 | </div> | ||
233 | </div> | ||
234 | </div> | ||
235 | </div> | ||
236 | |||
237 | |||
238 | <FormGroup controlId="admissionId"> | ||
239 | <ControlLabel>Admission Id</ControlLabel> | ||
240 | <FormControl | ||
241 | type="text" | ||
242 | value={this.state.admissionId} | ||
243 | placeholder="admission Id" | ||
244 | onChange={e=>this.onUpdate('admissionId',e.target.value)} | ||
245 | /> | ||
246 | </FormGroup> | ||
247 | |||
248 | <FormGroup controlId="firstName"> | ||
249 | <ControlLabel>First Name</ControlLabel> | ||
250 | <FormControl | ||
251 | type="text" | ||
252 | value={this.state.firstName} | ||
253 | placeholder="First Name" | ||
254 | onChange={e=>this.onUpdate('firstName',e.target.value)} | ||
255 | /> | ||
256 | </FormGroup> | ||
257 | <FormGroup controlId="middleName"> | ||
258 | <ControlLabel>Middle Name</ControlLabel> | ||
259 | <FormControl | ||
260 | type="text" | ||
261 | value={this.state.middleName} | ||
262 | placeholder="Middle Name" | ||
263 | onChange={e=>this.onUpdate('middleName',e.target.value)} | ||
264 | /> | ||
265 | </FormGroup> | ||
266 | |||
267 | <FormGroup controlId="lastName"> | ||
268 | <ControlLabel>Last Name</ControlLabel> | ||
269 | <FormControl | ||
270 | type="text" | ||
271 | value={this.state.lastName} | ||
272 | placeholder="Last Name" | ||
273 | onChange={e=>this.onUpdate('lastName',e.target.value)} | ||
274 | /> | ||
275 | |||
276 | </FormGroup> | ||
277 | <FormGroup controlId="email"> | ||
278 | <ControlLabel>Email</ControlLabel> | ||
279 | <FormControl | ||
280 | type="email" | ||
281 | value={this.state.email} | ||
282 | placeholder="Email" | ||
283 | onChange={e=>this.onUpdate('email',e.target.value)} | ||
284 | /> | ||
285 | </FormGroup> | ||
286 | <FormGroup> | ||
287 | <ControlLabel>Date of birth</ControlLabel> | ||
288 | <DatePicker id="dob" | ||
289 | value={this.state.dob} | ||
290 | onChange={this.handleDob} | ||
291 | /> | ||
292 | </FormGroup> | ||
293 | |||
294 | <FormGroup controlId="formControlsSelect"> | ||
295 | <ControlLabel>Gender</ControlLabel> | ||
296 | <FormControl componentClass="select" | ||
297 | placeholder="select" | ||
298 | value={this.state.gender} | ||
299 | onChange={e=>this.onUpdate('gender',e.target.value)} | ||
300 | > | ||
301 | <option value="male">Male</option> | ||
302 | <option value="female">Female</option> | ||
303 | </FormControl> | ||
304 | </FormGroup> | ||
305 | |||
306 | <FormGroup controlId="rollNo"> | ||
307 | <ControlLabel>Roll No</ControlLabel> | ||
308 | <FormControl | ||
309 | type="text" | ||
310 | value={this.state.rollNo} | ||
311 | placeholder="Roll No" | ||
312 | onChange={e=>this.onUpdate('rollNo',e.target.value)} | ||
313 | /> | ||
314 | </FormGroup> | ||
315 | <FormGroup controlId="class"> | ||
316 | <ControlLabel>Class</ControlLabel> | ||
317 | <FormControl | ||
318 | type="text" | ||
319 | value={this.state.class} | ||
320 | placeholder="7" | ||
321 | onChange={e=>this.onUpdate('class',e.target.value)} | ||
322 | /> | ||
323 | </FormGroup> | ||
324 | <FormGroup controlId="section"> | ||
325 | <ControlLabel>Section</ControlLabel> | ||
326 | <FormControl | ||
327 | type="text" | ||
328 | value={this.state.section} | ||
329 | placeholder="B" | ||
330 | onChange={e=>this.onUpdate('section',e.target.value)} | ||
331 | /> | ||
332 | </FormGroup> | ||
333 | |||
334 | <FormGroup controlId="community"> | ||
335 | <ControlLabel>Community</ControlLabel> | ||
336 | <FormControl | ||
337 | type="text" | ||
338 | value={this.state.community} | ||
339 | placeholder="General" | ||
340 | onChange={e=>this.onUpdate('community',e.target.value)} | ||
341 | /> | ||
342 | </FormGroup> | ||
343 | |||
344 | <FormGroup controlId="bloodGroup"> | ||
345 | <ControlLabel>bloodGroup</ControlLabel> | ||
346 | <FormControl | ||
347 | type="text" | ||
348 | value={this.state.bloodGroup} | ||
349 | placeholder="B+" | ||
350 | onChange={e=>this.onUpdate('bloodGroup',e.target.value)} | ||
351 | /> | ||
352 | </FormGroup> | ||
353 | |||
354 | <FormGroup controlId="phone"> | ||
355 | <ControlLabel>Phone</ControlLabel> | ||
356 | <FormControl | ||
357 | type="text" | ||
358 | value={this.state.phone} | ||
359 | placeholder="9999999999" | ||
360 | onChange={e=>this.onUpdate('phone',e.target.value)} | ||
361 | /> | ||
362 | </FormGroup> | ||
363 | |||
364 | <FormGroup controlId="address"> | ||
365 | <ControlLabel>Address</ControlLabel> | ||
366 | <FormControl | ||
367 | type="text" | ||
368 | value={this.state.address} | ||
369 | placeholder="#876, Street, town" | ||
370 | onChange={e=>this.onUpdate('address',e.target.value)} | ||
371 | /> | ||
372 | </FormGroup> | ||
373 | |||
374 | <FormGroup controlId="city"> | ||
375 | <ControlLabel>City</ControlLabel> | ||
376 | <FormControl | ||
377 | type="text" | ||
378 | value={this.state.city} | ||
379 | placeholder="Chennai" | ||
380 | onChange={e=>this.onUpdate('city',e.target.value)} | ||
381 | /> | ||
382 | </FormGroup> | ||
383 | |||
384 | <FormGroup controlId="state"> | ||
385 | <ControlLabel>State</ControlLabel> | ||
386 | <FormControl | ||
387 | type="text" | ||
388 | value={this.state.state} | ||
389 | placeholder="Tamilnadu" | ||
390 | onChange={e=>this.onUpdate('state',e.target.value)} | ||
391 | /> | ||
392 | </FormGroup> | ||
393 | |||
394 | <FormGroup controlId="parentName"> | ||
395 | <ControlLabel>Parent Name</ControlLabel> | ||
396 | <FormControl | ||
397 | type="text" | ||
398 | value={this.state.parentName} | ||
399 | placeholder="John" | ||
400 | onChange={e=>this.onUpdate('parentName',e.target.value)} | ||
401 | /> | ||
402 | </FormGroup> | ||
403 | |||
404 | <FormGroup controlId="parentEmail"> | ||
405 | <ControlLabel>Parent Email</ControlLabel> | ||
406 | <FormControl | ||
407 | type="text" | ||
408 | value={this.state.parentEmail} | ||
409 | placeholder="john@email.com" | ||
410 | onChange={e=>this.onUpdate('parentEmail',e.target.value)} | ||
411 | /> | ||
412 | </FormGroup> | ||
413 | |||
414 | <FormGroup controlId="relation"> | ||
415 | <ControlLabel>Relation</ControlLabel> | ||
416 | <FormControl | ||
417 | type="text" | ||
418 | value={this.state.relation} | ||
419 | placeholder="Father" | ||
420 | onChange={e=>this.onUpdate('relation',e.target.value)} | ||
421 | /> | ||
422 | </FormGroup> | ||
423 | |||
424 | <FormGroup controlId="profession"> | ||
425 | <ControlLabel>Profession</ControlLabel> | ||
426 | <FormControl | ||
427 | type="text" | ||
428 | value={this.state.profession} | ||
429 | placeholder="Farmer" | ||
430 | onChange={e=>this.onUpdate('profession',e.target.value)} | ||
431 | /> | ||
432 | </FormGroup> | ||
433 | |||
434 | <FormGroup controlId="parentGender"> | ||
435 | <ControlLabel>Parent Gender</ControlLabel> | ||
436 | <FormControl componentClass="select" | ||
437 | placeholder="select" | ||
438 | value={this.state.parentGender} | ||
439 | onChange={e=>this.onUpdate('parentGender',e.target.value)} | ||
440 | > | ||
441 | <option value="male">Male</option> | ||
442 | <option value="female">Female</option> | ||
443 | </FormControl> | ||
444 | </FormGroup> | ||
445 | |||
446 | <FormGroup controlId="parentPhone"> | ||
447 | <ControlLabel>Parent Phone</ControlLabel> | ||
448 | <FormControl | ||
449 | type="text" | ||
450 | value={this.state.parentPhone} | ||
451 | placeholder="9876543210" | ||
452 | onChange={e=>this.onUpdate('parentPhone',e.target.value)} | ||
453 | /> | ||
454 | </FormGroup> | ||
455 | |||
456 | <FormGroup controlId="parentAddress"> | ||
457 | <ControlLabel>Parent Address</ControlLabel> | ||
458 | <FormControl | ||
459 | type="text" | ||
460 | value={this.state.parentAddress} | ||
461 | placeholder="#12, street, town" | ||
462 | onChange={e=>this.onUpdate('parentAddress',e.target.value)} | ||
463 | /> | ||
464 | </FormGroup> | ||
465 | |||
466 | <FormGroup controlId="parentCity"> | ||
467 | <ControlLabel>Parent City</ControlLabel> | ||
468 | <FormControl | ||
469 | type="text" | ||
470 | value={this.state.parentCity} | ||
471 | placeholder="Chennai" | ||
472 | onChange={e=>this.onUpdate('parentCity',e.target.value)} | ||
473 | /> | ||
474 | </FormGroup> | ||
475 | |||
476 | <FormGroup controlId="parentState"> | ||
477 | <ControlLabel>Parent State</ControlLabel> | ||
478 | <FormControl | ||
479 | type="text" | ||
480 | value={this.state.parentState} | ||
481 | placeholder="Tamilnadu" | ||
482 | onChange={e=>this.onUpdate('parentState',e.target.value)} | ||
483 | /> | ||
484 | </FormGroup> | ||
485 | |||
486 | <FormGroup controlId="parentZipcode"> | ||
487 | <ControlLabel>Parent Zipcode</ControlLabel> | ||
488 | <FormControl | ||
489 | type="text" | ||
490 | value={this.state.parentZipcode} | ||
491 | placeholder="600031" | ||
492 | onChange={e=>this.onUpdate('parentZipcode',e.target.value)} | ||
493 | /> | ||
494 | </FormGroup> | ||
495 | <Button type="submit" bsStyle="default">Add Student</Button> | ||
496 | </Form> | ||
497 | ); | ||
498 | }; | ||
499 | |||
500 | }; | ||
501 |
imports/client/views/org/admin/teachers/add/addTeacher.js
File was created | 1 | import _ from 'lodash'; | |
2 | import { Meteor } from 'meteor/meteor'; | ||
3 | import React, { Component } from 'react'; | ||
4 | import { Link,browserHistory } from 'react-router'; | ||
5 | import { FormGroup,Panel,Table, | ||
6 | ButtonToolbar,Modal, | ||
7 | FormControl,Glyphicon,Button } from 'react-bootstrap'; | ||
8 | import { AddStudentFormContainer } from './AddStudentFormContainer'; | ||
9 | |||
10 | const style = { | ||
11 | margin: 12, | ||
12 | }; | ||
13 | export class AddTeacher extends Component { | ||
14 | constructor(props) { | ||
15 | super(props); | ||
16 | this.state = { | ||
17 | show: false | ||
18 | }; | ||
19 | this.showModal = this.showModal.bind(this); | ||
20 | this.hideModal = this.hideModal.bind(this); | ||
21 | this.onUpdate = this.onUpdate.bind(this); | ||
22 | }; | ||
23 | |||
24 | showModal() { | ||
25 | this.setState({show: true}); | ||
26 | } | ||
27 | |||
28 | hideModal() { | ||
29 | this.setState({show: false}); | ||
30 | } | ||
31 | onUpdate(key, value) { | ||
32 | this.setState({[key]: value}); | ||
33 | }; | ||
34 | |||
35 | render() { | ||
36 | return ( | ||
37 | <ButtonToolbar> | ||
38 | <Button bsStyle="primary" onClick={this.showModal}> | ||
39 | Add Student | ||
40 | </Button> | ||
41 | <Modal | ||
42 | {...this.props} | ||
43 | show={this.state.show} | ||
44 | onHide={this.hideModal} | ||
45 | dialogClassName="custom-modal" | ||
46 | > | ||
47 | <Modal.Header closeButton> | ||
48 | <Modal.Title id="contained-modal-title-lg">New Student</Modal.Title> | ||
49 | </Modal.Header> | ||
50 | <Modal.Body> | ||
51 | <AddStudentFormContainer /> | ||
52 | </Modal.Body> | ||
53 | {/* | ||
54 | <Modal.Footer> | ||
55 | <Button onClick={this.hideModal}>Close</Button> | ||
56 | </Modal.Footer> | ||
57 | */} | ||
58 | </Modal> | ||
59 | </ButtonToolbar> | ||
60 | ); | ||
61 | }; | ||
62 | |||
63 | }; | ||
64 |