Commit ec5f044a941dee80ffe6c96e356633a9928e645e
1 parent
fdfd4efb97
Exists in
master
Finished add teacher view
Showing
14 changed files
with
320 additions
and
374 deletions
Show diff stats
imports/client/views/core/DatePicker.js
... | ... | @@ -9,7 +9,7 @@ class DatePicker extends Component { |
9 | 9 | changeMonth: true, |
10 | 10 | changeYear: true, |
11 | 11 | showButtonPanel: true, |
12 | - yearRange: '-25:-1', | |
12 | + yearRange: '-35:-1', | |
13 | 13 | dateFormat: 'dd/mm/yy', |
14 | 14 | onSelect: function(dateText, inst) { |
15 | 15 | var date = $(this).val(); | ... | ... |
imports/client/views/org/admin/staff/add/AddStaffFormContainer.js
... | ... | @@ -3,6 +3,7 @@ import StaffForm from './StaffForm' |
3 | 3 | import Form from '/imports/client/views/core/Form' |
4 | 4 | import Validator from '/imports/client/views/core/Validator' |
5 | 5 | import { isRequired, isValidEmail } from '/imports/client/views/core/validations' |
6 | +import { addStudentManually } from '/imports/collections/students/methods'; | |
6 | 7 | |
7 | 8 | export class AddStaffFormContainer extends Component { |
8 | 9 | |
... | ... | @@ -15,8 +16,10 @@ export class AddStaffFormContainer extends Component { |
15 | 16 | } |
16 | 17 | |
17 | 18 | handleNextClick() { |
19 | + console.log("clicked"); | |
18 | 20 | this.form.handleSubmit() |
19 | 21 | if (this.validator.getErrors() && Object.keys(this.validator.getErrors()).length > 0) return |
22 | + console.log("after submit"); | |
20 | 23 | this.setState({ currentStep: this.state.currentStep + 1 }) |
21 | 24 | this.form.resetSubmitted() |
22 | 25 | } |
... | ... | @@ -26,8 +29,12 @@ export class AddStaffFormContainer extends Component { |
26 | 29 | } |
27 | 30 | |
28 | 31 | handleSubmit() { |
29 | - if (this.state.currentStep === 3) { | |
30 | - addStudentManually.call(this.form.state.values) | |
32 | + if (this.state.currentStep === 2) { | |
33 | + console.log(this.form.state.values); | |
34 | + Meteor.call('staff.addNew', this.form.state.values, (error, result) => { | |
35 | + console.log(error); | |
36 | + console.log(result); | |
37 | + }); | |
31 | 38 | } |
32 | 39 | } |
33 | 40 | |
... | ... | @@ -38,8 +45,28 @@ export class AddStaffFormContainer extends Component { |
38 | 45 | onSubmit={this.handleSubmit} |
39 | 46 | ref={form => this.form = form} |
40 | 47 | initialValues={{ |
41 | - gender: 'male', | |
42 | - parentGender: 'male', | |
48 | + employeeId: '12345', | |
49 | + firstName: 'Test', | |
50 | + lastName: 'Last', | |
51 | + | |
52 | + martialStatus: 'single', | |
53 | + gender: 'male', | |
54 | + dob: '07/03/1993', | |
55 | + | |
56 | + email: 'deepak125.dk+400@gmail.com', | |
57 | + phone: '9876543210', | |
58 | + address: '123', | |
59 | + | |
60 | + teaching: "yes", | |
61 | + type: 'permanent', | |
62 | + doj: '07/03/2016', | |
63 | + | |
64 | + qualifaication: 'Phd', | |
65 | + specialization: 'Maths', | |
66 | + university: 'Pune University', | |
67 | + | |
68 | + degreeFrom: '07/03/2009', | |
69 | + degreeEnded: '07/03/2013', | |
43 | 70 | }} |
44 | 71 | > |
45 | 72 | {({ values, setValue, getValue, isSubmitted, isDirty }) => ( |
... | ... | @@ -47,31 +74,29 @@ export class AddStaffFormContainer extends Component { |
47 | 74 | values={values} |
48 | 75 | ref={validator => this.validator = validator} |
49 | 76 | validations={{ |
50 | - admissionId: [(value) => isRequired('Admission id', value)], | |
51 | - firstName: [(value) => isRequired('First name', value)], | |
52 | - lastName: [(value) => isRequired('Last name', value)], | |
53 | - email: [(value) => isRequired('Email', value), isValidEmail], | |
54 | - dob: [(value) => isRequired('Date of birth', value)], | |
55 | - gender: [(value) => isRequired('Gender', value)], | |
56 | - rollNo: [(value) => this.state.currentStep === 1 && isRequired('Roll no', value)], | |
57 | - studentClass: [(value) => this.state.currentStep === 1 && isRequired('Class', value)], | |
58 | - section: [(value) => this.state.currentStep === 1 && isRequired('Section', value)], | |
59 | - community: [(value) => this.state.currentStep === 1 && isRequired('Community', value)], | |
60 | - bloodGroup: [(value) => this.state.currentStep === 1 && isRequired('Blood group', value)], | |
61 | - phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], | |
62 | - address: [(value) => this.state.currentStep === 2 && isRequired('Address', value)], | |
63 | - city: [(value) => this.state.currentStep === 2 && isRequired('City', value)], | |
64 | - state: [(value) => this.state.currentStep === 2 && isRequired('State', value)], | |
65 | - parentName: [(value) => this.state.currentStep === 3 && isRequired('Parent name', value)], | |
66 | - parentEmail: [(value) => this.state.currentStep === 3 && isRequired('Parent email', value), (value) => this.state.currentStep === 3 && isValidEmail(value)], | |
67 | - relation: [(value) => this.state.currentStep === 3 && isRequired('Relation', value)], | |
68 | - profession: [(value) => this.state.currentStep === 3 && isRequired('Profession', value)], | |
69 | - parentGender: [(value) => this.state.currentStep === 3 && isRequired('Parent gender', value)], | |
70 | - parentPhone: [(value) => this.state.currentStep === 3 && isRequired('Parent phone', value)], | |
71 | - parentAddress: [(value) => this.state.currentStep === 3 && isRequired('Parent address', value)], | |
72 | - parentCity: [(value) => this.state.currentStep === 3 && isRequired('Parent city', value)], | |
73 | - parentState: [(value) => this.state.currentStep === 3 && isRequired('Parent state', value)], | |
74 | - parentZipcode: [(value) => this.state.currentStep === 3 && isRequired('Parent zip code', value)], | |
77 | + employeeId: [(value) => isRequired('Admission id', value)], | |
78 | + firstName: [(value) => isRequired('First name', value)], | |
79 | + lastName: [(value) => isRequired('Last name', value)], | |
80 | + | |
81 | + gender: [(value) => isRequired('Gender', value)], | |
82 | + martialStatus: [(value) => isRequired('martialStatus', value)], | |
83 | + dob: [(value) => isRequired('Date of birth', value)], | |
84 | + | |
85 | + email: [(value) => this.state.currentStep === 1 && isRequired('Email', value), (value) => this.state.currentStep === 1 && isValidEmail(value)], | |
86 | + phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], | |
87 | + address: [(value) => this.state.currentStep === 1 && isRequired('Address', value)], | |
88 | + | |
89 | + teaching: [(value) => this.state.currentStep === 1 && isRequired('teaching', value)], | |
90 | + type: [(value) => this.state.currentStep === 1 && isRequired('type', value)], | |
91 | + doj: [(value) => this.state.currentStep === 1 && isRequired('doj', value)], | |
92 | + | |
93 | + qualifaication: [(value) => this.state.currentStep === 2 && isRequired('qualifaication', value)], | |
94 | + specialization: [(value) => this.state.currentStep === 2 && isRequired('specialization', value)], | |
95 | + university: [(value) => this.state.currentStep === 2 && isRequired('university', value)], | |
96 | + | |
97 | + degreeFrom: [(value) => this.state.currentStep === 2 && isRequired('degreeFrom', value)], | |
98 | + degreeEnded: [(value) => this.state.currentStep === 2 && isRequired('degreeEnded', value)], | |
99 | + | |
75 | 100 | }} |
76 | 101 | > |
77 | 102 | {({ errors }) => ( | ... | ... |
imports/client/views/org/admin/staff/add/StaffForm.js
... | ... | @@ -20,17 +20,13 @@ const StaffForm = props => ( |
20 | 20 | active: props.currentStep === 0, |
21 | 21 | }, |
22 | 22 | { |
23 | - label: 'Academic', | |
23 | + label: 'Additional Info', | |
24 | 24 | active: props.currentStep === 1, |
25 | 25 | }, |
26 | 26 | { |
27 | - label: 'Address', | |
27 | + label: 'Professional Info', | |
28 | 28 | active: props.currentStep === 2, |
29 | 29 | }, |
30 | - { | |
31 | - label: 'Parent info', | |
32 | - active: props.currentStep === 3, | |
33 | - } | |
34 | 30 | ]} |
35 | 31 | /> |
36 | 32 | {props.currentStep === 0 && ( |
... | ... | @@ -38,16 +34,16 @@ const StaffForm = props => ( |
38 | 34 | <legend className="text-semibold">Personal data</legend> |
39 | 35 | <Row> |
40 | 36 | <Col xs={12} sm={4}> |
41 | - <FormGroup controlId="admissionId"> | |
37 | + <FormGroup controlId="employeeId"> | |
42 | 38 | <Label required>Employee ID</Label> |
43 | 39 | <FormControl |
44 | 40 | type="text" |
45 | - value={props.getValue('admissionId')} | |
46 | - placeholder="admission Id" | |
47 | - onChange={e => props.setValue('admissionId', e.target.value)} | |
41 | + value={props.getValue('employeeId')} | |
42 | + placeholder="employee Id" | |
43 | + onChange={e => props.setValue('employeeId', e.target.value)} | |
48 | 44 | /> |
49 | - {props.isSubmitted() && props.errors && props.errors.admissionId && ( | |
50 | - <ErrorLabel> {props.errors.admissionId} </ErrorLabel> | |
45 | + {props.isSubmitted() && props.errors && props.errors.employeeId && ( | |
46 | + <ErrorLabel> {props.errors.employeeId} </ErrorLabel> | |
51 | 47 | )} |
52 | 48 | </FormGroup> |
53 | 49 | </Col> |
... | ... | @@ -101,14 +97,17 @@ const StaffForm = props => ( |
101 | 97 | </Col> |
102 | 98 | |
103 | 99 | <Col xs={12} sm={4}> |
104 | - <FormGroup controlId="martialStatus"> | |
105 | - <Label required>Martial Status</Label> | |
106 | - <FormControl | |
107 | - type="text" | |
100 | + <FormGroup controlId="formControlsSelect"> | |
101 | + <Label>martialStatus</Label> | |
102 | + <FormControl componentClass="select" | |
103 | + placeholder="select" | |
108 | 104 | value={props.getValue('martialStatus')} |
109 | - placeholder="Martial Status" | |
110 | 105 | onChange={e => props.setValue('martialStatus', e.target.value)} |
111 | - /> | |
106 | + > | |
107 | + <option value="single">Single</option> | |
108 | + <option value="married">Married</option> | |
109 | + <option value="divorced">Divorced</option> | |
110 | + </FormControl> | |
112 | 111 | {props.isSubmitted() && props.errors && props.errors.martialStatus && ( |
113 | 112 | <ErrorLabel> {props.errors.martialStatus} </ErrorLabel> |
114 | 113 | )} |
... | ... | @@ -132,6 +131,11 @@ const StaffForm = props => ( |
132 | 131 | </FormGroup> |
133 | 132 | </Col> |
134 | 133 | </Row> |
134 | + </fieldset> | |
135 | + )} | |
136 | + {props.currentStep === 1 && ( | |
137 | + <fieldset title="Academic"> | |
138 | + <legend className="text-semibold">Additional Info</legend> | |
135 | 139 | <Row> |
136 | 140 | <Col xs={12} sm={4}> |
137 | 141 | <FormGroup controlId="email"> |
... | ... | @@ -147,115 +151,13 @@ const StaffForm = props => ( |
147 | 151 | )} |
148 | 152 | </FormGroup> |
149 | 153 | </Col> |
150 | - | |
151 | - <Col xs={12} sm={4}> | |
152 | - <FormGroup controlId="formControlsSelect"> | |
153 | - <Label>Type</Label> | |
154 | - <FormControl componentClass="select" | |
155 | - placeholder="select" | |
156 | - value={props.getValue('type')} | |
157 | - onChange={e => props.setValue('gender', e.target.value)} | |
158 | - > | |
159 | - <option value="male">Male</option> | |
160 | - <option value="female">Female</option> | |
161 | - </FormControl> | |
162 | - {props.isSubmitted() && props.errors && props.errors.gender && ( | |
163 | - <ErrorLabel> {props.errors.gender} </ErrorLabel> | |
164 | - )} | |
165 | - </FormGroup> | |
166 | - </Col> | |
167 | - | |
168 | - </Row> | |
169 | - <Row> | |
170 | - | |
171 | - </Row> | |
172 | - </fieldset> | |
173 | - )} | |
174 | - {props.currentStep === 1 && ( | |
175 | - <fieldset title="Academic"> | |
176 | - <legend className="text-semibold">Academic</legend> | |
177 | - <Row> | |
178 | - <Col xs={12} sm={4}> | |
179 | - <FormGroup controlId="rollNo"> | |
180 | - <Label required>Roll No</Label> | |
181 | - <FormControl | |
182 | - type="text" | |
183 | - value={props.getValue('rollNo')} | |
184 | - placeholder="Roll No" | |
185 | - onChange={e => props.setValue('rollNo', e.target.value)} | |
186 | - /> | |
187 | - {props.isSubmitted() && props.errors && props.errors.rollNo && ( | |
188 | - <ErrorLabel> {props.errors.rollNo} </ErrorLabel> | |
189 | - )} | |
190 | - </FormGroup> | |
191 | - </Col> | |
192 | - <Col xs={12} sm={4}> | |
193 | - <FormGroup controlId="class"> | |
194 | - <Label required>Class</Label> | |
195 | - <FormControl | |
196 | - type="text" | |
197 | - value={props.getValue('studentClass')} | |
198 | - placeholder="7" | |
199 | - onChange={e => props.setValue('studentClass', e.target.value)} | |
200 | - /> | |
201 | - {props.isSubmitted() && props.errors && props.errors.studentClass && ( | |
202 | - <ErrorLabel> {props.errors.studentClass} </ErrorLabel> | |
203 | - )} | |
204 | - </FormGroup> | |
205 | - </Col> | |
206 | - </Row> | |
207 | - <Row> | |
208 | - <Col xs={12} sm={4}> | |
209 | - <FormGroup controlId="section"> | |
210 | - <Label required>Section</Label> | |
211 | - <FormControl | |
212 | - type="text" | |
213 | - value={props.getValue('section')} | |
214 | - placeholder="B" | |
215 | - onChange={e => props.setValue('section', e.target.value)} | |
216 | - /> | |
217 | - {props.isSubmitted() && props.errors && props.errors.section && ( | |
218 | - <ErrorLabel> {props.errors.section} </ErrorLabel> | |
219 | - )} | |
220 | - </FormGroup> | |
221 | - </Col> | |
222 | - <Col xs={12} sm={4}> | |
223 | - <FormGroup controlId="community"> | |
224 | - <Label required>Community</Label> | |
225 | - <FormControl | |
226 | - type="text" | |
227 | - value={props.getValue('community')} | |
228 | - placeholder="General" | |
229 | - onChange={e => props.setValue('community', e.target.value)} | |
230 | - /> | |
231 | - {props.isSubmitted() && props.errors && props.errors.community && ( | |
232 | - <ErrorLabel> {props.errors.community} </ErrorLabel> | |
233 | - )} | |
234 | - </FormGroup> | |
235 | - </Col> | |
236 | - </Row> | |
237 | - <Row> | |
238 | - <Col xs={12} sm={4}> | |
239 | - <FormGroup controlId="bloodGroup"> | |
240 | - <Label required>bloodGroup</Label> | |
241 | - <FormControl | |
242 | - type="text" | |
243 | - value={props.getValue('bloodGroup')} | |
244 | - placeholder="B+" | |
245 | - onChange={e => props.setValue('bloodGroup', e.target.value)} | |
246 | - /> | |
247 | - {props.isSubmitted() && props.errors && props.errors.bloodGroup && ( | |
248 | - <ErrorLabel> {props.errors.bloodGroup} </ErrorLabel> | |
249 | - )} | |
250 | - </FormGroup> | |
251 | - </Col> | |
252 | 154 | <Col xs={12} sm={4}> |
253 | 155 | <FormGroup controlId="phone"> |
254 | 156 | <Label required>Phone</Label> |
255 | 157 | <FormControl |
256 | 158 | type="text" |
257 | 159 | value={props.getValue('phone')} |
258 | - placeholder="9999999999" | |
160 | + placeholder="Martial Status" | |
259 | 161 | onChange={e => props.setValue('phone', e.target.value)} |
260 | 162 | /> |
261 | 163 | {props.isSubmitted() && props.errors && props.errors.phone && ( |
... | ... | @@ -263,13 +165,6 @@ const StaffForm = props => ( |
263 | 165 | )} |
264 | 166 | </FormGroup> |
265 | 167 | </Col> |
266 | - </Row> | |
267 | - </fieldset> | |
268 | - )} | |
269 | - {props.currentStep === 2 && ( | |
270 | - <fieldset title="Address"> | |
271 | - <legend className="text-semibold">Address</legend> | |
272 | - <Row> | |
273 | 168 | <Col xs={12} sm={4}> |
274 | 169 | <FormGroup controlId="address"> |
275 | 170 | <Label required>Address</Label> |
... | ... | @@ -284,190 +179,136 @@ const StaffForm = props => ( |
284 | 179 | )} |
285 | 180 | </FormGroup> |
286 | 181 | </Col> |
287 | - <Col xs={12} sm={4}> | |
288 | - <FormGroup controlId="city"> | |
289 | - <Label required>City</Label> | |
290 | - <FormControl | |
291 | - type="text" | |
292 | - value={props.getValue('city')} | |
293 | - placeholder="Chennai" | |
294 | - onChange={e => props.setValue('city', e.target.value)} | |
295 | - /> | |
296 | - {props.isSubmitted() && props.errors && props.errors.city && ( | |
297 | - <ErrorLabel> {props.errors.city} </ErrorLabel> | |
298 | - )} | |
299 | - </FormGroup> | |
300 | - </Col> | |
301 | 182 | </Row> |
302 | 183 | <Row> |
303 | 184 | <Col xs={12} sm={4}> |
304 | - <FormGroup controlId="state"> | |
305 | - <Label required>State</Label> | |
306 | - <FormControl | |
307 | - type="text" | |
308 | - value={props.getValue('state')} | |
309 | - placeholder="Tamilnadu" | |
310 | - onChange={e => props.setValue('state', e.target.value)} | |
311 | - /> | |
312 | - {props.isSubmitted() && props.errors && props.errors.state && ( | |
313 | - <ErrorLabel> {props.errors.state} </ErrorLabel> | |
185 | + <FormGroup controlId="formControlsSelect"> | |
186 | + <Label>Teaching Staff?</Label> | |
187 | + <FormControl componentClass="select" | |
188 | + placeholder="select" | |
189 | + value={props.getValue('teaching')} | |
190 | + onChange={e => props.setValue('teaching', e.target.value)} | |
191 | + > | |
192 | + <option value="yes">Yes</option> | |
193 | + <option value="no">No</option> | |
194 | + </FormControl> | |
195 | + {props.isSubmitted() && props.errors && props.errors.teaching && ( | |
196 | + <ErrorLabel> {props.errors.teaching} </ErrorLabel> | |
314 | 197 | )} |
315 | 198 | </FormGroup> |
316 | 199 | </Col> |
317 | - </Row> | |
318 | - </fieldset> | |
319 | - )} | |
320 | - {props.currentStep === 3 && ( | |
321 | - <fieldset title="2"> | |
322 | - <legend className="text-semibold">Parent information</legend> | |
323 | - <Row> | |
324 | 200 | <Col xs={12} sm={4}> |
325 | - <FormGroup controlId="parentName"> | |
326 | - <Label required>Parent Name</Label> | |
327 | - <FormControl | |
328 | - type="text" | |
329 | - value={props.getValue('parentName')} | |
330 | - placeholder="John" | |
331 | - onChange={e => props.setValue('parentName', e.target.value)} | |
332 | - /> | |
333 | - {props.isSubmitted() && props.errors && props.errors.parentName && ( | |
334 | - <ErrorLabel> {props.errors.parentName} </ErrorLabel> | |
201 | + <FormGroup controlId="formControlsSelect"> | |
202 | + <Label>Type</Label> | |
203 | + <FormControl componentClass="select" | |
204 | + placeholder="select" | |
205 | + value={props.getValue('type')} | |
206 | + onChange={e => props.setValue('type', e.target.value)} | |
207 | + > | |
208 | + <option value="permanent">Permanent</option> | |
209 | + <option value="temporary">Temporary</option> | |
210 | + </FormControl> | |
211 | + {props.isSubmitted() && props.errors && props.errors.type && ( | |
212 | + <ErrorLabel> {props.errors.type} </ErrorLabel> | |
335 | 213 | )} |
336 | 214 | </FormGroup> |
337 | 215 | </Col> |
338 | 216 | <Col xs={12} sm={4}> |
339 | - <FormGroup controlId="parentEmail"> | |
340 | - <Label required>Parent Email</Label> | |
341 | - <FormControl | |
342 | - type="text" | |
343 | - value={props.getValue('parentEmail')} | |
344 | - placeholder="john@email.com" | |
345 | - onChange={e => props.setValue('parentEmail', e.target.value)} | |
217 | + <FormGroup> | |
218 | + <Label required>Date of Joining</Label> | |
219 | + <DatePicker | |
220 | + id="doj" | |
221 | + setValue = {props.setValue} | |
222 | + value={props.getValue('doj')} | |
223 | + onChange={(e) => { | |
224 | + props.setValue('doj', e.target.value) | |
225 | + }} | |
346 | 226 | /> |
347 | - {props.isSubmitted() && props.errors && props.errors.parentEmail && ( | |
348 | - <ErrorLabel> {props.errors.parentEmail} </ErrorLabel> | |
227 | + {props.isSubmitted() && props.errors && props.errors.doj && ( | |
228 | + <ErrorLabel> {props.errors.doj} </ErrorLabel> | |
349 | 229 | )} |
350 | 230 | </FormGroup> |
351 | 231 | </Col> |
352 | 232 | </Row> |
233 | + </fieldset> | |
234 | + )} | |
235 | + {props.currentStep === 2 && ( | |
236 | + <fieldset title="Professional Info"> | |
237 | + <legend className="text-semibold">Professional Info</legend> | |
353 | 238 | <Row> |
354 | 239 | <Col xs={12} sm={4}> |
355 | - <FormGroup controlId="relation"> | |
356 | - <Label required>Relation</Label> | |
240 | + <FormGroup controlId="qualifaication"> | |
241 | + <Label required>Qualifaication</Label> | |
357 | 242 | <FormControl |
358 | 243 | type="text" |
359 | - value={props.getValue('relation')} | |
360 | - placeholder="Father" | |
361 | - onChange={e => props.setValue('relation', e.target.value)} | |
244 | + value={props.getValue('qualifaication')} | |
245 | + placeholder="Ex: Phd" | |
246 | + onChange={e => props.setValue('qualifaication', e.target.value)} | |
362 | 247 | /> |
363 | - {props.isSubmitted() && props.errors && props.errors.relation && ( | |
364 | - <ErrorLabel> {props.errors.relation} </ErrorLabel> | |
248 | + {props.isSubmitted() && props.errors && props.errors.qualifaication && ( | |
249 | + <ErrorLabel> {props.errors.qualifaication} </ErrorLabel> | |
365 | 250 | )} |
366 | 251 | </FormGroup> |
367 | 252 | </Col> |
368 | 253 | <Col xs={12} sm={4}> |
369 | - <FormGroup controlId="profession"> | |
370 | - <Label required>Profession</Label> | |
254 | + <FormGroup controlId="specialization"> | |
255 | + <Label required>Specialization</Label> | |
371 | 256 | <FormControl |
372 | 257 | type="text" |
373 | - value={props.getValue('profession')} | |
374 | - placeholder="Farmer" | |
375 | - onChange={e => props.setValue('profession', e.target.value)} | |
258 | + value={props.getValue('specialization')} | |
259 | + placeholder="Ex: Maths" | |
260 | + onChange={e => props.setValue('specialization', e.target.value)} | |
376 | 261 | /> |
377 | - {props.isSubmitted() && props.errors && props.errors.profession && ( | |
378 | - <ErrorLabel> {props.errors.profession} </ErrorLabel> | |
379 | - )} | |
380 | - </FormGroup> | |
381 | - </Col> | |
382 | - </Row> | |
383 | - <Row> | |
384 | - <Col xs={12} sm={4}> | |
385 | - <FormGroup controlId="parentGender"> | |
386 | - <Label>Parent Gender</Label> | |
387 | - <FormControl componentClass="select" | |
388 | - placeholder="select" | |
389 | - value={props.getValue('parentGender')} | |
390 | - onChange={e => props.setValue('parentGender', e.target.value)} | |
391 | - > | |
392 | - <option value="male">Male</option> | |
393 | - <option value="female">Female</option> | |
394 | - </FormControl> | |
395 | - {props.isSubmitted() && props.errors && props.errors.parentGender && ( | |
396 | - <ErrorLabel> {props.errors.parentGender} </ErrorLabel> | |
262 | + {props.isSubmitted() && props.errors && props.errors.specialization && ( | |
263 | + <ErrorLabel> {props.errors.specialization} </ErrorLabel> | |
397 | 264 | )} |
398 | 265 | </FormGroup> |
399 | 266 | </Col> |
400 | 267 | <Col xs={12} sm={4}> |
401 | - <FormGroup controlId="parentPhone"> | |
402 | - <Label required>Parent Phone</Label> | |
268 | + <FormGroup controlId="university"> | |
269 | + <Label required>University</Label> | |
403 | 270 | <FormControl |
404 | 271 | type="text" |
405 | - value={props.getValue('parentPhone')} | |
406 | - placeholder="9876543210" | |
407 | - onChange={e => props.setValue('parentPhone', e.target.value)} | |
272 | + value={props.getValue('university')} | |
273 | + placeholder="Ex: Pune University" | |
274 | + onChange={e => props.setValue('university', e.target.value)} | |
408 | 275 | /> |
409 | - {props.isSubmitted() && props.errors && props.errors.parentPhone && ( | |
410 | - <ErrorLabel> {props.errors.parentPhone} </ErrorLabel> | |
276 | + {props.isSubmitted() && props.errors && props.errors.university && ( | |
277 | + <ErrorLabel> {props.errors.university} </ErrorLabel> | |
411 | 278 | )} |
412 | 279 | </FormGroup> |
413 | 280 | </Col> |
414 | 281 | </Row> |
415 | 282 | <Row> |
416 | 283 | <Col xs={12} sm={4}> |
417 | - <FormGroup controlId="parentAddress"> | |
418 | - <Label required>Parent Address</Label> | |
419 | - <FormControl | |
420 | - type="text" | |
421 | - value={props.getValue('parentAddress')} | |
422 | - placeholder="#12, street, town" | |
423 | - onChange={e => props.setValue('parentAddress', e.target.value)} | |
424 | - /> | |
425 | - {props.isSubmitted() && props.errors && props.errors.parentAddress && ( | |
426 | - <ErrorLabel> {props.errors.parentAddress} </ErrorLabel> | |
427 | - )} | |
428 | - </FormGroup> | |
429 | - </Col> | |
430 | - <Col xs={12} sm={4}> | |
431 | - <FormGroup controlId="parentCity"> | |
432 | - <Label required>Parent City</Label> | |
433 | - <FormControl | |
434 | - type="text" | |
435 | - value={props.getValue('parentCity')} | |
436 | - placeholder="Chennai" | |
437 | - onChange={e => props.setValue('parentCity', e.target.value)} | |
284 | + <FormGroup> | |
285 | + <Label required>Latest Degree started At</Label> | |
286 | + <DatePicker | |
287 | + id="degreeFrom" | |
288 | + setValue = {props.setValue} | |
289 | + value={props.getValue('degreeFrom')} | |
290 | + onChange={(e) => { | |
291 | + props.setValue('degreeFrom', e.target.value) | |
292 | + }} | |
438 | 293 | /> |
439 | - {props.isSubmitted() && props.errors && props.errors.parentCity && ( | |
440 | - <ErrorLabel> {props.errors.parentCity} </ErrorLabel> | |
294 | + {props.isSubmitted() && props.errors && props.errors.degreeFrom && ( | |
295 | + <ErrorLabel> {props.errors.degreeFrom} </ErrorLabel> | |
441 | 296 | )} |
442 | 297 | </FormGroup> |
443 | 298 | </Col> |
444 | - </Row> | |
445 | - <Row> | |
446 | - <Col xs={12} sm={4}> | |
447 | - <FormGroup controlId="parentState"> | |
448 | - <Label required>Parent State</Label> | |
449 | - <FormControl | |
450 | - type="text" | |
451 | - value={props.getValue('parentState')} | |
452 | - placeholder="600031" | |
453 | - onChange={e => props.setValue('parentState', e.target.value)} | |
454 | - /> | |
455 | - {props.isSubmitted() && props.errors && props.errors.parentState && ( | |
456 | - <ErrorLabel> {props.errors.parentState} </ErrorLabel> | |
457 | - )} | |
458 | - </FormGroup> | |
459 | - </Col> | |
460 | 299 | <Col xs={12} sm={4}> |
461 | - <FormGroup controlId="parentZipcode"> | |
462 | - <Label required>Parent Zipcode</Label> | |
463 | - <FormControl | |
464 | - type="text" | |
465 | - value={props.getValue('parentZipcode')} | |
466 | - placeholder="600031" | |
467 | - onChange={e => props.setValue('parentZipcode', e.target.value)} | |
300 | + <FormGroup> | |
301 | + <Label required>Latest Degree ended At</Label> | |
302 | + <DatePicker | |
303 | + id="degreeEnded" | |
304 | + setValue = {props.setValue} | |
305 | + value={props.getValue('degreeEnded')} | |
306 | + onChange={(e) => { | |
307 | + props.setValue('degreeEnded', e.target.value) | |
308 | + }} | |
468 | 309 | /> |
469 | - {props.isSubmitted() && props.errors && props.errors.parentZipcode && ( | |
470 | - <ErrorLabel> {props.errors.parentZipcode} </ErrorLabel> | |
310 | + {props.isSubmitted() && props.errors && props.errors.degreeEnded && ( | |
311 | + <ErrorLabel> {props.errors.degreeEnded} </ErrorLabel> | |
471 | 312 | )} |
472 | 313 | </FormGroup> |
473 | 314 | </Col> |
... | ... | @@ -484,7 +325,7 @@ const StaffForm = props => ( |
484 | 325 | |
485 | 326 | </div> |
486 | 327 | )} |
487 | - {props.currentStep < 3 && ( | |
328 | + {props.currentStep < 2 && ( | |
488 | 329 | <div style={{ display: 'inline-block' }}> |
489 | 330 | <Button |
490 | 331 | bsStyle="primary" |
... | ... | @@ -495,7 +336,7 @@ const StaffForm = props => ( |
495 | 336 | </Button> |
496 | 337 | </div> |
497 | 338 | )} |
498 | - {props.currentStep === 3 && ( | |
339 | + {props.currentStep === 2 && ( | |
499 | 340 | <div style={{ display: 'inline-block' }}> |
500 | 341 | <Button |
501 | 342 | bsStyle="primary" | ... | ... |
imports/client/views/org/admin/staff/index.js
... | ... | @@ -16,18 +16,23 @@ const meteorTick = (props, onData) => { |
16 | 16 | |
17 | 17 | const handles = [ |
18 | 18 | Meteor.subscribe('users.current'), |
19 | - Meteor.subscribe('orgs.current') | |
19 | + Meteor.subscribe('orgs.current'), | |
20 | + Meteor.subscribe('users.forMyOrg'), | |
21 | + Meteor.subscribe('staff.forMyOrg'), | |
20 | 22 | ]; |
21 | 23 | |
22 | 24 | if(_.every(handles, (handle) => (handle.ready()) )) { |
23 | 25 | const user = Users.current(); |
24 | 26 | const org = Orgs.current(); |
25 | - staff = Users.find({"role":"STAFF"}).fetch() ? Users.find({"role":"TEACHER"}).fetch() : ""; | |
27 | + staff = Users.find({"role":"STAFF"}).fetch() ? Users.find({"role":"STAFF"}).fetch() : ""; | |
28 | + console.log(Users.find({"role":"STAFF"}).fetch()); | |
26 | 29 | staffData = Staffs.find().fetch() ? Staffs.find().fetch() : ""; |
30 | + console.log("staffData"); | |
31 | + console.log(staffData); | |
27 | 32 | for(var i=0; i< staff.length; i++){ |
28 | - for(var j=0; j< staff.length; j++){ | |
33 | + for(var j=0; j< staffData.length; j++){ | |
29 | 34 | if(staff[i]._id == staffData[j].userId){ |
30 | - staff[i].class = staffData[j].class; | |
35 | + staff[i].type = staffData[j].type; | |
31 | 36 | staff[i].dob = staffData[j].dob; |
32 | 37 | } |
33 | 38 | } | ... | ... |
imports/client/views/org/admin/staff/view/StaffRow.js
... | ... | @@ -0,0 +1,56 @@ |
1 | +import _ from 'lodash'; | |
2 | +import { Meteor } from 'meteor/meteor'; | |
3 | + | |
4 | +import React, { Component } from 'react'; | |
5 | +import { Link,browserHistory } from 'react-router'; | |
6 | +import { FormGroup, | |
7 | + FormControl,Glyphicon,Button } from 'react-bootstrap'; | |
8 | + | |
9 | + | |
10 | +export class StaffRow extends Component { | |
11 | + | |
12 | + constructor(props) { | |
13 | + super(props); | |
14 | + this.state = { | |
15 | + | |
16 | + }; | |
17 | + this.onUpdate = this.onUpdate.bind(this); | |
18 | + }; | |
19 | + | |
20 | + onUpdate(key, value) { | |
21 | + this.setState({[key]: value}); | |
22 | + }; | |
23 | + | |
24 | + render() { | |
25 | + const {staff} = this.props; | |
26 | + if(staff.firstName){ | |
27 | + return ( | |
28 | + <tr> | |
29 | + <td>{staff.firstName}</td> | |
30 | + <td>{staff.lastName}</td> | |
31 | + <td>{staff.type}</td> | |
32 | + <td>{staff.dob? moment(staff.dob).format("LL") : <span></span>}</td> | |
33 | + <td><span className="label label-success">Active</span></td> | |
34 | + <td className="text-center"> | |
35 | + <ul className="icons-list"> | |
36 | + <li className="dropdown"> | |
37 | + <a href="#" className="dropdown-toggle" data-toggle="dropdown"> | |
38 | + <i className="icon-menu9"></i> | |
39 | + </a> | |
40 | + <ul className="dropdown-menu dropdown-menu-right"> | |
41 | + <li><a href="#"><i className="icon-file-pdf"></i> Export to .pdf</a></li> | |
42 | + <li><a href="#"><i className="icon-file-excel"></i> Export to .csv</a></li> | |
43 | + <li><a href="#"><i className="icon-file-word"></i> Export to .doc</a></li> | |
44 | + </ul> | |
45 | + </li> | |
46 | + </ul> | |
47 | + </td> | |
48 | + </tr> | |
49 | + ); | |
50 | + }else { | |
51 | + return null; | |
52 | + } | |
53 | + | |
54 | + }; | |
55 | + | |
56 | +}; | ... | ... |
imports/client/views/org/admin/staff/view/StaffTable.js
... | ... | @@ -7,7 +7,7 @@ import { FormGroup,Panel,Table, |
7 | 7 | ButtonToolbar,Modal, |
8 | 8 | FormControl,Glyphicon,Button } from 'react-bootstrap'; |
9 | 9 | import {moment} from 'meteor/momentjs:moment' |
10 | -import {TeachersRow} from './TeachersRow' | |
10 | +import {StaffRow} from './StaffRow' | |
11 | 11 | |
12 | 12 | export class StaffTable extends Component { |
13 | 13 | |
... | ... | @@ -39,7 +39,7 @@ export class StaffTable extends Component { |
39 | 39 | <tr> |
40 | 40 | <th>First Name</th> |
41 | 41 | <th>Last Name</th> |
42 | - <th>Class</th> | |
42 | + <th>Type</th> | |
43 | 43 | <th>DOB</th> |
44 | 44 | <th>Status</th> |
45 | 45 | <th className="text-center">Actions</th> |
... | ... | @@ -47,11 +47,12 @@ export class StaffTable extends Component { |
47 | 47 | </thead> |
48 | 48 | <tbody> |
49 | 49 | { |
50 | - this.props.staff.map(function(student, i) | |
50 | + this.props.staff.map(function(staff, i) | |
51 | 51 | { |
52 | 52 | return( |
53 | - <TeachersRow | |
54 | - teacher = {teacher} | |
53 | + <StaffRow | |
54 | + key = {i} | |
55 | + staff = {staff} | |
55 | 56 | /> |
56 | 57 | ) |
57 | 58 | }) | ... | ... |
imports/client/views/org/admin/staff/view/TeachersRow.js
... | ... | @@ -1,56 +0,0 @@ |
1 | -import _ from 'lodash'; | |
2 | -import { Meteor } from 'meteor/meteor'; | |
3 | - | |
4 | -import React, { Component } from 'react'; | |
5 | -import { Link,browserHistory } from 'react-router'; | |
6 | -import { FormGroup, | |
7 | - FormControl,Glyphicon,Button } from 'react-bootstrap'; | |
8 | - | |
9 | - | |
10 | -export class teachersRow extends Component { | |
11 | - | |
12 | - constructor(props) { | |
13 | - super(props); | |
14 | - this.state = { | |
15 | - | |
16 | - }; | |
17 | - this.onUpdate = this.onUpdate.bind(this); | |
18 | - }; | |
19 | - | |
20 | - onUpdate(key, value) { | |
21 | - this.setState({[key]: value}); | |
22 | - }; | |
23 | - | |
24 | - render() { | |
25 | - const {student} = this.props; | |
26 | - if(student.firstName){ | |
27 | - return ( | |
28 | - <tr> | |
29 | - <td>{student.firstName}</td> | |
30 | - <td>{student.lastName}</td> | |
31 | - <td>{student.class}</td> | |
32 | - <td>{student.dob? moment(student.dob).format("LL") : <span></span>}</td> | |
33 | - <td><span className="label label-success">Active</span></td> | |
34 | - <td className="text-center"> | |
35 | - <ul className="icons-list"> | |
36 | - <li className="dropdown"> | |
37 | - <a href="#" className="dropdown-toggle" data-toggle="dropdown"> | |
38 | - <i className="icon-menu9"></i> | |
39 | - </a> | |
40 | - <ul className="dropdown-menu dropdown-menu-right"> | |
41 | - <li><a href="#"><i className="icon-file-pdf"></i> Export to .pdf</a></li> | |
42 | - <li><a href="#"><i className="icon-file-excel"></i> Export to .csv</a></li> | |
43 | - <li><a href="#"><i className="icon-file-word"></i> Export to .doc</a></li> | |
44 | - </ul> | |
45 | - </li> | |
46 | - </ul> | |
47 | - </td> | |
48 | - </tr> | |
49 | - ); | |
50 | - }else { | |
51 | - return null; | |
52 | - } | |
53 | - | |
54 | - }; | |
55 | - | |
56 | -}; |
imports/client/views/org/admin/students/add/AddStudentFormContainer.js
imports/collections/staff/index.js
... | ... | @@ -63,8 +63,17 @@ Staffs.deny({ |
63 | 63 | Staffs.schema = new SimpleSchema({ |
64 | 64 | userId: { type: String }, |
65 | 65 | orgId: { type: String }, |
66 | + employeeId: { type: String }, | |
67 | + martialStatus: { type: String }, | |
68 | + dob: { type: String }, | |
69 | + teaching: { type: String }, | |
66 | 70 | type: { type: String }, |
67 | 71 | gender: { type: String, optional: true }, |
72 | + qualifaication: { type: String, optional: true }, | |
73 | + specialization: { type: String, optional: true }, | |
74 | + university: { type: String, optional: true }, | |
75 | + degreeFrom: { type: String, optional: true }, | |
76 | + degreeEnded: { type: String, optional: true }, | |
68 | 77 | services: { |
69 | 78 | type: Object, |
70 | 79 | optional: true, |
... | ... | @@ -81,7 +90,6 @@ Staffs.attachSchema(Staffs.schema); |
81 | 90 | |
82 | 91 | Staffs.privateFields = { |
83 | 92 | orgId: 1, |
84 | - address: 1, | |
85 | 93 | |
86 | 94 | isMetaUser: 1, |
87 | 95 | createdAt: 1, | ... | ... |
imports/collections/staff/methods.js
... | ... | @@ -6,10 +6,10 @@ import { SimpleSchema } from 'meteor/aldeed:simple-schema'; |
6 | 6 | import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; |
7 | 7 | import { Bert } from 'meteor/themeteorchef:bert'; |
8 | 8 | import { Users } from '/imports/collections/users/index'; |
9 | -import { Teachers } from '/imports/collections/staff/index'; | |
9 | +import { Staffs } from '/imports/collections/staff/index'; | |
10 | 10 | import { Orgs } from '/imports/collections/orgs/index'; |
11 | -export const teachersMethods = new ValidatedMethod({ | |
12 | - name: 'teachers.method', | |
11 | +export const staffMethods = new ValidatedMethod({ | |
12 | + name: 'staff.method', | |
13 | 13 | |
14 | 14 | validate: new SimpleSchema({ |
15 | 15 | itemId: { type: String }, |
... | ... | @@ -20,3 +20,68 @@ export const teachersMethods = new ValidatedMethod({ |
20 | 20 | }, |
21 | 21 | |
22 | 22 | }); |
23 | + | |
24 | +export const staffAddNew = new ValidatedMethod({ | |
25 | + name: 'staff.addNew', | |
26 | + | |
27 | + validate: new SimpleSchema({ | |
28 | + employeeId: { type: String }, | |
29 | + firstName: { type: String }, | |
30 | + lastName: { type: String }, | |
31 | + martialStatus: { type: String }, | |
32 | + gender: { type: String }, | |
33 | + dob: { type: String }, | |
34 | + email: { type: String }, | |
35 | + phone: { type: String }, | |
36 | + address: { type: String }, | |
37 | + type: { type: String }, | |
38 | + doj: { type: String }, | |
39 | + teaching: { type: String }, | |
40 | + qualifaication: { type: String }, | |
41 | + specialization: { type: String }, | |
42 | + university: { type: String }, | |
43 | + degreeFrom: { type: String }, | |
44 | + degreeEnded: { type: String }, | |
45 | + }).validator(), | |
46 | + | |
47 | + run(data) { | |
48 | + const user = Users.findOne({_id: Meteor.userId()}); | |
49 | + if(!user) return false; | |
50 | + const org = Orgs.findOne({_id: user.orgId}); | |
51 | + if(!org) return false; | |
52 | + // console.log(data);return true; | |
53 | + orgId = user.orgId; | |
54 | + newUserId = Users.insert({ | |
55 | + emails: [{address:data.email, verified: false}], | |
56 | + phones: [{number:data.phone, verified: false}], | |
57 | + firstName: data.firstName, | |
58 | + lastName: data.lastName, | |
59 | + address: data.address, | |
60 | + orgId: orgId, | |
61 | + role: 'STAFF' | |
62 | + }); | |
63 | + console.log("newUserId"); | |
64 | + console.log(newUserId); | |
65 | + if(newUserId){ | |
66 | + newStaffId = Staffs.insert({ | |
67 | + userId: newUserId, | |
68 | + orgId: orgId, | |
69 | + employeeId: data.employeeId, | |
70 | + martialStatus:data.martialStatus, | |
71 | + gender: data.gender, | |
72 | + dob: data.dob, | |
73 | + teaching: data.teaching, | |
74 | + type: data.type, | |
75 | + qualifaication: data.qualifaication, | |
76 | + specialization: data.specialization, | |
77 | + university: data.university, | |
78 | + degreeFrom: data.degreeFrom, | |
79 | + degreeEnded: data.degreeEnded | |
80 | + }); | |
81 | + } | |
82 | + console.log("newStaffId"); | |
83 | + console.log(newStaffId); | |
84 | + return {}; | |
85 | + }, | |
86 | + | |
87 | +}); | ... | ... |
imports/collections/staff/publications.js
... | ... | @@ -3,10 +3,10 @@ import { check, Match } from 'meteor/check' |
3 | 3 | |
4 | 4 | import { Orgs } from '/imports/collections/orgs/index'; |
5 | 5 | import { Users } from '/imports/collections/users/index'; |
6 | -import { Teachers } from '/imports/collections/staff/index'; | |
6 | +import { Staffs } from '/imports/collections/staff/index'; | |
7 | 7 | |
8 | -Meteor.publish('teachers.forMyOrg', function () { | |
8 | +Meteor.publish('staff.forMyOrg', function () { | |
9 | 9 | const user = Users.findOne({_id: this.userId}); |
10 | 10 | if(!user) return []; |
11 | - return Teachers.find({orgId: user.orgId}); | |
11 | + return Staffs.find({orgId: user.orgId}); | |
12 | 12 | }); | ... | ... |
imports/collections/staff/serverCsvUpload.js
... | ... | @@ -11,7 +11,7 @@ import { Users } from '/imports/collections/users/index |
11 | 11 | import { Orgs } from '/imports/collections/orgs/index'; |
12 | 12 | import { Students } from '/imports/collections/students/index' |
13 | 13 | import { Parents } from '/imports/collections/parents/index'; |
14 | -import { Staffs } from '/imports/collections/staff/index'; | |
14 | +import { Staffs } from '/imports/collections/staff/index'; | |
15 | 15 | import csv1 from 'csv2json-convertor' |
16 | 16 | import json2csv from 'json2csv' |
17 | 17 | import fs from 'fs' | ... | ... |
imports/collections/users/index.js
... | ... | @@ -115,6 +115,7 @@ Users.schema = new SimpleSchema({ |
115 | 115 | firstName: { type: String, optional: true }, |
116 | 116 | middlename: { type: String, optional: true }, |
117 | 117 | lastName: { type: String, optional: true }, |
118 | + address: { type: String, optional: true, }, | |
118 | 119 | gender: { type: String, optional: true }, |
119 | 120 | dob: { type: String, optional: true }, |
120 | 121 | emails: { |
... | ... | @@ -126,8 +127,8 @@ Users.schema = new SimpleSchema({ |
126 | 127 | }, |
127 | 128 | phones: { |
128 | 129 | type: [new SimpleSchema({ |
129 | - country: { type: String, }, | |
130 | - prefix: { type: String, }, | |
130 | + country: { type: String, optional: true }, | |
131 | + prefix: { type: String, optional: true }, | |
131 | 132 | number: { type: String, }, |
132 | 133 | verified: { type: Boolean, }, |
133 | 134 | })], | ... | ... |
imports/collections/users/publications.js