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
1 | import React, { Component, PropTypes } from 'react' | 1 | import React, { Component, PropTypes } from 'react' |
2 | import $ from 'jquery' | 2 | import $ from 'jquery' |
3 | import 'jquery-ui/ui/widgets/datepicker' | 3 | import 'jquery-ui/ui/widgets/datepicker' |
4 | 4 | ||
5 | class DatePicker extends Component { | 5 | class DatePicker extends Component { |
6 | componentDidMount() { | 6 | componentDidMount() { |
7 | SELF = this; | 7 | SELF = this; |
8 | $('.datepicker').datepicker({ | 8 | $('.datepicker').datepicker({ |
9 | changeMonth: true, | 9 | changeMonth: true, |
10 | changeYear: true, | 10 | changeYear: true, |
11 | showButtonPanel: true, | 11 | showButtonPanel: true, |
12 | yearRange: '-25:-1', | 12 | yearRange: '-35:-1', |
13 | dateFormat: 'dd/mm/yy', | 13 | dateFormat: 'dd/mm/yy', |
14 | onSelect: function(dateText, inst) { | 14 | onSelect: function(dateText, inst) { |
15 | var date = $(this).val(); | 15 | var date = $(this).val(); |
16 | // $("#datepickerDOB").val(date); | 16 | // $("#datepickerDOB").val(date); |
17 | SELF.props.setValue('dob',date); | 17 | SELF.props.setValue('dob',date); |
18 | } | 18 | } |
19 | }); | 19 | }); |
20 | } | 20 | } |
21 | 21 | ||
22 | render() { | 22 | render() { |
23 | return ( | 23 | return ( |
24 | <input | 24 | <input |
25 | id="datepickerDOB" | 25 | id="datepickerDOB" |
26 | type="text" | 26 | type="text" |
27 | className="datepicker form-control" | 27 | className="datepicker form-control" |
28 | placeholder="DD-MM-YYYY" | 28 | placeholder="DD-MM-YYYY" |
29 | onChange={this.props.onChange} | 29 | onChange={this.props.onChange} |
30 | value={this.props.value} | 30 | value={this.props.value} |
31 | /> | 31 | /> |
32 | ) | 32 | ) |
33 | } | 33 | } |
34 | } | 34 | } |
35 | 35 | ||
36 | DatePicker.propTypes = { | 36 | DatePicker.propTypes = { |
37 | value: PropTypes.string.isRequired, | 37 | value: PropTypes.string.isRequired, |
38 | onChange: PropTypes.func.isRequired, | 38 | onChange: PropTypes.func.isRequired, |
39 | } | 39 | } |
40 | 40 | ||
41 | export default DatePicker | 41 | export default DatePicker |
42 | 42 |
imports/client/views/org/admin/staff/add/AddStaffFormContainer.js
1 | import React, { Component } from 'react' | 1 | import React, { Component } from 'react' |
2 | import StaffForm from './StaffForm' | 2 | import StaffForm from './StaffForm' |
3 | import Form from '/imports/client/views/core/Form' | 3 | import Form from '/imports/client/views/core/Form' |
4 | import Validator from '/imports/client/views/core/Validator' | 4 | import Validator from '/imports/client/views/core/Validator' |
5 | import { isRequired, isValidEmail } from '/imports/client/views/core/validations' | 5 | import { isRequired, isValidEmail } from '/imports/client/views/core/validations' |
6 | import { addStudentManually } from '/imports/collections/students/methods'; | ||
6 | 7 | ||
7 | export class AddStaffFormContainer extends Component { | 8 | export class AddStaffFormContainer extends Component { |
8 | 9 | ||
9 | constructor(props) { | 10 | constructor(props) { |
10 | super(props) | 11 | super(props) |
11 | this.state = { currentStep: 0 } | 12 | this.state = { currentStep: 0 } |
12 | this.handleNextClick = this.handleNextClick.bind(this) | 13 | this.handleNextClick = this.handleNextClick.bind(this) |
13 | this.handleBackClick = this.handleBackClick.bind(this) | 14 | this.handleBackClick = this.handleBackClick.bind(this) |
14 | this.handleSubmit = this.handleSubmit.bind(this) | 15 | this.handleSubmit = this.handleSubmit.bind(this) |
15 | } | 16 | } |
16 | 17 | ||
17 | handleNextClick() { | 18 | handleNextClick() { |
19 | console.log("clicked"); | ||
18 | this.form.handleSubmit() | 20 | this.form.handleSubmit() |
19 | if (this.validator.getErrors() && Object.keys(this.validator.getErrors()).length > 0) return | 21 | if (this.validator.getErrors() && Object.keys(this.validator.getErrors()).length > 0) return |
22 | console.log("after submit"); | ||
20 | this.setState({ currentStep: this.state.currentStep + 1 }) | 23 | this.setState({ currentStep: this.state.currentStep + 1 }) |
21 | this.form.resetSubmitted() | 24 | this.form.resetSubmitted() |
22 | } | 25 | } |
23 | 26 | ||
24 | handleBackClick() { | 27 | handleBackClick() { |
25 | this.setState({ currentStep: this.state.currentStep + -1 }) | 28 | this.setState({ currentStep: this.state.currentStep + -1 }) |
26 | } | 29 | } |
27 | 30 | ||
28 | handleSubmit() { | 31 | handleSubmit() { |
29 | if (this.state.currentStep === 3) { | 32 | if (this.state.currentStep === 2) { |
30 | addStudentManually.call(this.form.state.values) | 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 | ||
34 | //render callback | 41 | //render callback |
35 | render() { | 42 | render() { |
36 | return ( | 43 | return ( |
37 | <Form | 44 | <Form |
38 | onSubmit={this.handleSubmit} | 45 | onSubmit={this.handleSubmit} |
39 | ref={form => this.form = form} | 46 | ref={form => this.form = form} |
40 | initialValues={{ | 47 | initialValues={{ |
41 | gender: 'male', | 48 | employeeId: '12345', |
42 | parentGender: 'male', | 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 | {({ values, setValue, getValue, isSubmitted, isDirty }) => ( | 72 | {({ values, setValue, getValue, isSubmitted, isDirty }) => ( |
46 | <Validator | 73 | <Validator |
47 | values={values} | 74 | values={values} |
48 | ref={validator => this.validator = validator} | 75 | ref={validator => this.validator = validator} |
49 | validations={{ | 76 | validations={{ |
50 | admissionId: [(value) => isRequired('Admission id', value)], | 77 | employeeId: [(value) => isRequired('Admission id', value)], |
51 | firstName: [(value) => isRequired('First name', value)], | 78 | firstName: [(value) => isRequired('First name', value)], |
52 | lastName: [(value) => isRequired('Last name', value)], | 79 | lastName: [(value) => isRequired('Last name', value)], |
53 | email: [(value) => isRequired('Email', value), isValidEmail], | 80 | |
54 | dob: [(value) => isRequired('Date of birth', value)], | 81 | gender: [(value) => isRequired('Gender', value)], |
55 | gender: [(value) => isRequired('Gender', value)], | 82 | martialStatus: [(value) => isRequired('martialStatus', value)], |
56 | rollNo: [(value) => this.state.currentStep === 1 && isRequired('Roll no', value)], | 83 | dob: [(value) => isRequired('Date of birth', value)], |
57 | studentClass: [(value) => this.state.currentStep === 1 && isRequired('Class', value)], | 84 | |
58 | section: [(value) => this.state.currentStep === 1 && isRequired('Section', value)], | 85 | email: [(value) => this.state.currentStep === 1 && isRequired('Email', value), (value) => this.state.currentStep === 1 && isValidEmail(value)], |
59 | community: [(value) => this.state.currentStep === 1 && isRequired('Community', value)], | 86 | phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], |
60 | bloodGroup: [(value) => this.state.currentStep === 1 && isRequired('Blood group', value)], | 87 | address: [(value) => this.state.currentStep === 1 && isRequired('Address', value)], |
61 | phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], | 88 | |
62 | address: [(value) => this.state.currentStep === 2 && isRequired('Address', value)], | 89 | teaching: [(value) => this.state.currentStep === 1 && isRequired('teaching', value)], |
63 | city: [(value) => this.state.currentStep === 2 && isRequired('City', value)], | 90 | type: [(value) => this.state.currentStep === 1 && isRequired('type', value)], |
64 | state: [(value) => this.state.currentStep === 2 && isRequired('State', value)], | 91 | doj: [(value) => this.state.currentStep === 1 && isRequired('doj', value)], |
65 | parentName: [(value) => this.state.currentStep === 3 && isRequired('Parent name', value)], | 92 | |
66 | parentEmail: [(value) => this.state.currentStep === 3 && isRequired('Parent email', value), (value) => this.state.currentStep === 3 && isValidEmail(value)], | 93 | qualifaication: [(value) => this.state.currentStep === 2 && isRequired('qualifaication', value)], |
67 | relation: [(value) => this.state.currentStep === 3 && isRequired('Relation', value)], | 94 | specialization: [(value) => this.state.currentStep === 2 && isRequired('specialization', value)], |
68 | profession: [(value) => this.state.currentStep === 3 && isRequired('Profession', value)], | 95 | university: [(value) => this.state.currentStep === 2 && isRequired('university', value)], |
69 | parentGender: [(value) => this.state.currentStep === 3 && isRequired('Parent gender', value)], | 96 | |
70 | parentPhone: [(value) => this.state.currentStep === 3 && isRequired('Parent phone', value)], | 97 | degreeFrom: [(value) => this.state.currentStep === 2 && isRequired('degreeFrom', value)], |
71 | parentAddress: [(value) => this.state.currentStep === 3 && isRequired('Parent address', value)], | 98 | degreeEnded: [(value) => this.state.currentStep === 2 && isRequired('degreeEnded', value)], |
72 | parentCity: [(value) => this.state.currentStep === 3 && isRequired('Parent city', value)], | 99 | |
73 | parentState: [(value) => this.state.currentStep === 3 && isRequired('Parent state', value)], | ||
74 | parentZipcode: [(value) => this.state.currentStep === 3 && isRequired('Parent zip code', value)], | ||
75 | }} | 100 | }} |
76 | > | 101 | > |
77 | {({ errors }) => ( | 102 | {({ errors }) => ( |
78 | <StaffForm | 103 | <StaffForm |
79 | isDirty={isDirty} | 104 | isDirty={isDirty} |
80 | setValue={setValue} | 105 | setValue={setValue} |
81 | getValue={getValue} | 106 | getValue={getValue} |
82 | isSubmitted={isSubmitted} | 107 | isSubmitted={isSubmitted} |
83 | errors={errors} | 108 | errors={errors} |
84 | onNextClick={this.handleNextClick} | 109 | onNextClick={this.handleNextClick} |
85 | onBackClick={this.handleBackClick} | 110 | onBackClick={this.handleBackClick} |
86 | currentStep={this.state.currentStep} | 111 | currentStep={this.state.currentStep} |
87 | /> | 112 | /> |
88 | )} | 113 | )} |
89 | </Validator> | 114 | </Validator> |
90 | )} | 115 | )} |
91 | </Form> | 116 | </Form> |
92 | ) | 117 | ) |
93 | } | 118 | } |
imports/client/views/org/admin/staff/add/StaffForm.js
1 | import React, { PropTypes } from 'react' | 1 | import React, { PropTypes } from 'react' |
2 | import { | 2 | import { |
3 | Row, | 3 | Row, |
4 | Col, | 4 | Col, |
5 | FormGroup, | 5 | FormGroup, |
6 | FormControl, | 6 | FormControl, |
7 | Button | 7 | Button |
8 | } from 'react-bootstrap' | 8 | } from 'react-bootstrap' |
9 | import DatePicker from '/imports/client/views/core/DatePicker' | 9 | import DatePicker from '/imports/client/views/core/DatePicker' |
10 | import Label from '/imports/client/views/core/Label' | 10 | import Label from '/imports/client/views/core/Label' |
11 | import Stepper from '/imports/client/views/core/Stepper' | 11 | import Stepper from '/imports/client/views/core/Stepper' |
12 | import ErrorLabel from '/imports/client/views/core/ErrorLabel' | 12 | import ErrorLabel from '/imports/client/views/core/ErrorLabel' |
13 | 13 | ||
14 | const StaffForm = props => ( | 14 | const StaffForm = props => ( |
15 | <div className="stepy-validation"> | 15 | <div className="stepy-validation"> |
16 | <Stepper | 16 | <Stepper |
17 | steps={[ | 17 | steps={[ |
18 | { | 18 | { |
19 | label: 'Personal data', | 19 | label: 'Personal data', |
20 | active: props.currentStep === 0, | 20 | active: props.currentStep === 0, |
21 | }, | 21 | }, |
22 | { | 22 | { |
23 | label: 'Academic', | 23 | label: 'Additional Info', |
24 | active: props.currentStep === 1, | 24 | active: props.currentStep === 1, |
25 | }, | 25 | }, |
26 | { | 26 | { |
27 | label: 'Address', | 27 | label: 'Professional Info', |
28 | active: props.currentStep === 2, | 28 | active: props.currentStep === 2, |
29 | }, | 29 | }, |
30 | { | ||
31 | label: 'Parent info', | ||
32 | active: props.currentStep === 3, | ||
33 | } | ||
34 | ]} | 30 | ]} |
35 | /> | 31 | /> |
36 | {props.currentStep === 0 && ( | 32 | {props.currentStep === 0 && ( |
37 | <fieldset title="1"> | 33 | <fieldset title="1"> |
38 | <legend className="text-semibold">Personal data</legend> | 34 | <legend className="text-semibold">Personal data</legend> |
39 | <Row> | 35 | <Row> |
40 | <Col xs={12} sm={4}> | 36 | <Col xs={12} sm={4}> |
41 | <FormGroup controlId="admissionId"> | 37 | <FormGroup controlId="employeeId"> |
42 | <Label required>Employee ID</Label> | 38 | <Label required>Employee ID</Label> |
43 | <FormControl | 39 | <FormControl |
44 | type="text" | 40 | type="text" |
45 | value={props.getValue('admissionId')} | 41 | value={props.getValue('employeeId')} |
46 | placeholder="admission Id" | 42 | placeholder="employee Id" |
47 | onChange={e => props.setValue('admissionId', e.target.value)} | 43 | onChange={e => props.setValue('employeeId', e.target.value)} |
48 | /> | 44 | /> |
49 | {props.isSubmitted() && props.errors && props.errors.admissionId && ( | 45 | {props.isSubmitted() && props.errors && props.errors.employeeId && ( |
50 | <ErrorLabel> {props.errors.admissionId} </ErrorLabel> | 46 | <ErrorLabel> {props.errors.employeeId} </ErrorLabel> |
51 | )} | 47 | )} |
52 | </FormGroup> | 48 | </FormGroup> |
53 | </Col> | 49 | </Col> |
54 | 50 | ||
55 | <Col xs={12} sm={4}> | 51 | <Col xs={12} sm={4}> |
56 | <FormGroup controlId="firstName"> | 52 | <FormGroup controlId="firstName"> |
57 | <Label required>First Name</Label> | 53 | <Label required>First Name</Label> |
58 | <FormControl | 54 | <FormControl |
59 | type="text" | 55 | type="text" |
60 | value={props.getValue('firstName')} | 56 | value={props.getValue('firstName')} |
61 | placeholder="First Name" | 57 | placeholder="First Name" |
62 | onChange={e => props.setValue('firstName', e.target.value)} | 58 | onChange={e => props.setValue('firstName', e.target.value)} |
63 | /> | 59 | /> |
64 | {props.isSubmitted() && props.errors && props.errors.firstName && ( | 60 | {props.isSubmitted() && props.errors && props.errors.firstName && ( |
65 | <ErrorLabel> {props.errors.firstName} </ErrorLabel> | 61 | <ErrorLabel> {props.errors.firstName} </ErrorLabel> |
66 | )} | 62 | )} |
67 | </FormGroup> | 63 | </FormGroup> |
68 | </Col> | 64 | </Col> |
69 | 65 | ||
70 | <Col xs={12} sm={4}> | 66 | <Col xs={12} sm={4}> |
71 | <FormGroup controlId="lastName"> | 67 | <FormGroup controlId="lastName"> |
72 | <Label required>Last Name</Label> | 68 | <Label required>Last Name</Label> |
73 | <FormControl | 69 | <FormControl |
74 | type="text" | 70 | type="text" |
75 | value={props.getValue('lastName')} | 71 | value={props.getValue('lastName')} |
76 | placeholder="Last Name" | 72 | placeholder="Last Name" |
77 | onChange={e => props.setValue('lastName', e.target.value)} | 73 | onChange={e => props.setValue('lastName', e.target.value)} |
78 | /> | 74 | /> |
79 | {props.isSubmitted() && props.errors && props.errors.lastName && ( | 75 | {props.isSubmitted() && props.errors && props.errors.lastName && ( |
80 | <ErrorLabel> {props.errors.lastName} </ErrorLabel> | 76 | <ErrorLabel> {props.errors.lastName} </ErrorLabel> |
81 | )} | 77 | )} |
82 | </FormGroup> | 78 | </FormGroup> |
83 | </Col> | 79 | </Col> |
84 | </Row> | 80 | </Row> |
85 | <Row> | 81 | <Row> |
86 | <Col xs={12} sm={4}> | 82 | <Col xs={12} sm={4}> |
87 | <FormGroup controlId="formControlsSelect"> | 83 | <FormGroup controlId="formControlsSelect"> |
88 | <Label>Gender</Label> | 84 | <Label>Gender</Label> |
89 | <FormControl componentClass="select" | 85 | <FormControl componentClass="select" |
90 | placeholder="select" | 86 | placeholder="select" |
91 | value={props.getValue('gender')} | 87 | value={props.getValue('gender')} |
92 | onChange={e => props.setValue('gender', e.target.value)} | 88 | onChange={e => props.setValue('gender', e.target.value)} |
93 | > | 89 | > |
94 | <option value="male">Male</option> | 90 | <option value="male">Male</option> |
95 | <option value="female">Female</option> | 91 | <option value="female">Female</option> |
96 | </FormControl> | 92 | </FormControl> |
97 | {props.isSubmitted() && props.errors && props.errors.gender && ( | 93 | {props.isSubmitted() && props.errors && props.errors.gender && ( |
98 | <ErrorLabel> {props.errors.gender} </ErrorLabel> | 94 | <ErrorLabel> {props.errors.gender} </ErrorLabel> |
99 | )} | 95 | )} |
100 | </FormGroup> | 96 | </FormGroup> |
101 | </Col> | 97 | </Col> |
102 | 98 | ||
103 | <Col xs={12} sm={4}> | 99 | <Col xs={12} sm={4}> |
104 | <FormGroup controlId="martialStatus"> | 100 | <FormGroup controlId="formControlsSelect"> |
105 | <Label required>Martial Status</Label> | 101 | <Label>martialStatus</Label> |
106 | <FormControl | 102 | <FormControl componentClass="select" |
107 | type="text" | 103 | placeholder="select" |
108 | value={props.getValue('martialStatus')} | 104 | value={props.getValue('martialStatus')} |
109 | placeholder="Martial Status" | ||
110 | onChange={e => props.setValue('martialStatus', e.target.value)} | 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 | {props.isSubmitted() && props.errors && props.errors.martialStatus && ( | 111 | {props.isSubmitted() && props.errors && props.errors.martialStatus && ( |
113 | <ErrorLabel> {props.errors.martialStatus} </ErrorLabel> | 112 | <ErrorLabel> {props.errors.martialStatus} </ErrorLabel> |
114 | )} | 113 | )} |
115 | </FormGroup> | 114 | </FormGroup> |
116 | </Col> | 115 | </Col> |
117 | 116 | ||
118 | <Col xs={12} sm={4}> | 117 | <Col xs={12} sm={4}> |
119 | <FormGroup> | 118 | <FormGroup> |
120 | <Label required>Date of birth</Label> | 119 | <Label required>Date of birth</Label> |
121 | <DatePicker | 120 | <DatePicker |
122 | id="dob" | 121 | id="dob" |
123 | setValue = {props.setValue} | 122 | setValue = {props.setValue} |
124 | value={props.getValue('dob')} | 123 | value={props.getValue('dob')} |
125 | onChange={(e) => { | 124 | onChange={(e) => { |
126 | props.setValue('dob', e.target.value) | 125 | props.setValue('dob', e.target.value) |
127 | }} | 126 | }} |
128 | /> | 127 | /> |
129 | {props.isSubmitted() && props.errors && props.errors.dob && ( | 128 | {props.isSubmitted() && props.errors && props.errors.dob && ( |
130 | <ErrorLabel> {props.errors.dob} </ErrorLabel> | 129 | <ErrorLabel> {props.errors.dob} </ErrorLabel> |
131 | )} | 130 | )} |
132 | </FormGroup> | 131 | </FormGroup> |
133 | </Col> | 132 | </Col> |
134 | </Row> | 133 | </Row> |
134 | </fieldset> | ||
135 | )} | ||
136 | {props.currentStep === 1 && ( | ||
137 | <fieldset title="Academic"> | ||
138 | <legend className="text-semibold">Additional Info</legend> | ||
135 | <Row> | 139 | <Row> |
136 | <Col xs={12} sm={4}> | 140 | <Col xs={12} sm={4}> |
137 | <FormGroup controlId="email"> | 141 | <FormGroup controlId="email"> |
138 | <Label required>Email</Label> | 142 | <Label required>Email</Label> |
139 | <FormControl | 143 | <FormControl |
140 | type="email" | 144 | type="email" |
141 | value={props.getValue('email')} | 145 | value={props.getValue('email')} |
142 | placeholder="Email" | 146 | placeholder="Email" |
143 | onChange={e => props.setValue('email', e.target.value)} | 147 | onChange={e => props.setValue('email', e.target.value)} |
144 | /> | 148 | /> |
145 | {props.isSubmitted() && props.errors && props.errors.email && ( | 149 | {props.isSubmitted() && props.errors && props.errors.email && ( |
146 | <ErrorLabel> {props.errors.email} </ErrorLabel> | 150 | <ErrorLabel> {props.errors.email} </ErrorLabel> |
147 | )} | 151 | )} |
148 | </FormGroup> | 152 | </FormGroup> |
149 | </Col> | 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 | <Col xs={12} sm={4}> | 154 | <Col xs={12} sm={4}> |
253 | <FormGroup controlId="phone"> | 155 | <FormGroup controlId="phone"> |
254 | <Label required>Phone</Label> | 156 | <Label required>Phone</Label> |
255 | <FormControl | 157 | <FormControl |
256 | type="text" | 158 | type="text" |
257 | value={props.getValue('phone')} | 159 | value={props.getValue('phone')} |
258 | placeholder="9999999999" | 160 | placeholder="Martial Status" |
259 | onChange={e => props.setValue('phone', e.target.value)} | 161 | onChange={e => props.setValue('phone', e.target.value)} |
260 | /> | 162 | /> |
261 | {props.isSubmitted() && props.errors && props.errors.phone && ( | 163 | {props.isSubmitted() && props.errors && props.errors.phone && ( |
262 | <ErrorLabel> {props.errors.phone} </ErrorLabel> | 164 | <ErrorLabel> {props.errors.phone} </ErrorLabel> |
263 | )} | 165 | )} |
264 | </FormGroup> | 166 | </FormGroup> |
265 | </Col> | 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 | <Col xs={12} sm={4}> | 168 | <Col xs={12} sm={4}> |
274 | <FormGroup controlId="address"> | 169 | <FormGroup controlId="address"> |
275 | <Label required>Address</Label> | 170 | <Label required>Address</Label> |
276 | <FormControl | 171 | <FormControl |
277 | type="text" | 172 | type="text" |
278 | value={props.getValue('address')} | 173 | value={props.getValue('address')} |
279 | placeholder="#876, Street, town" | 174 | placeholder="#876, Street, town" |
280 | onChange={e => props.setValue('address', e.target.value)} | 175 | onChange={e => props.setValue('address', e.target.value)} |
281 | /> | 176 | /> |
282 | {props.isSubmitted() && props.errors && props.errors.address && ( | 177 | {props.isSubmitted() && props.errors && props.errors.address && ( |
283 | <ErrorLabel> {props.errors.address} </ErrorLabel> | 178 | <ErrorLabel> {props.errors.address} </ErrorLabel> |
284 | )} | 179 | )} |
285 | </FormGroup> | 180 | </FormGroup> |
286 | </Col> | 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 | </Row> | 182 | </Row> |
302 | <Row> | 183 | <Row> |
303 | <Col xs={12} sm={4}> | 184 | <Col xs={12} sm={4}> |
304 | <FormGroup controlId="state"> | 185 | <FormGroup controlId="formControlsSelect"> |
305 | <Label required>State</Label> | 186 | <Label>Teaching Staff?</Label> |
306 | <FormControl | 187 | <FormControl componentClass="select" |
307 | type="text" | 188 | placeholder="select" |
308 | value={props.getValue('state')} | 189 | value={props.getValue('teaching')} |
309 | placeholder="Tamilnadu" | 190 | onChange={e => props.setValue('teaching', e.target.value)} |
310 | onChange={e => props.setValue('state', e.target.value)} | 191 | > |
311 | /> | 192 | <option value="yes">Yes</option> |
312 | {props.isSubmitted() && props.errors && props.errors.state && ( | 193 | <option value="no">No</option> |
313 | <ErrorLabel> {props.errors.state} </ErrorLabel> | 194 | </FormControl> |
195 | {props.isSubmitted() && props.errors && props.errors.teaching && ( | ||
196 | <ErrorLabel> {props.errors.teaching} </ErrorLabel> | ||
314 | )} | 197 | )} |
315 | </FormGroup> | 198 | </FormGroup> |
316 | </Col> | 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 | <Col xs={12} sm={4}> | 200 | <Col xs={12} sm={4}> |
325 | <FormGroup controlId="parentName"> | 201 | <FormGroup controlId="formControlsSelect"> |
326 | <Label required>Parent Name</Label> | 202 | <Label>Type</Label> |
327 | <FormControl | 203 | <FormControl componentClass="select" |
328 | type="text" | 204 | placeholder="select" |
329 | value={props.getValue('parentName')} | 205 | value={props.getValue('type')} |
330 | placeholder="John" | 206 | onChange={e => props.setValue('type', e.target.value)} |
331 | onChange={e => props.setValue('parentName', e.target.value)} | 207 | > |
332 | /> | 208 | <option value="permanent">Permanent</option> |
333 | {props.isSubmitted() && props.errors && props.errors.parentName && ( | 209 | <option value="temporary">Temporary</option> |
334 | <ErrorLabel> {props.errors.parentName} </ErrorLabel> | 210 | </FormControl> |
211 | {props.isSubmitted() && props.errors && props.errors.type && ( | ||
212 | <ErrorLabel> {props.errors.type} </ErrorLabel> | ||
335 | )} | 213 | )} |
336 | </FormGroup> | 214 | </FormGroup> |
337 | </Col> | 215 | </Col> |
338 | <Col xs={12} sm={4}> | 216 | <Col xs={12} sm={4}> |
339 | <FormGroup controlId="parentEmail"> | 217 | <FormGroup> |
340 | <Label required>Parent Email</Label> | 218 | <Label required>Date of Joining</Label> |
341 | <FormControl | 219 | <DatePicker |
342 | type="text" | 220 | id="doj" |
343 | value={props.getValue('parentEmail')} | 221 | setValue = {props.setValue} |
344 | placeholder="john@email.com" | 222 | value={props.getValue('doj')} |
345 | onChange={e => props.setValue('parentEmail', e.target.value)} | 223 | onChange={(e) => { |
224 | props.setValue('doj', e.target.value) | ||
225 | }} | ||
346 | /> | 226 | /> |
347 | {props.isSubmitted() && props.errors && props.errors.parentEmail && ( | 227 | {props.isSubmitted() && props.errors && props.errors.doj && ( |
348 | <ErrorLabel> {props.errors.parentEmail} </ErrorLabel> | 228 | <ErrorLabel> {props.errors.doj} </ErrorLabel> |
349 | )} | 229 | )} |
350 | </FormGroup> | 230 | </FormGroup> |
351 | </Col> | 231 | </Col> |
352 | </Row> | 232 | </Row> |
233 | </fieldset> | ||
234 | )} | ||
235 | {props.currentStep === 2 && ( | ||
236 | <fieldset title="Professional Info"> | ||
237 | <legend className="text-semibold">Professional Info</legend> | ||
353 | <Row> | 238 | <Row> |
354 | <Col xs={12} sm={4}> | 239 | <Col xs={12} sm={4}> |
355 | <FormGroup controlId="relation"> | 240 | <FormGroup controlId="qualifaication"> |
356 | <Label required>Relation</Label> | 241 | <Label required>Qualifaication</Label> |
357 | <FormControl | 242 | <FormControl |
358 | type="text" | 243 | type="text" |
359 | value={props.getValue('relation')} | 244 | value={props.getValue('qualifaication')} |
360 | placeholder="Father" | 245 | placeholder="Ex: Phd" |
361 | onChange={e => props.setValue('relation', e.target.value)} | 246 | onChange={e => props.setValue('qualifaication', e.target.value)} |
362 | /> | 247 | /> |
363 | {props.isSubmitted() && props.errors && props.errors.relation && ( | 248 | {props.isSubmitted() && props.errors && props.errors.qualifaication && ( |
364 | <ErrorLabel> {props.errors.relation} </ErrorLabel> | 249 | <ErrorLabel> {props.errors.qualifaication} </ErrorLabel> |
365 | )} | 250 | )} |
366 | </FormGroup> | 251 | </FormGroup> |
367 | </Col> | 252 | </Col> |
368 | <Col xs={12} sm={4}> | 253 | <Col xs={12} sm={4}> |
369 | <FormGroup controlId="profession"> | 254 | <FormGroup controlId="specialization"> |
370 | <Label required>Profession</Label> | 255 | <Label required>Specialization</Label> |
371 | <FormControl | 256 | <FormControl |
372 | type="text" | 257 | type="text" |
373 | value={props.getValue('profession')} | 258 | value={props.getValue('specialization')} |
374 | placeholder="Farmer" | 259 | placeholder="Ex: Maths" |
375 | onChange={e => props.setValue('profession', e.target.value)} | 260 | onChange={e => props.setValue('specialization', e.target.value)} |
376 | /> | 261 | /> |
377 | {props.isSubmitted() && props.errors && props.errors.profession && ( | 262 | {props.isSubmitted() && props.errors && props.errors.specialization && ( |
378 | <ErrorLabel> {props.errors.profession} </ErrorLabel> | 263 | <ErrorLabel> {props.errors.specialization} </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> | ||
397 | )} | 264 | )} |
398 | </FormGroup> | 265 | </FormGroup> |
399 | </Col> | 266 | </Col> |
400 | <Col xs={12} sm={4}> | 267 | <Col xs={12} sm={4}> |
401 | <FormGroup controlId="parentPhone"> | 268 | <FormGroup controlId="university"> |
402 | <Label required>Parent Phone</Label> | 269 | <Label required>University</Label> |
403 | <FormControl | 270 | <FormControl |
404 | type="text" | 271 | type="text" |
405 | value={props.getValue('parentPhone')} | 272 | value={props.getValue('university')} |
406 | placeholder="9876543210" | 273 | placeholder="Ex: Pune University" |
407 | onChange={e => props.setValue('parentPhone', e.target.value)} | 274 | onChange={e => props.setValue('university', e.target.value)} |
408 | /> | 275 | /> |
409 | {props.isSubmitted() && props.errors && props.errors.parentPhone && ( | 276 | {props.isSubmitted() && props.errors && props.errors.university && ( |
410 | <ErrorLabel> {props.errors.parentPhone} </ErrorLabel> | 277 | <ErrorLabel> {props.errors.university} </ErrorLabel> |
411 | )} | 278 | )} |
412 | </FormGroup> | 279 | </FormGroup> |
413 | </Col> | 280 | </Col> |
414 | </Row> | 281 | </Row> |
415 | <Row> | 282 | <Row> |
416 | <Col xs={12} sm={4}> | 283 | <Col xs={12} sm={4}> |
417 | <FormGroup controlId="parentAddress"> | 284 | <FormGroup> |
418 | <Label required>Parent Address</Label> | 285 | <Label required>Latest Degree started At</Label> |
419 | <FormControl | 286 | <DatePicker |
420 | type="text" | 287 | id="degreeFrom" |
421 | value={props.getValue('parentAddress')} | 288 | setValue = {props.setValue} |
422 | placeholder="#12, street, town" | 289 | value={props.getValue('degreeFrom')} |
423 | onChange={e => props.setValue('parentAddress', e.target.value)} | 290 | onChange={(e) => { |
424 | /> | 291 | props.setValue('degreeFrom', e.target.value) |
425 | {props.isSubmitted() && props.errors && props.errors.parentAddress && ( | 292 | }} |
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)} | ||
438 | /> | 293 | /> |
439 | {props.isSubmitted() && props.errors && props.errors.parentCity && ( | 294 | {props.isSubmitted() && props.errors && props.errors.degreeFrom && ( |
440 | <ErrorLabel> {props.errors.parentCity} </ErrorLabel> | 295 | <ErrorLabel> {props.errors.degreeFrom} </ErrorLabel> |
441 | )} | 296 | )} |
442 | </FormGroup> | 297 | </FormGroup> |
443 | </Col> | 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 | <Col xs={12} sm={4}> | 299 | <Col xs={12} sm={4}> |
461 | <FormGroup controlId="parentZipcode"> | 300 | <FormGroup> |
462 | <Label required>Parent Zipcode</Label> | 301 | <Label required>Latest Degree ended At</Label> |
463 | <FormControl | 302 | <DatePicker |
464 | type="text" | 303 | id="degreeEnded" |
465 | value={props.getValue('parentZipcode')} | 304 | setValue = {props.setValue} |
466 | placeholder="600031" | 305 | value={props.getValue('degreeEnded')} |
467 | onChange={e => props.setValue('parentZipcode', e.target.value)} | 306 | onChange={(e) => { |
307 | props.setValue('degreeEnded', e.target.value) | ||
308 | }} | ||
468 | /> | 309 | /> |
469 | {props.isSubmitted() && props.errors && props.errors.parentZipcode && ( | 310 | {props.isSubmitted() && props.errors && props.errors.degreeEnded && ( |
470 | <ErrorLabel> {props.errors.parentZipcode} </ErrorLabel> | 311 | <ErrorLabel> {props.errors.degreeEnded} </ErrorLabel> |
471 | )} | 312 | )} |
472 | </FormGroup> | 313 | </FormGroup> |
473 | </Col> | 314 | </Col> |
474 | </Row> | 315 | </Row> |
475 | </fieldset> | 316 | </fieldset> |
476 | )} | 317 | )} |
477 | <div style={{ textAlign: 'left' }}> | 318 | <div style={{ textAlign: 'left' }}> |
478 | {props.currentStep > 0 && ( | 319 | {props.currentStep > 0 && ( |
479 | <div style={{ display: 'inline-block', marginRight: 10 }}> | 320 | <div style={{ display: 'inline-block', marginRight: 10 }}> |
480 | <Button onClick={props.onBackClick}> | 321 | <Button onClick={props.onBackClick}> |
481 | <i className="icon-arrow-left13 position-left"></i> | 322 | <i className="icon-arrow-left13 position-left"></i> |
482 | BACK | 323 | BACK |
483 | </Button> | 324 | </Button> |
484 | 325 | ||
485 | </div> | 326 | </div> |
486 | )} | 327 | )} |
487 | {props.currentStep < 3 && ( | 328 | {props.currentStep < 2 && ( |
488 | <div style={{ display: 'inline-block' }}> | 329 | <div style={{ display: 'inline-block' }}> |
489 | <Button | 330 | <Button |
490 | bsStyle="primary" | 331 | bsStyle="primary" |
491 | onClick={props.onNextClick} | 332 | onClick={props.onNextClick} |
492 | > | 333 | > |
493 | NEXT | 334 | NEXT |
494 | <i className="icon-arrow-right14 position-right" /> | 335 | <i className="icon-arrow-right14 position-right" /> |
495 | </Button> | 336 | </Button> |
496 | </div> | 337 | </div> |
497 | )} | 338 | )} |
498 | {props.currentStep === 3 && ( | 339 | {props.currentStep === 2 && ( |
499 | <div style={{ display: 'inline-block' }}> | 340 | <div style={{ display: 'inline-block' }}> |
500 | <Button | 341 | <Button |
imports/client/views/org/admin/staff/index.js
1 | // import { InviteSignupController } from '/imports/client/views/invite/signup/index' | 1 | // import { InviteSignupController } from '/imports/client/views/invite/signup/index' |
2 | import _ from 'lodash'; | 2 | import _ from 'lodash'; |
3 | import { | 3 | import { |
4 | composeWithTracker, | 4 | composeWithTracker, |
5 | compose, | 5 | compose, |
6 | composeAll | 6 | composeAll |
7 | } from 'react-komposer'; | 7 | } from 'react-komposer'; |
8 | import { Loading } from '/imports/client/components/Loading'; | 8 | import { Loading } from '/imports/client/components/Loading'; |
9 | 9 | ||
10 | import { Orgs } from '/imports/collections/orgs/index'; | 10 | import { Orgs } from '/imports/collections/orgs/index'; |
11 | import { Users } from '/imports/collections/users/index'; | 11 | import { Users } from '/imports/collections/users/index'; |
12 | import { Staffs } from '/imports/collections/staff/index'; | 12 | import { Staffs } from '/imports/collections/staff/index'; |
13 | import { StaffView } from './StaffView'; | 13 | import { StaffView } from './StaffView'; |
14 | 14 | ||
15 | const meteorTick = (props, onData) => { | 15 | const meteorTick = (props, onData) => { |
16 | 16 | ||
17 | const handles = [ | 17 | const handles = [ |
18 | Meteor.subscribe('users.current'), | 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 | if(_.every(handles, (handle) => (handle.ready()) )) { | 24 | if(_.every(handles, (handle) => (handle.ready()) )) { |
23 | const user = Users.current(); | 25 | const user = Users.current(); |
24 | const org = Orgs.current(); | 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 | staffData = Staffs.find().fetch() ? Staffs.find().fetch() : ""; | 29 | staffData = Staffs.find().fetch() ? Staffs.find().fetch() : ""; |
30 | console.log("staffData"); | ||
31 | console.log(staffData); | ||
27 | for(var i=0; i< staff.length; i++){ | 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 | if(staff[i]._id == staffData[j].userId){ | 34 | if(staff[i]._id == staffData[j].userId){ |
30 | staff[i].class = staffData[j].class; | 35 | staff[i].type = staffData[j].type; |
31 | staff[i].dob = staffData[j].dob; | 36 | staff[i].dob = staffData[j].dob; |
32 | } | 37 | } |
33 | } | 38 | } |
34 | } | 39 | } |
35 | onData(null, { | 40 | onData(null, { |
36 | data: { | 41 | data: { |
37 | user: user, | 42 | user: user, |
38 | org: org, | 43 | org: org, |
39 | staff: staff | 44 | staff: staff |
40 | }, | 45 | }, |
41 | }); | 46 | }); |
42 | } | 47 | } |
43 | 48 | ||
44 | return () => { | 49 | return () => { |
45 | _.each(handles, (handle) => handle.stop() ); | 50 | _.each(handles, (handle) => handle.stop() ); |
46 | }; | 51 | }; |
47 | }; | 52 | }; |
48 | 53 | ||
49 | 54 | ||
50 | const reduxTick = (props, onData) => { | 55 | const reduxTick = (props, onData) => { |
51 | onData(null, { | 56 | onData(null, { |
52 | data: {} | 57 | data: {} |
53 | }); | 58 | }); |
54 | }; | 59 | }; |
55 | 60 | ||
56 | 61 | ||
57 | export const staffViewController = composeAll( | 62 | export const staffViewController = composeAll( |
58 | composeWithTracker(meteorTick, Loading), | 63 | composeWithTracker(meteorTick, Loading), |
59 | compose(reduxTick, Loading), | 64 | compose(reduxTick, Loading), |
60 | )(StaffView); | 65 | )(StaffView); |
61 | 66 |
imports/client/views/org/admin/staff/view/StaffRow.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 { 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 | }; | ||
57 |
imports/client/views/org/admin/staff/view/StaffTable.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 {moment} from 'meteor/momentjs:moment' | 9 | import {moment} from 'meteor/momentjs:moment' |
10 | import {TeachersRow} from './TeachersRow' | 10 | import {StaffRow} from './StaffRow' |
11 | 11 | ||
12 | export class StaffTable extends Component { | 12 | export class StaffTable extends Component { |
13 | 13 | ||
14 | constructor(props) { | 14 | constructor(props) { |
15 | super(props); | 15 | super(props); |
16 | this.state = { | 16 | this.state = { |
17 | show: false | 17 | show: false |
18 | }; | 18 | }; |
19 | this.onUpdate = this.onUpdate.bind(this); | 19 | this.onUpdate = this.onUpdate.bind(this); |
20 | }; | 20 | }; |
21 | onUpdate(key, value) { | 21 | onUpdate(key, value) { |
22 | this.setState({[key]: value}); | 22 | this.setState({[key]: value}); |
23 | }; | 23 | }; |
24 | 24 | ||
25 | render() { | 25 | render() { |
26 | return ( | 26 | return ( |
27 | <div className="panel panel-flat"> | 27 | <div className="panel panel-flat"> |
28 | <div className="panel-heading"> | 28 | <div className="panel-heading"> |
29 | <h5 className="panel-title">Teachers Details</h5> | 29 | <h5 className="panel-title">Teachers Details</h5> |
30 | <div className="heading-elements"> | 30 | <div className="heading-elements"> |
31 | <ul className="icons-list"> | 31 | <ul className="icons-list"> |
32 | <li><a data-action="collapse"></a></li> | 32 | <li><a data-action="collapse"></a></li> |
33 | <li><a data-action="reload"></a></li> | 33 | <li><a data-action="reload"></a></li> |
34 | </ul> | 34 | </ul> |
35 | </div> | 35 | </div> |
36 | </div> | 36 | </div> |
37 | <Table striped bordered condensed hover> | 37 | <Table striped bordered condensed hover> |
38 | <thead> | 38 | <thead> |
39 | <tr> | 39 | <tr> |
40 | <th>First Name</th> | 40 | <th>First Name</th> |
41 | <th>Last Name</th> | 41 | <th>Last Name</th> |
42 | <th>Class</th> | 42 | <th>Type</th> |
43 | <th>DOB</th> | 43 | <th>DOB</th> |
44 | <th>Status</th> | 44 | <th>Status</th> |
45 | <th className="text-center">Actions</th> | 45 | <th className="text-center">Actions</th> |
46 | </tr> | 46 | </tr> |
47 | </thead> | 47 | </thead> |
48 | <tbody> | 48 | <tbody> |
49 | { | 49 | { |
50 | this.props.staff.map(function(student, i) | 50 | this.props.staff.map(function(staff, i) |
51 | { | 51 | { |
52 | return( | 52 | return( |
53 | <TeachersRow | 53 | <StaffRow |
54 | teacher = {teacher} | 54 | key = {i} |
55 | staff = {staff} | ||
55 | /> | 56 | /> |
56 | ) | 57 | ) |
57 | }) | 58 | }) |
58 | } | 59 | } |
59 | </tbody> | 60 | </tbody> |
60 | </Table> | 61 | </Table> |
61 | </div> | 62 | </div> |
62 | ); | 63 | ); |
63 | }; | 64 | }; |
64 | 65 | ||
65 | }; | 66 | }; |
66 | 67 |
imports/client/views/org/admin/staff/view/TeachersRow.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, | ||
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 | }; | ||
57 | 1 | import _ from 'lodash'; |
imports/client/views/org/admin/students/add/AddStudentFormContainer.js
1 | import React, { Component } from 'react' | 1 | import React, { Component } from 'react' |
2 | import { AddStudentForm } from './addStudentForm' | 2 | import { AddStudentForm } from './addStudentForm' |
3 | import StudentForm from './StudentForm' | 3 | import StudentForm from './StudentForm' |
4 | import Form from '/imports/client/views/core/Form' | 4 | import Form from '/imports/client/views/core/Form' |
5 | import Validator from '/imports/client/views/core/Validator' | 5 | import Validator from '/imports/client/views/core/Validator' |
6 | import { isRequired, isValidEmail } from '/imports/client/views/core/validations' | 6 | import { isRequired, isValidEmail } from '/imports/client/views/core/validations' |
7 | import { addStudentManually } from '/imports/collections/students/methods'; | 7 | import { addStudentManually } from '/imports/collections/students/methods'; |
8 | 8 | ||
9 | export class AddStudentFormContainer extends Component { | 9 | export class AddStudentFormContainer extends Component { |
10 | 10 | ||
11 | constructor(props) { | 11 | constructor(props) { |
12 | super(props) | 12 | super(props) |
13 | this.state = { currentStep: 0 } | 13 | this.state = { currentStep: 0 } |
14 | this.handleNextClick = this.handleNextClick.bind(this) | 14 | this.handleNextClick = this.handleNextClick.bind(this) |
15 | this.handleBackClick = this.handleBackClick.bind(this) | 15 | this.handleBackClick = this.handleBackClick.bind(this) |
16 | this.handleSubmit = this.handleSubmit.bind(this) | 16 | this.handleSubmit = this.handleSubmit.bind(this) |
17 | } | 17 | } |
18 | 18 | ||
19 | handleNextClick() { | 19 | handleNextClick() { |
20 | this.form.handleSubmit() | 20 | this.form.handleSubmit() |
21 | if (this.validator.getErrors() && Object.keys(this.validator.getErrors()).length > 0) return | 21 | if (this.validator.getErrors() && Object.keys(this.validator.getErrors()).length > 0) return |
22 | this.setState({ currentStep: this.state.currentStep + 1 }) | 22 | this.setState({ currentStep: this.state.currentStep + 1 }) |
23 | this.form.resetSubmitted() | 23 | this.form.resetSubmitted() |
24 | } | 24 | } |
25 | 25 | ||
26 | handleBackClick() { | 26 | handleBackClick() { |
27 | this.setState({ currentStep: this.state.currentStep + -1 }) | 27 | this.setState({ currentStep: this.state.currentStep + -1 }) |
28 | } | 28 | } |
29 | 29 | ||
30 | handleSubmit() { | 30 | handleSubmit() { |
31 | if (this.state.currentStep === 3) { | 31 | if (this.state.currentStep === 3) { |
32 | addStudentManually.call(this.form.state.values) | 32 | addStudentManually.call(this.form.state.values); |
33 | } | 33 | } |
34 | } | 34 | } |
35 | 35 | ||
36 | //render callback | 36 | //render callback |
37 | render() { | 37 | render() { |
38 | return ( | 38 | return ( |
39 | <Form | 39 | <Form |
40 | onSubmit={this.handleSubmit} | 40 | onSubmit={this.handleSubmit} |
41 | ref={form => this.form = form} | 41 | ref={form => this.form = form} |
42 | initialValues={{ | 42 | initialValues={{ |
43 | gender: 'male', | 43 | gender: 'male', |
44 | parentGender: 'male', | 44 | parentGender: 'male', |
45 | }} | 45 | }} |
46 | > | 46 | > |
47 | {({ values, setValue, getValue, isSubmitted, isDirty }) => ( | 47 | {({ values, setValue, getValue, isSubmitted, isDirty }) => ( |
48 | <Validator | 48 | <Validator |
49 | values={values} | 49 | values={values} |
50 | ref={validator => this.validator = validator} | 50 | ref={validator => this.validator = validator} |
51 | validations={{ | 51 | validations={{ |
52 | admissionId: [(value) => isRequired('Admission id', value)], | 52 | admissionId: [(value) => isRequired('Admission id', value)], |
53 | firstName: [(value) => isRequired('First name', value)], | 53 | firstName: [(value) => isRequired('First name', value)], |
54 | lastName: [(value) => isRequired('Last name', value)], | 54 | lastName: [(value) => isRequired('Last name', value)], |
55 | email: [(value) => isRequired('Email', value), isValidEmail], | 55 | email: [(value) => isRequired('Email', value), isValidEmail], |
56 | dob: [(value) => isRequired('Date of birth', value)], | 56 | dob: [(value) => isRequired('Date of birth', value)], |
57 | gender: [(value) => isRequired('Gender', value)], | 57 | gender: [(value) => isRequired('Gender', value)], |
58 | rollNo: [(value) => this.state.currentStep === 1 && isRequired('Roll no', value)], | 58 | rollNo: [(value) => this.state.currentStep === 1 && isRequired('Roll no', value)], |
59 | studentClass: [(value) => this.state.currentStep === 1 && isRequired('Class', value)], | 59 | studentClass: [(value) => this.state.currentStep === 1 && isRequired('Class', value)], |
60 | section: [(value) => this.state.currentStep === 1 && isRequired('Section', value)], | 60 | section: [(value) => this.state.currentStep === 1 && isRequired('Section', value)], |
61 | community: [(value) => this.state.currentStep === 1 && isRequired('Community', value)], | 61 | community: [(value) => this.state.currentStep === 1 && isRequired('Community', value)], |
62 | bloodGroup: [(value) => this.state.currentStep === 1 && isRequired('Blood group', value)], | 62 | bloodGroup: [(value) => this.state.currentStep === 1 && isRequired('Blood group', value)], |
63 | phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], | 63 | phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], |
64 | address: [(value) => this.state.currentStep === 2 && isRequired('Address', value)], | 64 | address: [(value) => this.state.currentStep === 2 && isRequired('Address', value)], |
65 | city: [(value) => this.state.currentStep === 2 && isRequired('City', value)], | 65 | city: [(value) => this.state.currentStep === 2 && isRequired('City', value)], |
66 | state: [(value) => this.state.currentStep === 2 && isRequired('State', value)], | 66 | state: [(value) => this.state.currentStep === 2 && isRequired('State', value)], |
67 | parentName: [(value) => this.state.currentStep === 3 && isRequired('Parent name', 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)], | 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)], | 69 | relation: [(value) => this.state.currentStep === 3 && isRequired('Relation', value)], |
70 | profession: [(value) => this.state.currentStep === 3 && isRequired('Profession', value)], | 70 | profession: [(value) => this.state.currentStep === 3 && isRequired('Profession', value)], |
71 | parentGender: [(value) => this.state.currentStep === 3 && isRequired('Parent gender', value)], | 71 | parentGender: [(value) => this.state.currentStep === 3 && isRequired('Parent gender', value)], |
72 | parentPhone: [(value) => this.state.currentStep === 3 && isRequired('Parent phone', value)], | 72 | parentPhone: [(value) => this.state.currentStep === 3 && isRequired('Parent phone', value)], |
73 | parentAddress: [(value) => this.state.currentStep === 3 && isRequired('Parent address', value)], | 73 | parentAddress: [(value) => this.state.currentStep === 3 && isRequired('Parent address', value)], |
74 | parentCity: [(value) => this.state.currentStep === 3 && isRequired('Parent city', value)], | 74 | parentCity: [(value) => this.state.currentStep === 3 && isRequired('Parent city', value)], |
75 | parentState: [(value) => this.state.currentStep === 3 && isRequired('Parent state', value)], | 75 | parentState: [(value) => this.state.currentStep === 3 && isRequired('Parent state', value)], |
76 | parentZipcode: [(value) => this.state.currentStep === 3 && isRequired('Parent zip code', value)], | 76 | parentZipcode: [(value) => this.state.currentStep === 3 && isRequired('Parent zip code', value)], |
77 | }} | 77 | }} |
78 | > | 78 | > |
79 | {({ errors }) => ( | 79 | {({ errors }) => ( |
80 | <StudentForm | 80 | <StudentForm |
81 | isDirty={isDirty} | 81 | isDirty={isDirty} |
82 | setValue={setValue} | 82 | setValue={setValue} |
83 | getValue={getValue} | 83 | getValue={getValue} |
84 | isSubmitted={isSubmitted} | 84 | isSubmitted={isSubmitted} |
85 | errors={errors} | 85 | errors={errors} |
86 | onNextClick={this.handleNextClick} | 86 | onNextClick={this.handleNextClick} |
87 | onBackClick={this.handleBackClick} | 87 | onBackClick={this.handleBackClick} |
88 | currentStep={this.state.currentStep} | 88 | currentStep={this.state.currentStep} |
89 | /> | 89 | /> |
90 | )} | 90 | )} |
91 | </Validator> | 91 | </Validator> |
92 | )} | 92 | )} |
93 | </Form> | 93 | </Form> |
94 | ) | 94 | ) |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 |
imports/collections/staff/index.js
1 | // import {Staffs } from '/imports/collections/staff/index' | 1 | // import {Staffs } from '/imports/collections/staff/index' |
2 | 2 | ||
3 | import _ from 'lodash'; | 3 | import _ from 'lodash'; |
4 | import { Meteor } from 'meteor/meteor'; | 4 | import { Meteor } from 'meteor/meteor'; |
5 | import { Mongo } from 'meteor/mongo'; | 5 | import { Mongo } from 'meteor/mongo'; |
6 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; | 6 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; |
7 | 7 | ||
8 | import { Orgs } from '/imports/collections/orgs/index'; | 8 | import { Orgs } from '/imports/collections/orgs/index'; |
9 | import { Users } from '/imports/collections/users/index'; | 9 | import { Users } from '/imports/collections/users/index'; |
10 | 10 | ||
11 | class Staff { | 11 | class Staff { |
12 | constructor(doc) { | 12 | constructor(doc) { |
13 | _.assign(this, doc); | 13 | _.assign(this, doc); |
14 | }; | 14 | }; |
15 | 15 | ||
16 | getUserIds() { | 16 | getUserIds() { |
17 | return _.filter(_.map(this.users, 'userId')); | 17 | return _.filter(_.map(this.users, 'userId')); |
18 | }; | 18 | }; |
19 | }; | 19 | }; |
20 | export { Staff }; | 20 | export { Staff }; |
21 | 21 | ||
22 | class StaffsCollection extends Mongo.Collection { | 22 | class StaffsCollection extends Mongo.Collection { |
23 | insert(item, callback) { | 23 | insert(item, callback) { |
24 | _.assign(item, { | 24 | _.assign(item, { |
25 | createdAt: new Date().getTime(), | 25 | createdAt: new Date().getTime(), |
26 | }); | 26 | }); |
27 | return super.insert(item, callback); | 27 | return super.insert(item, callback); |
28 | }; | 28 | }; |
29 | }; | 29 | }; |
30 | 30 | ||
31 | export const Staffs = new StaffsCollection('Teachers', { | 31 | export const Staffs = new StaffsCollection('Teachers', { |
32 | transform: (item) => { | 32 | transform: (item) => { |
33 | return new Staff(item); | 33 | return new Staff(item); |
34 | }, | 34 | }, |
35 | }); | 35 | }); |
36 | 36 | ||
37 | _.assign(Staffs, { | 37 | _.assign(Staffs, { |
38 | allStaffs: () => { | 38 | allStaffs: () => { |
39 | const user = Users.current(); | 39 | const user = Users.current(); |
40 | if(!user) return null; | 40 | if(!user) return null; |
41 | return Orgs.find({'users.userId': user._id}); | 41 | return Orgs.find({'users.userId': user._id}); |
42 | }, | 42 | }, |
43 | current: () => { | 43 | current: () => { |
44 | const user = Users.current(); | 44 | const user = Users.current(); |
45 | if(!user) return null; | 45 | if(!user) return null; |
46 | return Orgs.findOne({_id: user.orgId}); | 46 | return Orgs.findOne({_id: user.orgId}); |
47 | }, | 47 | }, |
48 | currentOrgUsers: () => { | 48 | currentOrgUsers: () => { |
49 | const OrgsArr = Orgs.current(); | 49 | const OrgsArr = Orgs.current(); |
50 | if(!OrgsArr) return null; | 50 | if(!OrgsArr) return null; |
51 | return OrgsArr.users; | 51 | return OrgsArr.users; |
52 | }, | 52 | }, |
53 | 53 | ||
54 | }); | 54 | }); |
55 | 55 | ||
56 | Staffs.deny({ | 56 | Staffs.deny({ |
57 | insert() { return true; }, | 57 | insert() { return true; }, |
58 | update() { return true; }, | 58 | update() { return true; }, |
59 | remove() { return true; }, | 59 | remove() { return true; }, |
60 | }); | 60 | }); |
61 | 61 | ||
62 | 62 | ||
63 | Staffs.schema = new SimpleSchema({ | 63 | Staffs.schema = new SimpleSchema({ |
64 | userId: { type: String }, | 64 | userId: { type: String }, |
65 | orgId: { type: String }, | 65 | orgId: { type: String }, |
66 | employeeId: { type: String }, | ||
67 | martialStatus: { type: String }, | ||
68 | dob: { type: String }, | ||
69 | teaching: { type: String }, | ||
66 | type: { type: String }, | 70 | type: { type: String }, |
67 | gender: { type: String, optional: true }, | 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 | services: { | 77 | services: { |
69 | type: Object, | 78 | type: Object, |
70 | optional: true, | 79 | optional: true, |
71 | blackbox: true, | 80 | blackbox: true, |
72 | }, | 81 | }, |
73 | 82 | ||
74 | isMetaUser: { type: Boolean, optional: true }, | 83 | isMetaUser: { type: Boolean, optional: true }, |
75 | 84 | ||
76 | createdAt: { type: Date, autoValue: function(){return new Date();}} | 85 | createdAt: { type: Date, autoValue: function(){return new Date();}} |
77 | 86 | ||
78 | }); | 87 | }); |
79 | 88 | ||
80 | Staffs.attachSchema(Staffs.schema); | 89 | Staffs.attachSchema(Staffs.schema); |
81 | 90 | ||
82 | Staffs.privateFields = { | 91 | Staffs.privateFields = { |
83 | orgId: 1, | 92 | orgId: 1, |
84 | address: 1, | ||
85 | 93 | ||
86 | isMetaUser: 1, | 94 | isMetaUser: 1, |
87 | createdAt: 1, | 95 | createdAt: 1, |
88 | }; | 96 | }; |
89 | 97 | ||
90 | Staffs.publicFields = { | 98 | Staffs.publicFields = { |
91 | firstName: 1, | 99 | firstName: 1, |
92 | lastName: 1, | 100 | lastName: 1, |
93 | emails: 1, | 101 | emails: 1, |
94 | 102 | ||
95 | createdAt: 1, | 103 | createdAt: 1, |
96 | }; | 104 | }; |
imports/collections/staff/methods.js
1 | // import {Parents } from '/imports/collections/parents/methods' | 1 | // import {Parents } from '/imports/collections/parents/methods' |
2 | import _ from 'lodash'; | 2 | import _ from 'lodash'; |
3 | import { Meteor } from 'meteor/meteor'; | 3 | import { Meteor } from 'meteor/meteor'; |
4 | import { ValidatedMethod } from 'meteor/mdg:validated-method'; | 4 | import { ValidatedMethod } from 'meteor/mdg:validated-method'; |
5 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; | 5 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; |
6 | import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; | 6 | import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; |
7 | import { Bert } from 'meteor/themeteorchef:bert'; | 7 | import { Bert } from 'meteor/themeteorchef:bert'; |
8 | import { Users } from '/imports/collections/users/index'; | 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 | import { Orgs } from '/imports/collections/orgs/index'; | 10 | import { Orgs } from '/imports/collections/orgs/index'; |
11 | export const teachersMethods = new ValidatedMethod({ | 11 | export const staffMethods = new ValidatedMethod({ |
12 | name: 'teachers.method', | 12 | name: 'staff.method', |
13 | 13 | ||
14 | validate: new SimpleSchema({ | 14 | validate: new SimpleSchema({ |
15 | itemId: { type: String }, | 15 | itemId: { type: String }, |
16 | }).validator(), | 16 | }).validator(), |
17 | 17 | ||
18 | run({itemId}) { | 18 | run({itemId}) { |
19 | return {}; | 19 | return {}; |
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 | }); | ||
23 | 88 |
imports/collections/staff/publications.js
1 | import { Meteor } from 'meteor/meteor'; | 1 | import { Meteor } from 'meteor/meteor'; |
2 | import { check, Match } from 'meteor/check' | 2 | import { check, Match } from 'meteor/check' |
3 | 3 | ||
4 | import { Orgs } from '/imports/collections/orgs/index'; | 4 | import { Orgs } from '/imports/collections/orgs/index'; |
5 | import { Users } from '/imports/collections/users/index'; | 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 | const user = Users.findOne({_id: this.userId}); | 9 | const user = Users.findOne({_id: this.userId}); |
10 | if(!user) return []; | 10 | if(!user) return []; |
11 | return Teachers.find({orgId: user.orgId}); | 11 | return Staffs.find({orgId: user.orgId}); |
12 | }); | 12 | }); |
13 | 13 |
imports/collections/staff/serverCsvUpload.js
1 | // import { } from '/imports/collections/staff/methods'; | 1 | // import { } from '/imports/collections/staff/methods'; |
2 | import _ from 'lodash'; | 2 | import _ from 'lodash'; |
3 | import { Meteor } from 'meteor/meteor'; | 3 | import { Meteor } from 'meteor/meteor'; |
4 | import Papa from 'meteor/harrison:papa-parse' | 4 | import Papa from 'meteor/harrison:papa-parse' |
5 | import csv from 'csv2json-convertor' | 5 | import csv from 'csv2json-convertor' |
6 | import { ValidatedMethod } from 'meteor/mdg:validated-method'; | 6 | import { ValidatedMethod } from 'meteor/mdg:validated-method'; |
7 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; | 7 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; |
8 | import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; | 8 | import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; |
9 | import { Bert } from 'meteor/themeteorchef:bert'; | 9 | import { Bert } from 'meteor/themeteorchef:bert'; |
10 | import { Users } from '/imports/collections/users/index'; | 10 | import { Users } from '/imports/collections/users/index'; |
11 | import { Orgs } from '/imports/collections/orgs/index'; | 11 | import { Orgs } from '/imports/collections/orgs/index'; |
12 | import { Students } from '/imports/collections/students/index' | 12 | import { Students } from '/imports/collections/students/index' |
13 | import { Parents } from '/imports/collections/parents/index'; | 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 | import csv1 from 'csv2json-convertor' | 15 | import csv1 from 'csv2json-convertor' |
16 | import json2csv from 'json2csv' | 16 | import json2csv from 'json2csv' |
17 | import fs from 'fs' | 17 | import fs from 'fs' |
18 | import Validation from '/imports/validation/validationMethods'; | 18 | import Validation from '/imports/validation/validationMethods'; |
19 | import Constants from '/imports/constants/constants' | 19 | import Constants from '/imports/constants/constants' |
20 | 20 | ||
21 | export const staffCsvtMethod = new ValidatedMethod({ | 21 | export const staffCsvtMethod = new ValidatedMethod({ |
22 | name: 'staff.csvMethod', | 22 | name: 'staff.csvMethod', |
23 | 23 | ||
24 | validate: new SimpleSchema({ | 24 | validate: new SimpleSchema({ |
25 | itemId: { type: String }, | 25 | itemId: { type: String }, |
26 | }).validator(), | 26 | }).validator(), |
27 | 27 | ||
28 | run({itemId}) { | 28 | run({itemId}) { |
29 | return {}; | 29 | return {}; |
30 | }, | 30 | }, |
31 | 31 | ||
32 | }); | 32 | }); |
33 | 33 | ||
34 | export const staffSaveCsvData = new ValidatedMethod({ | 34 | export const staffSaveCsvData = new ValidatedMethod({ |
35 | name: 'staff.saveCsvData', | 35 | name: 'staff.saveCsvData', |
36 | 36 | ||
37 | validate: null, | 37 | validate: null, |
38 | 38 | ||
39 | run({item,filename,csv_fiels}) { | 39 | run({item,filename,csv_fiels}) { |
40 | var csv = json2csv({ | 40 | var csv = json2csv({ |
41 | data: item, | 41 | data: item, |
42 | fields: csv_fiels | 42 | fields: csv_fiels |
43 | }); | 43 | }); |
44 | fs.writeFile(filename, csv,function(err) { | 44 | fs.writeFile(filename, csv,function(err) { |
45 | if (err) throw err; | 45 | if (err) throw err; |
46 | }); | 46 | }); |
47 | }, | 47 | }, |
48 | }); | 48 | }); |
49 | 49 | ||
50 | export const addStaffCSV= new ValidatedMethod({ | 50 | export const addStaffCSV= new ValidatedMethod({ |
51 | name: 'staff.addCSV', | 51 | name: 'staff.addCSV', |
52 | 52 | ||
53 | validate: null, | 53 | validate: null, |
54 | 54 | ||
55 | run(item){ | 55 | run(item){ |
56 | data = item ; | 56 | data = item ; |
57 | console.log("data"); | 57 | console.log("data"); |
58 | console.log(data); | 58 | console.log(data); |
59 | // return true; | 59 | // return true; |
60 | const user = Users.findOne({_id: this.userId}); | 60 | const user = Users.findOne({_id: this.userId}); |
61 | orgId = user.orgId; | 61 | orgId = user.orgId; |
62 | newStaffId = Users.insert({ | 62 | newStaffId = Users.insert({ |
63 | // emails: [{address:data.email, verified: false}], | 63 | // emails: [{address:data.email, verified: false}], |
64 | //username: data["First Name*"], | 64 | //username: data["First Name*"], |
65 | firstName: data["First Name*"], | 65 | firstName: data["First Name*"], |
66 | lastName: data['Last Name*'], | 66 | lastName: data['Last Name*'], |
67 | orgId: orgId, | 67 | orgId: orgId, |
68 | role: 'STAFF' | 68 | role: 'STAFF' |
69 | }); | 69 | }); |
70 | console.log("newStaffId"); | 70 | console.log("newStaffId"); |
71 | console.log(newStaffId); | 71 | console.log(newStaffId); |
72 | if(newStaffId){ | 72 | if(newStaffId){ |
73 | Staffs.insert({ | 73 | Staffs.insert({ |
74 | userId: newStaffId, | 74 | userId: newStaffId, |
75 | orgId: orgId, | 75 | orgId: orgId, |
76 | admissionId: data['Student Admission ID*'], | 76 | admissionId: data['Student Admission ID*'], |
77 | address: data['Student Admission ID*'], | 77 | address: data['Student Admission ID*'], |
78 | gender: data['Gender(male/female)*'], | 78 | gender: data['Gender(male/female)*'], |
79 | dob: data['Birthday(YYYY-MM-DD)*'], | 79 | dob: data['Birthday(YYYY-MM-DD)*'], |
80 | rollNo: data['Student Roll*'], | 80 | rollNo: data['Student Roll*'], |
81 | class: data['Student Class Name*'], | 81 | class: data['Student Class Name*'], |
82 | section: data['Student Section Name*'], | 82 | section: data['Student Section Name*'], |
83 | bloodGroup: data['Blood Group*'], | 83 | bloodGroup: data['Blood Group*'], |
84 | community: data['Community'], | 84 | community: data['Community'], |
85 | parent: [{id: newParentUserId, relatinship: data['Parent Relation*']}] | 85 | parent: [{id: newParentUserId, relatinship: data['Parent Relation*']}] |
86 | }); | 86 | }); |
87 | } | 87 | } |
88 | return {newStudentId}; | 88 | return {newStudentId}; |
89 | }, | 89 | }, |
90 | 90 | ||
91 | }); | 91 | }); |
92 | 92 | ||
93 | export const staffUploadCsv = new ValidatedMethod({ | 93 | export const staffUploadCsv = new ValidatedMethod({ |
94 | name: 'staff.uploadCsv', | 94 | name: 'staff.uploadCsv', |
95 | 95 | ||
96 | validate: null, | 96 | validate: null, |
97 | 97 | ||
98 | run({data}) { | 98 | run({data}) { |
99 | let validation = new Validation(); | 99 | let validation = new Validation(); |
100 | let constants = new Constants(); | 100 | let constants = new Constants(); |
101 | //console.log("++++++++++++++++++++++++"+constants.csv_students_data()); | 101 | //console.log("++++++++++++++++++++++++"+constants.csv_students_data()); |
102 | temp = constants.csv_students_data(); | 102 | temp = constants.csv_students_data(); |
103 | console.log(temp); | 103 | console.log(temp); |
104 | var CSV_valid_buffer = []; | 104 | var CSV_valid_buffer = []; |
105 | var CSV_invalid_buffer = []; | 105 | var CSV_invalid_buffer = []; |
106 | var filename = new Date().getTime().toString(); | 106 | var filename = new Date().getTime().toString(); |
107 | var csv_filepath = './CSV_Files/'; | 107 | var csv_filepath = './CSV_Files/'; |
108 | for (let i = 0; i < data.length; i++) | 108 | for (let i = 0; i < data.length; i++) |
109 | { | 109 | { |
110 | let item = data[i]; | 110 | let item = data[i]; |
111 | delete item['Errors']; | 111 | delete item['Errors']; |
112 | var formate_validation = 1; | 112 | var formate_validation = 1; |
113 | var is_not_null = 1; | 113 | var is_not_null = 1; |
114 | var errors = []; | 114 | var errors = []; |
115 | for (var key in item){ | 115 | for (var key in item){ |
116 | var value = item[key]; | 116 | var value = item[key]; |
117 | var n = key.indexOf("*"); | 117 | var n = key.indexOf("*"); |
118 | if(n!=-1) { | 118 | if(n!=-1) { |
119 | if(!(validation.notNull(value))) | 119 | if(!(validation.notNull(value))) |
120 | { | 120 | { |
121 | errors.push(key+"is Empty"); | 121 | errors.push(key+"is Empty"); |
122 | } | 122 | } |
123 | is_not_null = is_not_null && validation.notNull(value); | 123 | is_not_null = is_not_null && validation.notNull(value); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | var formate_validation = validation.validateEmail(item["Parent Email*"]) && validation.mobileNumber(item["Parent Mobile*"]) ; //&& validation.validateEmail(item["Parent Mobile"]) ); | 126 | var formate_validation = validation.validateEmail(item["Parent Email*"]) && validation.mobileNumber(item["Parent Mobile*"]) ; //&& validation.validateEmail(item["Parent Mobile"]) ); |
127 | 127 | ||
128 | if (!(validation.validateEmail(item["Parent Email*"]))){ | 128 | if (!(validation.validateEmail(item["Parent Email*"]))){ |
129 | errors.push('Parent Email is invalid'); | 129 | errors.push('Parent Email is invalid'); |
130 | } | 130 | } |
131 | if (!(validation.mobileNumber(item["Parent Mobile*"]))) | 131 | if (!(validation.mobileNumber(item["Parent Mobile*"]))) |
132 | { | 132 | { |
133 | errors.push('Parent Mobile is invalid'); | 133 | errors.push('Parent Mobile is invalid'); |
134 | } | 134 | } |
135 | 135 | ||
136 | var is_valid = formate_validation && is_not_null ; | 136 | var is_valid = formate_validation && is_not_null ; |
137 | if (is_valid) | 137 | if (is_valid) |
138 | { | 138 | { |
139 | CSV_valid_buffer.push(item); | 139 | CSV_valid_buffer.push(item); |
140 | console.log("----------------------------------------1"); | 140 | console.log("----------------------------------------1"); |
141 | Meteor.call('student.addCSV',item); | 141 | Meteor.call('student.addCSV',item); |
142 | console.log("----------------------------------------2"); | 142 | console.log("----------------------------------------2"); |
143 | 143 | ||
144 | } | 144 | } |
145 | else | 145 | else |
146 | { | 146 | { |
147 | var str = errors.toString(); | 147 | var str = errors.toString(); |
148 | item.Errors = str; | 148 | item.Errors = str; |
149 | CSV_invalid_buffer.push(item); | 149 | CSV_invalid_buffer.push(item); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | console.log(csv_filepath+filename+"_CSV_invalid_data"+".csv"); | 152 | console.log(csv_filepath+filename+"_CSV_invalid_data"+".csv"); |
153 | Meteor.call('staff.saveCsvData',{ item : CSV_invalid_buffer, filename: csv_filepath+filename+"_CSV_invalid_data"+".csv",csv_fiels :constants.csv_students_data()}); | 153 | Meteor.call('staff.saveCsvData',{ item : CSV_invalid_buffer, filename: csv_filepath+filename+"_CSV_invalid_data"+".csv",csv_fiels :constants.csv_students_data()}); |
154 | Meteor.call('staff.saveCsvData',{ item : CSV_valid_buffer,filename: csv_filepath+filename+"_CSV_valid_data"+".csv",csv_fiels :constants.csv_students_data()}); | 154 | Meteor.call('staff.saveCsvData',{ item : CSV_valid_buffer,filename: csv_filepath+filename+"_CSV_valid_data"+".csv",csv_fiels :constants.csv_students_data()}); |
155 | return {}; | 155 | return {}; |
156 | }, | 156 | }, |
157 | 157 | ||
158 | }); | 158 | }); |
159 | 159 |
imports/collections/users/index.js
1 | // import { Users } from '/imports/collections/users/index'; | 1 | // import { Users } from '/imports/collections/users/index'; |
2 | // import { Users } from '/imports/collections/users/index'; | 2 | // import { Users } from '/imports/collections/users/index'; |
3 | 3 | ||
4 | import _ from 'lodash'; | 4 | import _ from 'lodash'; |
5 | import { Meteor } from 'meteor/meteor'; | 5 | import { Meteor } from 'meteor/meteor'; |
6 | import { Mongo } from 'meteor/mongo'; | 6 | import { Mongo } from 'meteor/mongo'; |
7 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; | 7 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; |
8 | 8 | ||
9 | import { Orgs } from '/imports/collections/orgs/index'; | 9 | import { Orgs } from '/imports/collections/orgs/index'; |
10 | 10 | ||
11 | class User { | 11 | class User { |
12 | 12 | ||
13 | constructor(doc) { | 13 | constructor(doc) { |
14 | _.assign(this, doc); | 14 | _.assign(this, doc); |
15 | }; | 15 | }; |
16 | 16 | ||
17 | isEmailVerified() { | 17 | isEmailVerified() { |
18 | return !! _.find(this.emails, x => x.verified); | 18 | return !! _.find(this.emails, x => x.verified); |
19 | }; | 19 | }; |
20 | 20 | ||
21 | isPhoneVerified() { | 21 | isPhoneVerified() { |
22 | return !! _.find(this.phones, x => x.verified); | 22 | return !! _.find(this.phones, x => x.verified); |
23 | }; | 23 | }; |
24 | 24 | ||
25 | isIdentityVerified() { | 25 | isIdentityVerified() { |
26 | return !! _.find(this.identities, x => x.verified); | 26 | return !! _.find(this.identities, x => x.verified); |
27 | }; | 27 | }; |
28 | 28 | ||
29 | getRole() { | 29 | getRole() { |
30 | const org = Orgs.findOne({_id: this.orgId}); | 30 | const org = Orgs.findOne({_id: this.orgId}); |
31 | if(!org) return null; | 31 | if(!org) return null; |
32 | const connection = _.find(org.users, {userId: this._id}); | 32 | const connection = _.find(org.users, {userId: this._id}); |
33 | if(!connection) return null; | 33 | if(!connection) return null; |
34 | return connection.role; | 34 | return connection.role; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | getFullName() { | 37 | getFullName() { |
38 | return `${this.firstName} ${this.lastName}`; | 38 | return `${this.firstName} ${this.lastName}`; |
39 | }; | 39 | }; |
40 | getFirstName() { | 40 | getFirstName() { |
41 | return `${this.firstName}`; | 41 | return `${this.firstName}`; |
42 | }; | 42 | }; |
43 | getLastName() { | 43 | getLastName() { |
44 | return `${this.lastName}`; | 44 | return `${this.lastName}`; |
45 | }; | 45 | }; |
46 | getEmail() { | 46 | getEmail() { |
47 | return `${this.emails[0].address}`; | 47 | return `${this.emails[0].address}`; |
48 | }; | 48 | }; |
49 | getOrganization(){ | 49 | getOrganization(){ |
50 | return `${this.orgId}`; | 50 | return `${this.orgId}`; |
51 | }; | 51 | }; |
52 | 52 | ||
53 | getNameByUserId(userId){ | 53 | getNameByUserId(userId){ |
54 | var user = Users.findOne({"_id":userId}); | 54 | var user = Users.findOne({"_id":userId}); |
55 | return user.firstName + " " + user.lastName; | 55 | return user.firstName + " " + user.lastName; |
56 | } | 56 | } |
57 | getAvatarUrl() { | 57 | getAvatarUrl() { |
58 | let random = parseInt(this._id.substr(0, 4), 36); | 58 | let random = parseInt(this._id.substr(0, 4), 36); |
59 | random = '' + (random % 32); | 59 | random = '' + (random % 32); |
60 | while(random.length < 3) random = '0' + random; | 60 | while(random.length < 3) random = '0' + random; |
61 | return `/files/random/random${ random }.png`; | 61 | return `/files/random/random${ random }.png`; |
62 | }; | 62 | }; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | export { User }; | 65 | export { User }; |
66 | 66 | ||
67 | 67 | ||
68 | const transform = function(doc) { | 68 | const transform = function(doc) { |
69 | return new User(doc); | 69 | return new User(doc); |
70 | }; | 70 | }; |
71 | 71 | ||
72 | export const Users = { | 72 | export const Users = { |
73 | 73 | ||
74 | current: function() { | 74 | current: function() { |
75 | return Meteor.users.findOne({_id: Meteor.userId()}, _.extend({transform: transform})); | 75 | return Meteor.users.findOne({_id: Meteor.userId()}, _.extend({transform: transform})); |
76 | }, | 76 | }, |
77 | 77 | ||
78 | find: function(selector, options) { | 78 | find: function(selector, options) { |
79 | return Meteor.users.find(selector || {}, _.extend({transform: transform}, options)); | 79 | return Meteor.users.find(selector || {}, _.extend({transform: transform}, options)); |
80 | }, | 80 | }, |
81 | 81 | ||
82 | findOne: function(selector, options) { | 82 | findOne: function(selector, options) { |
83 | return Meteor.users.findOne(selector || {}, _.extend({transform: transform}, options)); | 83 | return Meteor.users.findOne(selector || {}, _.extend({transform: transform}, options)); |
84 | }, | 84 | }, |
85 | 85 | ||
86 | insert: _.bind(Meteor.users.insert, Meteor.users), | 86 | insert: _.bind(Meteor.users.insert, Meteor.users), |
87 | update: _.bind(Meteor.users.update, Meteor.users), | 87 | update: _.bind(Meteor.users.update, Meteor.users), |
88 | remove: _.bind(Meteor.users.remove, Meteor.users), | 88 | remove: _.bind(Meteor.users.remove, Meteor.users), |
89 | allow: _.bind(Meteor.users.allow, Meteor.users), | 89 | allow: _.bind(Meteor.users.allow, Meteor.users), |
90 | deny: _.bind(Meteor.users.deny, Meteor.users), | 90 | deny: _.bind(Meteor.users.deny, Meteor.users), |
91 | attachSchema: _.bind(Meteor.users.attachSchema, Meteor.users), | 91 | attachSchema: _.bind(Meteor.users.attachSchema, Meteor.users), |
92 | 92 | ||
93 | }; | 93 | }; |
94 | 94 | ||
95 | 95 | ||
96 | Users.deny({ | 96 | Users.deny({ |
97 | insert() { return true; }, | 97 | insert() { return true; }, |
98 | update() { return true; }, | 98 | update() { return true; }, |
99 | remove() { return true; }, | 99 | remove() { return true; }, |
100 | }); | 100 | }); |
101 | 101 | ||
102 | Users.roles = { | 102 | Users.roles = { |
103 | 'STUDENT': 'STUDENT', | 103 | 'STUDENT': 'STUDENT', |
104 | 'STAFF': 'STAFF', | 104 | 'STAFF': 'STAFF', |
105 | 'ADMIN': 'ADMIN', | 105 | 'ADMIN': 'ADMIN', |
106 | 'PARENT': 'PARENT' | 106 | 'PARENT': 'PARENT' |
107 | }; | 107 | }; |
108 | 108 | ||
109 | 109 | ||
110 | Users.schema = new SimpleSchema({ | 110 | Users.schema = new SimpleSchema({ |
111 | role: { type: String }, | 111 | role: { type: String }, |
112 | orgId: { type: String }, | 112 | orgId: { type: String }, |
113 | username: { type: String, optional: true }, | 113 | username: { type: String, optional: true }, |
114 | prefix: { type: String, optional: true }, | 114 | prefix: { type: String, optional: true }, |
115 | firstName: { type: String, optional: true }, | 115 | firstName: { type: String, optional: true }, |
116 | middlename: { type: String, optional: true }, | 116 | middlename: { type: String, optional: true }, |
117 | lastName: { type: String, optional: true }, | 117 | lastName: { type: String, optional: true }, |
118 | address: { type: String, optional: true, }, | ||
118 | gender: { type: String, optional: true }, | 119 | gender: { type: String, optional: true }, |
119 | dob: { type: String, optional: true }, | 120 | dob: { type: String, optional: true }, |
120 | emails: { | 121 | emails: { |
121 | type: [new SimpleSchema({ | 122 | type: [new SimpleSchema({ |
122 | address: { type: String, }, | 123 | address: { type: String, }, |
123 | verified: { type: Boolean, }, | 124 | verified: { type: Boolean, }, |
124 | })], | 125 | })], |
125 | optional: true | 126 | optional: true |
126 | }, | 127 | }, |
127 | phones: { | 128 | phones: { |
128 | type: [new SimpleSchema({ | 129 | type: [new SimpleSchema({ |
129 | country: { type: String, }, | 130 | country: { type: String, optional: true }, |
130 | prefix: { type: String, }, | 131 | prefix: { type: String, optional: true }, |
131 | number: { type: String, }, | 132 | number: { type: String, }, |
132 | verified: { type: Boolean, }, | 133 | verified: { type: Boolean, }, |
133 | })], | 134 | })], |
134 | optional: true | 135 | optional: true |
135 | }, | 136 | }, |
136 | 137 | ||
137 | services: { | 138 | services: { |
138 | type: Object, | 139 | type: Object, |
139 | optional: true, | 140 | optional: true, |
140 | blackbox: true, | 141 | blackbox: true, |
141 | }, | 142 | }, |
142 | 143 | ||
143 | isMetaUser: { type: Boolean, optional: true }, | 144 | isMetaUser: { type: Boolean, optional: true }, |
144 | 145 | ||
145 | createdAt: { type: Date, autoValue: function(){return new Date();}} | 146 | createdAt: { type: Date, autoValue: function(){return new Date();}} |
146 | 147 | ||
147 | }); | 148 | }); |
148 | 149 | ||
149 | Users.attachSchema(Users.schema); | 150 | Users.attachSchema(Users.schema); |
150 | 151 | ||
151 | Users.privateFields = { | 152 | Users.privateFields = { |
152 | orgId: 1, | 153 | orgId: 1, |
153 | address: 1, | 154 | address: 1, |
154 | 155 | ||
155 | firstName: 1, | 156 | firstName: 1, |
156 | lastName: 1, | 157 | lastName: 1, |
157 | emails: 1, | 158 | emails: 1, |
158 | phones: 1, | 159 | phones: 1, |
159 | 160 | ||
160 | isMetaUser: 1, | 161 | isMetaUser: 1, |
161 | createdAt: 1, | 162 | createdAt: 1, |
162 | }; | 163 | }; |
163 | 164 | ||
164 | Users.publicFields = { | 165 | Users.publicFields = { |
165 | firstName: 1, | 166 | firstName: 1, |
166 | lastName: 1, | 167 | lastName: 1, |
167 | emails: 1, | 168 | emails: 1, |
168 | 169 | ||
169 | createdAt: 1, | 170 | createdAt: 1, |
170 | }; | 171 | }; |
171 | 172 |
imports/collections/users/publications.js
1 | import { Meteor } from 'meteor/meteor'; | 1 | import { Meteor } from 'meteor/meteor'; |
2 | import { check, Match } from 'meteor/check' | 2 | import { check, Match } from 'meteor/check' |
3 | import { Users } from '/imports/collections/users/index'; | 3 | import { Users } from '/imports/collections/users/index'; |
4 | import { Orgs } from '/imports/collections/orgs/index'; | 4 | import { Orgs } from '/imports/collections/orgs/index'; |
5 | 5 | ||
6 | 6 | ||
7 | 7 | ||
8 | Meteor.publish('users.current', function() { | 8 | Meteor.publish('users.current', function() { |
9 | return Users.find({ | 9 | return Users.find({ |
10 | _id: this.userId, | 10 | _id: this.userId, |
11 | }); | 11 | }); |
12 | }); | 12 | }); |
13 | Meteor.publish('users.forMyOrg', function() { | 13 | Meteor.publish('users.forMyOrg', function() { |
14 | const user = Users.findOne({_id: this.userId}); | 14 | const user = Users.findOne({_id: this.userId}); |
15 | if(!user) return []; | 15 | if(!user) return []; |
16 | const org = Orgs.findOne({_id: user.orgId}); | 16 | const org = Orgs.findOne({_id: user.orgId}); |
17 | if(!org) return []; | 17 | if(!org) return []; |
18 | 18 | ||
19 | return Users.find({ | 19 | return Users.find({ |
20 | orgId: user.orgId,role:"STUDENT" | 20 | orgId: user.orgId |
21 | }); | 21 | }); |
22 | }); | 22 | }); |
23 | 23 |