diff --git a/imports/client/app/routes.js b/imports/client/app/routes.js index 949f049..cb6e497 100644 --- a/imports/client/app/routes.js +++ b/imports/client/app/routes.js @@ -23,7 +23,7 @@ import { importCsvController } from '/imports/client/views/org/impo //admin import { StudentDataController } from '/imports/client/views/org/admin/students/index' -import { teachersViewController } from '/imports/client/views/org/admin/teachers/index' +import { staffViewController } from '/imports/client/views/org/admin/staff/index' //students //teachers @@ -55,7 +55,7 @@ const getOrgRoutes = () => ( - + @@ -107,7 +107,7 @@ const detectOrg = () => { orgSlug = hostnameArray[1]; } } - + if(orgSlug!==""){ console.log(orgSlug); Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) { diff --git a/imports/client/views/org/admin/AdminLayout.js b/imports/client/views/org/admin/AdminLayout.js index a15ada1..c61c10e 100644 --- a/imports/client/views/org/admin/AdminLayout.js +++ b/imports/client/views/org/admin/AdminLayout.js @@ -47,7 +47,7 @@ export class AdminAppLayout extends Component {
- +
diff --git a/imports/client/views/org/admin/Header.js b/imports/client/views/org/admin/Header.js index 876934f..df66b46 100644 --- a/imports/client/views/org/admin/Header.js +++ b/imports/client/views/org/admin/Header.js @@ -39,7 +39,7 @@ export class Header extends Component {
- +
diff --git a/imports/client/views/org/admin/staff/StaffView.js b/imports/client/views/org/admin/staff/StaffView.js new file mode 100644 index 0000000..e6a0da9 --- /dev/null +++ b/imports/client/views/org/admin/staff/StaffView.js @@ -0,0 +1,107 @@ +import _ from 'lodash'; +import { Meteor } from 'meteor/meteor'; + +import React, { Component } from 'react'; +import { Link,browserHistory } from 'react-router'; +import { FormGroup, + FormControl,Glyphicon,Button } from 'react-bootstrap'; +import { Header } from '../Header'; +import { AdminSidebar } from '../Sidebar' +import { AdminBreadcrumb } from '../Breadcrumb' +import { StaffTable } from './view/StaffTable' +import { AddTeacher } from './add/addTeacher' +import { UploadCsvTeacher } from './UploadCsvTeacher' + +export class StaffView extends Component { + constructor(props) { + super(props); + this.state = { + + }; + this.onUpdate = this.onUpdate.bind(this); + }; + + onUpdate(key, value) { + this.setState({[key]: value}); + }; + + render() { + const {user, org, staff} = this.props.data; + return ( +
+
+
+ +
+ + +
+
+
+
+ + + +
+
+
+
+
+ +
+
+ Advanced Search +
    +
  • +
+
+ +
+
+
+ this.onUpdate('firstNameSearch',e.target.value)} + placeholder="First Name" + /> +
+ +
+
+
+
+
+
+
+ this.onUpdate('lastNameSearch',e.target.value)} + placeholder="Last Name" /> +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ ); + }; + +}; diff --git a/imports/client/views/org/admin/staff/UploadCsvTeacher.js b/imports/client/views/org/admin/staff/UploadCsvTeacher.js new file mode 100644 index 0000000..bd22a00 --- /dev/null +++ b/imports/client/views/org/admin/staff/UploadCsvTeacher.js @@ -0,0 +1,103 @@ +// import {UploadCsv } from '/imports/collections/students/UploadCsv' +import _ from 'lodash'; +import { Meteor } from 'meteor/meteor'; + +import React, { Component } from 'react'; +import { Link,browserHistory } from 'react-router'; +import { FormGroup,Panel,Table, + ButtonToolbar,Modal,ControlLabel,HelpBlock, + FormControl,Glyphicon,Button } from 'react-bootstrap'; +// import { AddStudentForm } from './addStudentForm'; +import { FilesCollection } from 'meteor/ostrio:files'; +const Papa = this.Papa; +// console.log(this); +const style = { + margin: 12, +}; +function FieldGroup({ id, label, help, ...props }) { + return ( + + {label} + + {help && {help}} + + ); +} +export class UploadCsvTeacher extends Component { + constructor(props) { + super(props); + this.state = { + show: false + }; + this.showModal = this.showModal.bind(this); + this.hideModal = this.hideModal.bind(this); + this.onUpdate = this.onUpdate.bind(this); + }; + + showModal() { + this.setState({show: true}); + } + + hideModal() { + this.setState({show: false}); + } + onUpdate(key, value) { + this.setState({[key]: value}); + }; + uploadStudentCsv(e){ + e.preventDefault(); + e.persist(); + var file = $('input[type="file"]').prop("files")[0]; + Papa.parse(file, { + header: true, + complete: function(csvData) { + console.log("csvData"); + console.log(csvData); + if(csvData){ + Meteor.call('teachers.uploadCsv', csvData, function (error, result) { + console.log("error"); + console.log(error); + console.log("result"); + console.log(result); + }) + } + } + }); + } + + render() { + console.log(this.props); + return ( + + + + + Upload Csv + + +
this.uploadStudentCsv(e) } > + + + +
+ + + +
+
+ ); + }; + +}; diff --git a/imports/client/views/org/admin/staff/add/AddTeacherFormContainer.js b/imports/client/views/org/admin/staff/add/AddTeacherFormContainer.js new file mode 100644 index 0000000..b4e5a19 --- /dev/null +++ b/imports/client/views/org/admin/staff/add/AddTeacherFormContainer.js @@ -0,0 +1,95 @@ +import React, { Component } from 'react' +import StudentForm from './TeacherForm' +import Form from '/imports/client/views/core/Form' +import Validator from '/imports/client/views/core/Validator' +import { isRequired, isValidEmail } from '/imports/client/views/core/validations' +import { addStudentManually } from '/imports/collections/students/methods'; + +export class AddStudentFormContainer extends Component { + + constructor(props) { + super(props) + this.state = { currentStep: 0 } + this.handleNextClick = this.handleNextClick.bind(this) + this.handleBackClick = this.handleBackClick.bind(this) + this.handleSubmit = this.handleSubmit.bind(this) + } + + handleNextClick() { + this.form.handleSubmit() + if (this.validator.getErrors() && Object.keys(this.validator.getErrors()).length > 0) return + this.setState({ currentStep: this.state.currentStep + 1 }) + this.form.resetSubmitted() + } + + handleBackClick() { + this.setState({ currentStep: this.state.currentStep + -1 }) + } + + handleSubmit() { + if (this.state.currentStep === 3) { + addStudentManually.call(this.form.state.values) + } + } + + //render callback + render() { + return ( +
this.form = form} + initialValues={{ + gender: 'male', + parentGender: 'male', + }} + > + {({ values, setValue, getValue, isSubmitted, isDirty }) => ( + this.validator = validator} + validations={{ + admissionId: [(value) => isRequired('Admission id', value)], + firstName: [(value) => isRequired('First name', value)], + lastName: [(value) => isRequired('Last name', value)], + email: [(value) => isRequired('Email', value), isValidEmail], + dob: [(value) => isRequired('Date of birth', value)], + gender: [(value) => isRequired('Gender', value)], + rollNo: [(value) => this.state.currentStep === 1 && isRequired('Roll no', value)], + studentClass: [(value) => this.state.currentStep === 1 && isRequired('Class', value)], + section: [(value) => this.state.currentStep === 1 && isRequired('Section', value)], + community: [(value) => this.state.currentStep === 1 && isRequired('Community', value)], + bloodGroup: [(value) => this.state.currentStep === 1 && isRequired('Blood group', value)], + phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], + address: [(value) => this.state.currentStep === 2 && isRequired('Address', value)], + city: [(value) => this.state.currentStep === 2 && isRequired('City', value)], + state: [(value) => this.state.currentStep === 2 && isRequired('State', value)], + parentName: [(value) => this.state.currentStep === 3 && isRequired('Parent name', value)], + parentEmail: [(value) => this.state.currentStep === 3 && isRequired('Parent email', value), (value) => this.state.currentStep === 3 && isValidEmail(value)], + relation: [(value) => this.state.currentStep === 3 && isRequired('Relation', value)], + profession: [(value) => this.state.currentStep === 3 && isRequired('Profession', value)], + parentGender: [(value) => this.state.currentStep === 3 && isRequired('Parent gender', value)], + parentPhone: [(value) => this.state.currentStep === 3 && isRequired('Parent phone', value)], + parentAddress: [(value) => this.state.currentStep === 3 && isRequired('Parent address', value)], + parentCity: [(value) => this.state.currentStep === 3 && isRequired('Parent city', value)], + parentState: [(value) => this.state.currentStep === 3 && isRequired('Parent state', value)], + parentZipcode: [(value) => this.state.currentStep === 3 && isRequired('Parent zip code', value)], + }} + > + {({ errors }) => ( + + )} + + )} +
+ ) + } +} diff --git a/imports/client/views/org/admin/staff/add/TeacherForm.js b/imports/client/views/org/admin/staff/add/TeacherForm.js new file mode 100644 index 0000000..95d7757 --- /dev/null +++ b/imports/client/views/org/admin/staff/add/TeacherForm.js @@ -0,0 +1,521 @@ +import React, { PropTypes } from 'react' +import { + Row, + Col, + FormGroup, + FormControl, + Button +} from 'react-bootstrap' +import DatePicker from '/imports/client/views/core/DatePicker' +import Label from '/imports/client/views/core/Label' +import Stepper from '/imports/client/views/core/Stepper' +import ErrorLabel from '/imports/client/views/core/ErrorLabel' + +const StudentForm = props => ( +
+ + {props.currentStep === 0 && ( +
+ Personal data + + + + + props.setValue('admissionId', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.admissionId && ( + {props.errors.admissionId} + )} + + + + + + + props.setValue('firstName', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.firstName && ( + {props.errors.firstName} + )} + + + + + + + props.setValue('lastName', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.lastName && ( + {props.errors.lastName} + )} + + + + + + + + props.setValue('gender', e.target.value)} + > + + + + {props.isSubmitted() && props.errors && props.errors.gender && ( + {props.errors.gender} + )} + + + + + + + props.setValue('martialStatus', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.martialStatus && ( + {props.errors.martialStatus} + )} + + + + + + + { + props.setValue('dob', e.target.value) + }} + /> + {props.isSubmitted() && props.errors && props.errors.dob && ( + {props.errors.dob} + )} + + + + + + + + props.setValue('email', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.email && ( + {props.errors.email} + )} + + + + + + + props.setValue('gender', e.target.value)} + > + + + + {props.isSubmitted() && props.errors && props.errors.gender && ( + {props.errors.gender} + )} + + + + + + + +
+ )} + {props.currentStep === 1 && ( +
+ Academic + + + + + props.setValue('rollNo', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.rollNo && ( + {props.errors.rollNo} + )} + + + + + + props.setValue('studentClass', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.studentClass && ( + {props.errors.studentClass} + )} + + + + + + + + props.setValue('section', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.section && ( + {props.errors.section} + )} + + + + + + props.setValue('community', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.community && ( + {props.errors.community} + )} + + + + + + + + props.setValue('bloodGroup', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.bloodGroup && ( + {props.errors.bloodGroup} + )} + + + + + + props.setValue('phone', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.phone && ( + {props.errors.phone} + )} + + + +
+ )} + {props.currentStep === 2 && ( +
+ Address + + + + + props.setValue('address', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.address && ( + {props.errors.address} + )} + + + + + + props.setValue('city', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.city && ( + {props.errors.city} + )} + + + + + + + + props.setValue('state', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.state && ( + {props.errors.state} + )} + + + +
+ )} + {props.currentStep === 3 && ( +
+ Parent information + + + + + props.setValue('parentName', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.parentName && ( + {props.errors.parentName} + )} + + + + + + props.setValue('parentEmail', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.parentEmail && ( + {props.errors.parentEmail} + )} + + + + + + + + props.setValue('relation', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.relation && ( + {props.errors.relation} + )} + + + + + + props.setValue('profession', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.profession && ( + {props.errors.profession} + )} + + + + + + + + props.setValue('parentGender', e.target.value)} + > + + + + {props.isSubmitted() && props.errors && props.errors.parentGender && ( + {props.errors.parentGender} + )} + + + + + + props.setValue('parentPhone', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.parentPhone && ( + {props.errors.parentPhone} + )} + + + + + + + + props.setValue('parentAddress', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.parentAddress && ( + {props.errors.parentAddress} + )} + + + + + + props.setValue('parentCity', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.parentCity && ( + {props.errors.parentCity} + )} + + + + + + + + props.setValue('parentState', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.parentState && ( + {props.errors.parentState} + )} + + + + + + props.setValue('parentZipcode', e.target.value)} + /> + {props.isSubmitted() && props.errors && props.errors.parentZipcode && ( + {props.errors.parentZipcode} + )} + + + +
+ )} +
+ {props.currentStep > 0 && ( +
+ + +
+ )} + {props.currentStep < 3 && ( +
+ +
+ )} + {props.currentStep === 3 && ( +
+ +
+ )} +
+
+) + +StudentForm.propTypes = { + currentStep: PropTypes.number.isRequired, + onNextClick: PropTypes.func.isRequired, + onBackClick: PropTypes.func.isRequired, + setValue: PropTypes.func.isRequired, + getValue: PropTypes.func.isRequired, +} + +export default StudentForm diff --git a/imports/client/views/org/admin/staff/add/addTeacher.js b/imports/client/views/org/admin/staff/add/addTeacher.js new file mode 100644 index 0000000..051b69b --- /dev/null +++ b/imports/client/views/org/admin/staff/add/addTeacher.js @@ -0,0 +1,64 @@ +import _ from 'lodash'; +import { Meteor } from 'meteor/meteor'; +import React, { Component } from 'react'; +import { Link,browserHistory } from 'react-router'; +import { FormGroup,Panel,Table, + ButtonToolbar,Modal, + FormControl,Glyphicon,Button } from 'react-bootstrap'; +import { AddStudentFormContainer } from './AddTeacherFormContainer'; + +const style = { + margin: 12, +}; +export class AddTeacher extends Component { + constructor(props) { + super(props); + this.state = { + show: false + }; + this.showModal = this.showModal.bind(this); + this.hideModal = this.hideModal.bind(this); + this.onUpdate = this.onUpdate.bind(this); + }; + + showModal() { + this.setState({show: true}); + } + + hideModal() { + this.setState({show: false}); + } + onUpdate(key, value) { + this.setState({[key]: value}); + }; + + render() { + return ( + + + + + Add New Staff + + + + + {/* + + + + */} + + + ); + }; + +}; diff --git a/imports/client/views/org/admin/staff/index.js b/imports/client/views/org/admin/staff/index.js new file mode 100644 index 0000000..609edc2 --- /dev/null +++ b/imports/client/views/org/admin/staff/index.js @@ -0,0 +1,60 @@ +// import { InviteSignupController } from '/imports/client/views/invite/signup/index' +import _ from 'lodash'; +import { + composeWithTracker, + compose, + composeAll + } from 'react-komposer'; +import { Loading } from '/imports/client/components/Loading'; + +import { Orgs } from '/imports/collections/orgs/index'; +import { Users } from '/imports/collections/users/index'; +import { Staffs } from '/imports/collections/staff/index'; +import { StaffView } from './StaffView'; + +const meteorTick = (props, onData) => { + + const handles = [ + Meteor.subscribe('users.current'), + Meteor.subscribe('orgs.current') + ]; + + if(_.every(handles, (handle) => (handle.ready()) )) { + const user = Users.current(); + const org = Orgs.current(); + staff = Users.find({"role":"STAFF"}).fetch() ? Users.find({"role":"TEACHER"}).fetch() : ""; + staffData = Staffs.find().fetch() ? Staffs.find().fetch() : ""; + for(var i=0; i< staff.length; i++){ + for(var j=0; j< staff.length; j++){ + if(staff[i]._id == staffData[j].userId){ + staff[i].class = staffData[j].class; + staff[i].dob = staffData[j].dob; + } + } + } + onData(null, { + data: { + user: user, + org: org, + staff: staff + }, + }); + } + + return () => { + _.each(handles, (handle) => handle.stop() ); + }; +}; + + +const reduxTick = (props, onData) => { + onData(null, { + data: {} + }); +}; + + +export const staffViewController = composeAll( + composeWithTracker(meteorTick, Loading), + compose(reduxTick, Loading), +)(StaffView); diff --git a/imports/client/views/org/admin/staff/view/StaffTable.js b/imports/client/views/org/admin/staff/view/StaffTable.js new file mode 100644 index 0000000..ddf9bc7 --- /dev/null +++ b/imports/client/views/org/admin/staff/view/StaffTable.js @@ -0,0 +1,65 @@ +import _ from 'lodash'; +import { Meteor } from 'meteor/meteor'; + +import React, { Component } from 'react'; +import { Link,browserHistory } from 'react-router'; +import { FormGroup,Panel,Table, + ButtonToolbar,Modal, + FormControl,Glyphicon,Button } from 'react-bootstrap'; +import {moment} from 'meteor/momentjs:moment' +import {TeachersRow} from './TeachersRow' + +export class StaffTable extends Component { + + constructor(props) { + super(props); + this.state = { + show: false + }; + this.onUpdate = this.onUpdate.bind(this); + }; + onUpdate(key, value) { + this.setState({[key]: value}); + }; + + render() { + return ( +
+
+
Teachers Details
+
+
    +
  • +
  • +
+
+
+ + + + + + + + + + + + + { + this.props.staff.map(function(student, i) + { + return( + + ) + }) + } + +
First NameLast NameClassDOBStatusActions
+
+ ); + }; + +}; diff --git a/imports/client/views/org/admin/staff/view/TeachersRow.js b/imports/client/views/org/admin/staff/view/TeachersRow.js new file mode 100644 index 0000000..2cd6950 --- /dev/null +++ b/imports/client/views/org/admin/staff/view/TeachersRow.js @@ -0,0 +1,56 @@ +import _ from 'lodash'; +import { Meteor } from 'meteor/meteor'; + +import React, { Component } from 'react'; +import { Link,browserHistory } from 'react-router'; +import { FormGroup, + FormControl,Glyphicon,Button } from 'react-bootstrap'; + + +export class teachersRow extends Component { + + constructor(props) { + super(props); + this.state = { + + }; + this.onUpdate = this.onUpdate.bind(this); + }; + + onUpdate(key, value) { + this.setState({[key]: value}); + }; + + render() { + const {student} = this.props; + if(student.firstName){ + return ( + + {student.firstName} + {student.lastName} + {student.class} + {student.dob? moment(student.dob).format("LL") : } + Active + + + + + ); + }else { + return null; + } + + }; + +}; diff --git a/imports/client/views/org/admin/students/UploadCsv.js b/imports/client/views/org/admin/students/UploadCsv.js index dc50c45..78dfc52 100644 --- a/imports/client/views/org/admin/students/UploadCsv.js +++ b/imports/client/views/org/admin/students/UploadCsv.js @@ -79,7 +79,7 @@ export class UploadCsv extends Component { dialogClassName="custom-modal" > - New Student + Upload Csv file
this.uploadStudentCsv(e) } > diff --git a/imports/client/views/org/admin/students/add/addStudent.js b/imports/client/views/org/admin/students/add/addStudent.js index 14c9129..dc67039 100644 --- a/imports/client/views/org/admin/students/add/addStudent.js +++ b/imports/client/views/org/admin/students/add/addStudent.js @@ -45,7 +45,7 @@ export class AddStudent extends Component { dialogClassName="custom-modal" > - New Student + Add Student diff --git a/imports/client/views/org/admin/teachers/TeacherView.js b/imports/client/views/org/admin/teachers/TeacherView.js deleted file mode 100644 index 748b842..0000000 --- a/imports/client/views/org/admin/teachers/TeacherView.js +++ /dev/null @@ -1,107 +0,0 @@ -import _ from 'lodash'; -import { Meteor } from 'meteor/meteor'; - -import React, { Component } from 'react'; -import { Link,browserHistory } from 'react-router'; -import { FormGroup, - FormControl,Glyphicon,Button } from 'react-bootstrap'; -import { Header } from '../Header'; -import { AdminSidebar } from '../Sidebar' -import { AdminBreadcrumb } from '../Breadcrumb' -import { TeachersTable } from './view/TeachersTable' -import { AddTeacher } from './add/addTeacher' -import { UploadCsvTeacher } from './UploadCsvTeacher' - -export class TeachersView extends Component { - constructor(props) { - super(props); - this.state = { - - }; - this.onUpdate = this.onUpdate.bind(this); - }; - - onUpdate(key, value) { - this.setState({[key]: value}); - }; - - render() { - const {user, org, teachers, teachersData} = this.props.data; - return ( -
-
-
- -
- - -
-
-
-
- - - -
-
-
-
-
- -
-
- Advanced Search -
    -
  • -
-
- -
- -
- this.onUpdate('firstNameSearch',e.target.value)} - placeholder="First Name" - /> -
- -
-
- -
-
-
-
- this.onUpdate('lastNameSearch',e.target.value)} - placeholder="Last Name" /> -
- -
-
-
-
-
-
-
-
-
-
-
-
-
- ); - }; - -}; diff --git a/imports/client/views/org/admin/teachers/UploadCsvTeacher.js b/imports/client/views/org/admin/teachers/UploadCsvTeacher.js deleted file mode 100644 index ddac363..0000000 --- a/imports/client/views/org/admin/teachers/UploadCsvTeacher.js +++ /dev/null @@ -1,103 +0,0 @@ -// import {UploadCsv } from '/imports/collections/students/UploadCsv' -import _ from 'lodash'; -import { Meteor } from 'meteor/meteor'; - -import React, { Component } from 'react'; -import { Link,browserHistory } from 'react-router'; -import { FormGroup,Panel,Table, - ButtonToolbar,Modal,ControlLabel,HelpBlock, - FormControl,Glyphicon,Button } from 'react-bootstrap'; -// import { AddStudentForm } from './addStudentForm'; -import { FilesCollection } from 'meteor/ostrio:files'; -const Papa = this.Papa; -// console.log(this); -const style = { - margin: 12, -}; -function FieldGroup({ id, label, help, ...props }) { - return ( - - {label} - - {help && {help}} - - ); -} -export class UploadCsvTeacher extends Component { - constructor(props) { - super(props); - this.state = { - show: false - }; - this.showModal = this.showModal.bind(this); - this.hideModal = this.hideModal.bind(this); - this.onUpdate = this.onUpdate.bind(this); - }; - - showModal() { - this.setState({show: true}); - } - - hideModal() { - this.setState({show: false}); - } - onUpdate(key, value) { - this.setState({[key]: value}); - }; - uploadStudentCsv(e){ - e.preventDefault(); - e.persist(); - var file = $('input[type="file"]').prop("files")[0]; - Papa.parse(file, { - header: true, - complete: function(csvData) { - console.log("csvData"); - console.log(csvData); - if(csvData){ - Meteor.call('teachers.uploadCsv', csvData, function (error, result) { - console.log("error"); - console.log(error); - console.log("result"); - console.log(result); - }) - } - } - }); - } - - render() { - console.log(this.props); - return ( - - - - - New Student - - -
this.uploadStudentCsv(e) } > - - - -
- - - -
-
- ); - }; - -}; diff --git a/imports/client/views/org/admin/teachers/add/AddStudentFormContainer.js b/imports/client/views/org/admin/teachers/add/AddStudentFormContainer.js deleted file mode 100644 index 85ef828..0000000 --- a/imports/client/views/org/admin/teachers/add/AddStudentFormContainer.js +++ /dev/null @@ -1,96 +0,0 @@ -import React, { Component } from 'react' -import { AddStudentForm } from './addStudentForm' -import StudentForm from './StudentForm' -import Form from '/imports/client/views/core/Form' -import Validator from '/imports/client/views/core/Validator' -import { isRequired, isValidEmail } from '/imports/client/views/core/validations' -import { addStudentManually } from '/imports/collections/students/methods'; - -export class AddStudentFormContainer extends Component { - - constructor(props) { - super(props) - this.state = { currentStep: 0 } - this.handleNextClick = this.handleNextClick.bind(this) - this.handleBackClick = this.handleBackClick.bind(this) - this.handleSubmit = this.handleSubmit.bind(this) - } - - handleNextClick() { - this.form.handleSubmit() - if (this.validator.getErrors() && Object.keys(this.validator.getErrors()).length > 0) return - this.setState({ currentStep: this.state.currentStep + 1 }) - this.form.resetSubmitted() - } - - handleBackClick() { - this.setState({ currentStep: this.state.currentStep + -1 }) - } - - handleSubmit() { - if (this.state.currentStep === 3) { - addStudentManually.call(this.form.state.values) - } - } - - //render callback - render() { - return ( -
this.form = form} - initialValues={{ - gender: 'male', - parentGender: 'male', - }} - > - {({ values, setValue, getValue, isSubmitted, isDirty }) => ( - this.validator = validator} - validations={{ - admissionId: [(value) => isRequired('Admission id', value)], - firstName: [(value) => isRequired('First name', value)], - lastName: [(value) => isRequired('Last name', value)], - email: [(value) => isRequired('Email', value), isValidEmail], - dob: [(value) => isRequired('Date of birth', value)], - gender: [(value) => isRequired('Gender', value)], - rollNo: [(value) => this.state.currentStep === 1 && isRequired('Roll no', value)], - studentClass: [(value) => this.state.currentStep === 1 && isRequired('Class', value)], - section: [(value) => this.state.currentStep === 1 && isRequired('Section', value)], - community: [(value) => this.state.currentStep === 1 && isRequired('Community', value)], - bloodGroup: [(value) => this.state.currentStep === 1 && isRequired('Blood group', value)], - phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], - address: [(value) => this.state.currentStep === 2 && isRequired('Address', value)], - city: [(value) => this.state.currentStep === 2 && isRequired('City', value)], - state: [(value) => this.state.currentStep === 2 && isRequired('State', value)], - parentName: [(value) => this.state.currentStep === 3 && isRequired('Parent name', value)], - parentEmail: [(value) => this.state.currentStep === 3 && isRequired('Parent email', value), (value) => this.state.currentStep === 3 && isValidEmail(value)], - relation: [(value) => this.state.currentStep === 3 && isRequired('Relation', value)], - profession: [(value) => this.state.currentStep === 3 && isRequired('Profession', value)], - parentGender: [(value) => this.state.currentStep === 3 && isRequired('Parent gender', value)], - parentPhone: [(value) => this.state.currentStep === 3 && isRequired('Parent phone', value)], - parentAddress: [(value) => this.state.currentStep === 3 && isRequired('Parent address', value)], - parentCity: [(value) => this.state.currentStep === 3 && isRequired('Parent city', value)], - parentState: [(value) => this.state.currentStep === 3 && isRequired('Parent state', value)], - parentZipcode: [(value) => this.state.currentStep === 3 && isRequired('Parent zip code', value)], - }} - > - {({ errors }) => ( - - )} - - )} -
- ) - } -} diff --git a/imports/client/views/org/admin/teachers/add/StudentForm.js b/imports/client/views/org/admin/teachers/add/StudentForm.js deleted file mode 100644 index 2db920a..0000000 --- a/imports/client/views/org/admin/teachers/add/StudentForm.js +++ /dev/null @@ -1,485 +0,0 @@ -import React, { PropTypes } from 'react' -import { - Row, - Col, - FormGroup, - FormControl, - Button -} from 'react-bootstrap' -import DatePicker from '/imports/client/views/core/DatePicker' -import Label from '/imports/client/views/core/Label' -import Stepper from '/imports/client/views/core/Stepper' -import ErrorLabel from '/imports/client/views/core/ErrorLabel' - -const StudentForm = props => ( -
- - {props.currentStep === 0 && ( -
- Personal data - - - - - props.setValue('admissionId', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.admissionId && ( - {props.errors.admissionId} - )} - - - - - - props.setValue('firstName', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.firstName && ( - {props.errors.firstName} - )} - - - - - - - - props.setValue('lastName', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.lastName && ( - {props.errors.lastName} - )} - - - - - - props.setValue('gender', e.target.value)} - > - - - - {props.isSubmitted() && props.errors && props.errors.gender && ( - {props.errors.gender} - )} - - - - - - - - props.setValue('email', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.email && ( - {props.errors.email} - )} - - - - - - { - props.setValue('dob', e.target.value) - }} - /> - {props.isSubmitted() && props.errors && props.errors.dob && ( - {props.errors.dob} - )} - - - - - - -
- )} - {props.currentStep === 1 && ( -
- Academic - - - - - props.setValue('rollNo', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.rollNo && ( - {props.errors.rollNo} - )} - - - - - - props.setValue('studentClass', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.studentClass && ( - {props.errors.studentClass} - )} - - - - - - - - props.setValue('section', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.section && ( - {props.errors.section} - )} - - - - - - props.setValue('community', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.community && ( - {props.errors.community} - )} - - - - - - - - props.setValue('bloodGroup', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.bloodGroup && ( - {props.errors.bloodGroup} - )} - - - - - - props.setValue('phone', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.phone && ( - {props.errors.phone} - )} - - - -
- )} - {props.currentStep === 2 && ( -
- Address - - - - - props.setValue('address', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.address && ( - {props.errors.address} - )} - - - - - - props.setValue('city', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.city && ( - {props.errors.city} - )} - - - - - - - - props.setValue('state', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.state && ( - {props.errors.state} - )} - - - -
- )} - {props.currentStep === 3 && ( -
- Parent information - - - - - props.setValue('parentName', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.parentName && ( - {props.errors.parentName} - )} - - - - - - props.setValue('parentEmail', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.parentEmail && ( - {props.errors.parentEmail} - )} - - - - - - - - props.setValue('relation', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.relation && ( - {props.errors.relation} - )} - - - - - - props.setValue('profession', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.profession && ( - {props.errors.profession} - )} - - - - - - - - props.setValue('parentGender', e.target.value)} - > - - - - {props.isSubmitted() && props.errors && props.errors.parentGender && ( - {props.errors.parentGender} - )} - - - - - - props.setValue('parentPhone', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.parentPhone && ( - {props.errors.parentPhone} - )} - - - - - - - - props.setValue('parentAddress', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.parentAddress && ( - {props.errors.parentAddress} - )} - - - - - - props.setValue('parentCity', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.parentCity && ( - {props.errors.parentCity} - )} - - - - - - - - props.setValue('parentState', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.parentState && ( - {props.errors.parentState} - )} - - - - - - props.setValue('parentZipcode', e.target.value)} - /> - {props.isSubmitted() && props.errors && props.errors.parentZipcode && ( - {props.errors.parentZipcode} - )} - - - -
- )} -
- {props.currentStep > 0 && ( -
- - -
- )} - {props.currentStep < 3 && ( -
- -
- )} - {props.currentStep === 3 && ( -
- -
- )} -
-
-) - -StudentForm.propTypes = { - currentStep: PropTypes.number.isRequired, - onNextClick: PropTypes.func.isRequired, - onBackClick: PropTypes.func.isRequired, - setValue: PropTypes.func.isRequired, - getValue: PropTypes.func.isRequired, -} - -export default StudentForm diff --git a/imports/client/views/org/admin/teachers/add/addStudentForm.js b/imports/client/views/org/admin/teachers/add/addStudentForm.js deleted file mode 100644 index 9f41e25..0000000 --- a/imports/client/views/org/admin/teachers/add/addStudentForm.js +++ /dev/null @@ -1,500 +0,0 @@ -import _ from 'lodash'; -import { Meteor } from 'meteor/meteor'; - -import React, { Component } from 'react'; -import { Link,browserHistory } from 'react-router'; -import { Form, FormGroup,InputGroup, - DropdownButton,MenuItem,ControlLabel, - SplitButton, - FormControl,Glyphicon,Button } from 'react-bootstrap'; -import DatePicker from 'react-bootstrap-date-picker' -import {addStudentManually} from '/imports/collections/students/methods'; - -export class AddStudentForm extends Component { - - constructor(props) { - super(props); - this.state = { - admissionId: "123", - firstName: "first", - lastName: "last", - middleName: "middle", - email: "deepak125.dk+21@gmail.com", - dob: "", - formattedDob: "", - gender: "male", - rollNo: "1", - class: "2", - section: "B", - community: "SC", - bloodGroup: "B+", - phone: "9876543321", - address: "address", - city: "chennai", - state: "tn", - parentName: "parentName", - parentEmail: "deepak125.dk+41@gmail.com", - relation: "father", - profession: "farmer", - parentGender: "male", - parentPhone: "987655412", - parentAddress: "parentAddress", - parentCity: "parentCity", - parentState: "parentState", - parentZipcode: "parentZipcode", - }; - this.onUpdate = this.onUpdate.bind(this); - this.handleDob = this.handleDob.bind(this); - }; - - onUpdate(key, value) { - this.setState({[key]: value}); - }; - - handleDob(value, formattedValue) { - this.setState({ - dob: value, // ISO String, ex: "2016-11-19T12:00:00.000Z" - formattedDob: formattedValue // Formatted String, ex: "11/19/2016" - }); -} - addStudent(e){ - e.preventDefault(); - e.persist(); - const firstName = this.state.firstName; - const middleName = this.state.middleName; - const lastName = this.state.lastName; - const admissionId = this.state.admissionId; - const email = this.state.email; - const dob = this.state.dob; - const formattedDob = this.state.formattedDob; - const gender = this.state.gender; - const rollNo = this.state.rollNo; - const studentclass = this.state.class; - const section = this.state.section; - const community = this.state.community; - const bloodGroup = this.state.bloodGroup; - const phone = this.state.phone; - const address = this.state.address; - const city = this.state.city; - const state = this.state.state; - const parentName = this.state.parentName; - const parentEmail = this.state.parentEmail; - const relation = this.state.relation; - const profession = this.state.profession; - const parentGender = this.state.parentGender; - const parentPhone = this.state.parentPhone; - const parentAddress = this.state.parentAddress; - const parentCity = this.state.parentCity; - const parentState = this.state.parentState; - const parentZipcode = this.state.parentZipcode; - if(admissionId==""){ - Bert.alert('Enter Admission Id!', 'danger'); - }else if(firstName==""){ - Bert.alert('Enter Fist Name', 'danger'); - } else if(middleName==""){ - Bert.alert('Enter Middle name!', 'danger'); - }else if(lastName==""){ - Bert.alert('Enter Last name!', 'danger'); - }else if(email==""){ - Bert.alert('Enter email!', 'danger'); - }else if(dob==""){ - Bert.alert('Enter DOB!', 'danger'); - }else if(gender==""){ - Bert.alert('Enter Student Gender!', 'danger'); - }else if(studentclass==""){ - Bert.alert('Enter Class!', 'danger'); - }else if(section==""){ - Bert.alert('Enter Section!', 'danger'); - }else if(community==""){ - Bert.alert('Enter Section!', 'danger'); - }else if(bloodGroup==""){ - Bert.alert('Enter Blood Group!', 'danger'); - }else if(phone==""){ - Bert.alert('Enter phone!', 'danger'); - }else if(address==""){ - Bert.alert('Enter address!', 'danger'); - }else if(city==""){ - Bert.alert('Enter city!', 'danger'); - }else if(state==""){ - Bert.alert('Enter state!', 'danger'); - }else if(parentName==""){ - Bert.alert('Enter Parent name!', 'danger'); - }else if(parentEmail==""){ - Bert.alert('Enter Parent Email!', 'danger'); - }else if(relation==""){ - Bert.alert('Enter relation!', 'danger'); - }else if(profession==""){ - Bert.alert('Enter parent profession!', 'danger'); - }else if(parentGender==""){ - Bert.alert("Enter Parent's Gender!", 'danger'); - }else if(parentPhone==""){ - Bert.alert("Enter Parent's Phone!", 'danger'); - }else if(parentAddress==""){ - Bert.alert("Enter Parent's Address!", 'danger'); - }else if(parentCity==""){ - Bert.alert("Enter Parent's City!", 'danger'); - }else if(parentState==""){ - Bert.alert("Enter Parent's State!", 'danger'); - }else if(parentZipcode==""){ - Bert.alert("Enter Parent's zipcode!", 'danger'); - }else{ - addStudentManually.call({ - admissionId, - firstName, - middleName, - lastName, - email, - dob, - formattedDob, - gender, - rollNo, - studentclass, - section, - community, - bloodGroup, - phone, - address, - city, - state, - parentName, - parentEmail, - relation, - profession, - parentGender, - parentPhone, - parentAddress, - parentCity, - parentState, - parentZipcode - }, function (error, result) { - console.log(error); - console.log(result); - }); - } - } - render() { - return ( -
this.addStudent(e) } inline> - -
-
Personal data
-
-
-
- - - Admission Id - this.onUpdate('admissionId',e.target.value)} - /> - - -
- -
- - - First Name - this.onUpdate('firstName',e.target.value)} - /> - - -
-
-
-
- - - - Admission Id - this.onUpdate('admissionId',e.target.value)} - /> - - - - First Name - this.onUpdate('firstName',e.target.value)} - /> - - - Middle Name - this.onUpdate('middleName',e.target.value)} - /> - - - - Last Name - this.onUpdate('lastName',e.target.value)} - /> - - - - Email - this.onUpdate('email',e.target.value)} - /> - - - Date of birth - - - - - Gender - this.onUpdate('gender',e.target.value)} - > - - - - - - - Roll No - this.onUpdate('rollNo',e.target.value)} - /> - - - Class - this.onUpdate('class',e.target.value)} - /> - - - Section - this.onUpdate('section',e.target.value)} - /> - - - - Community - this.onUpdate('community',e.target.value)} - /> - - - - bloodGroup - this.onUpdate('bloodGroup',e.target.value)} - /> - - - - Phone - this.onUpdate('phone',e.target.value)} - /> - - - - Address - this.onUpdate('address',e.target.value)} - /> - - - - City - this.onUpdate('city',e.target.value)} - /> - - - - State - this.onUpdate('state',e.target.value)} - /> - - - - Parent Name - this.onUpdate('parentName',e.target.value)} - /> - - - - Parent Email - this.onUpdate('parentEmail',e.target.value)} - /> - - - - Relation - this.onUpdate('relation',e.target.value)} - /> - - - - Profession - this.onUpdate('profession',e.target.value)} - /> - - - - Parent Gender - this.onUpdate('parentGender',e.target.value)} - > - - - - - - - Parent Phone - this.onUpdate('parentPhone',e.target.value)} - /> - - - - Parent Address - this.onUpdate('parentAddress',e.target.value)} - /> - - - - Parent City - this.onUpdate('parentCity',e.target.value)} - /> - - - - Parent State - this.onUpdate('parentState',e.target.value)} - /> - - - - Parent Zipcode - this.onUpdate('parentZipcode',e.target.value)} - /> - - -
- ); - }; - -}; diff --git a/imports/client/views/org/admin/teachers/add/addTeacher.js b/imports/client/views/org/admin/teachers/add/addTeacher.js deleted file mode 100644 index 6b3b7de..0000000 --- a/imports/client/views/org/admin/teachers/add/addTeacher.js +++ /dev/null @@ -1,63 +0,0 @@ -import _ from 'lodash'; -import { Meteor } from 'meteor/meteor'; -import React, { Component } from 'react'; -import { Link,browserHistory } from 'react-router'; -import { FormGroup,Panel,Table, - ButtonToolbar,Modal, - FormControl,Glyphicon,Button } from 'react-bootstrap'; -import { AddStudentFormContainer } from './AddStudentFormContainer'; - -const style = { - margin: 12, -}; -export class AddTeacher extends Component { - constructor(props) { - super(props); - this.state = { - show: false - }; - this.showModal = this.showModal.bind(this); - this.hideModal = this.hideModal.bind(this); - this.onUpdate = this.onUpdate.bind(this); - }; - - showModal() { - this.setState({show: true}); - } - - hideModal() { - this.setState({show: false}); - } - onUpdate(key, value) { - this.setState({[key]: value}); - }; - - render() { - return ( - - - - - New Student - - - - - {/* - - - - */} - - - ); - }; - -}; diff --git a/imports/client/views/org/admin/teachers/index.js b/imports/client/views/org/admin/teachers/index.js deleted file mode 100644 index 0377bf8..0000000 --- a/imports/client/views/org/admin/teachers/index.js +++ /dev/null @@ -1,61 +0,0 @@ -// import { InviteSignupController } from '/imports/client/views/invite/signup/index' -import _ from 'lodash'; -import { - composeWithTracker, - compose, - composeAll - } from 'react-komposer'; -import { Loading } from '/imports/client/components/Loading'; - -import { Orgs } from '/imports/collections/orgs/index'; -import { Users } from '/imports/collections/users/index'; -import { Teachers } from '/imports/collections/teachers/index'; -import { TeachersView } from './TeacherView'; - -const meteorTick = (props, onData) => { - - const handles = [ - Meteor.subscribe('users.current'), - Meteor.subscribe('orgs.current') - ]; - - if(_.every(handles, (handle) => (handle.ready()) )) { - const user = Users.current(); - const org = Orgs.current(); - teachers = Users.find({"role":"TEACHER"}).fetch() ? Users.find({"role":"TEACHER"}).fetch() : ""; - teachersData = Teachers.find().fetch() ? Teachers.find().fetch() : ""; - for(var i=0; i< teachers.length; i++){ - for(var j=0; j< teachers.length; j++){ - if(teachers[i]._id == teachersData[j].userId){ - teachers[i].class = teachersData[j].class; - teachers[i].dob = teachersData[j].dob; - } - } - } - onData(null, { - data: { - user: user, - org: org, - teachersData: teachersData, - teachers: teachers - }, - }); - } - - return () => { - _.each(handles, (handle) => handle.stop() ); - }; -}; - - -const reduxTick = (props, onData) => { - onData(null, { - data: {} - }); -}; - - -export const teachersViewController = composeAll( - composeWithTracker(meteorTick, Loading), - compose(reduxTick, Loading), -)(TeachersView); diff --git a/imports/client/views/org/admin/teachers/view/TeachersRow.js b/imports/client/views/org/admin/teachers/view/TeachersRow.js deleted file mode 100644 index 2cd6950..0000000 --- a/imports/client/views/org/admin/teachers/view/TeachersRow.js +++ /dev/null @@ -1,56 +0,0 @@ -import _ from 'lodash'; -import { Meteor } from 'meteor/meteor'; - -import React, { Component } from 'react'; -import { Link,browserHistory } from 'react-router'; -import { FormGroup, - FormControl,Glyphicon,Button } from 'react-bootstrap'; - - -export class teachersRow extends Component { - - constructor(props) { - super(props); - this.state = { - - }; - this.onUpdate = this.onUpdate.bind(this); - }; - - onUpdate(key, value) { - this.setState({[key]: value}); - }; - - render() { - const {student} = this.props; - if(student.firstName){ - return ( - - {student.firstName} - {student.lastName} - {student.class} - {student.dob? moment(student.dob).format("LL") : } - Active - - - - - ); - }else { - return null; - } - - }; - -}; diff --git a/imports/client/views/org/admin/teachers/view/TeachersTable.js b/imports/client/views/org/admin/teachers/view/TeachersTable.js deleted file mode 100644 index a3b5315..0000000 --- a/imports/client/views/org/admin/teachers/view/TeachersTable.js +++ /dev/null @@ -1,65 +0,0 @@ -import _ from 'lodash'; -import { Meteor } from 'meteor/meteor'; - -import React, { Component } from 'react'; -import { Link,browserHistory } from 'react-router'; -import { FormGroup,Panel,Table, - ButtonToolbar,Modal, - FormControl,Glyphicon,Button } from 'react-bootstrap'; -import {moment} from 'meteor/momentjs:moment' -import {TeachersRow} from './TeachersRow' - -export class TeachersTable extends Component { - - constructor(props) { - super(props); - this.state = { - show: false - }; - this.onUpdate = this.onUpdate.bind(this); - }; - onUpdate(key, value) { - this.setState({[key]: value}); - }; - - render() { - return ( -
-
-
Teachers Details
-
-
    -
  • -
  • -
-
-
- - - - - - - - - - - - - { - this.props.teachers.map(function(student, i) - { - return( - - ) - }) - } - -
First NameLast NameClassDOBStatusActions
-
- ); - }; - -}; diff --git a/imports/collections/staff/index.js b/imports/collections/staff/index.js new file mode 100644 index 0000000..b08146a --- /dev/null +++ b/imports/collections/staff/index.js @@ -0,0 +1,96 @@ +// import {Staffs } from '/imports/collections/staff/index' + +import _ from 'lodash'; +import { Meteor } from 'meteor/meteor'; +import { Mongo } from 'meteor/mongo'; +import { SimpleSchema } from 'meteor/aldeed:simple-schema'; + +import { Orgs } from '/imports/collections/orgs/index'; +import { Users } from '/imports/collections/users/index'; + +class Staff { + constructor(doc) { + _.assign(this, doc); + }; + + getUserIds() { + return _.filter(_.map(this.users, 'userId')); + }; +}; +export { Staff }; + +class StaffsCollection extends Mongo.Collection { + insert(item, callback) { + _.assign(item, { + createdAt: new Date().getTime(), + }); + return super.insert(item, callback); + }; +}; + +export const Staffs = new StaffsCollection('Teachers', { + transform: (item) => { + return new Staff(item); + }, +}); + +_.assign(Staffs, { + allStaffs: () => { + const user = Users.current(); + if(!user) return null; + return Orgs.find({'users.userId': user._id}); + }, + current: () => { + const user = Users.current(); + if(!user) return null; + return Orgs.findOne({_id: user.orgId}); + }, + currentOrgUsers: () => { + const OrgsArr = Orgs.current(); + if(!OrgsArr) return null; + return OrgsArr.users; + }, + +}); + +Staffs.deny({ + insert() { return true; }, + update() { return true; }, + remove() { return true; }, +}); + + +Staffs.schema = new SimpleSchema({ + userId: { type: String }, + orgId: { type: String }, + type: { type: String }, + gender: { type: String, optional: true }, + services: { + type: Object, + optional: true, + blackbox: true, + }, + + isMetaUser: { type: Boolean, optional: true }, + + createdAt: { type: Date, autoValue: function(){return new Date();}} + +}); + +Staffs.attachSchema(Staffs.schema); + +Staffs.privateFields = { + orgId: 1, + address: 1, + + isMetaUser: 1, + createdAt: 1, +}; + +Staffs.publicFields = { + firstName: 1, + lastName: 1, + emails: 1, + + createdAt: 1, +}; diff --git a/imports/collections/staff/methods.js b/imports/collections/staff/methods.js new file mode 100644 index 0000000..5322be1 --- /dev/null +++ b/imports/collections/staff/methods.js @@ -0,0 +1,22 @@ +// import {Parents } from '/imports/collections/parents/methods' +import _ from 'lodash'; +import { Meteor } from 'meteor/meteor'; +import { ValidatedMethod } from 'meteor/mdg:validated-method'; +import { SimpleSchema } from 'meteor/aldeed:simple-schema'; +import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; +import { Bert } from 'meteor/themeteorchef:bert'; +import { Users } from '/imports/collections/users/index'; +import { Teachers } from '/imports/collections/staff/index'; +import { Orgs } from '/imports/collections/orgs/index'; +export const teachersMethods = new ValidatedMethod({ + name: 'teachers.method', + + validate: new SimpleSchema({ + itemId: { type: String }, + }).validator(), + + run({itemId}) { + return {}; + }, + +}); diff --git a/imports/collections/staff/publications.js b/imports/collections/staff/publications.js new file mode 100644 index 0000000..e508417 --- /dev/null +++ b/imports/collections/staff/publications.js @@ -0,0 +1,12 @@ +import { Meteor } from 'meteor/meteor'; +import { check, Match } from 'meteor/check' + +import { Orgs } from '/imports/collections/orgs/index'; +import { Users } from '/imports/collections/users/index'; +import { Teachers } from '/imports/collections/staff/index'; + +Meteor.publish('teachers.forMyOrg', function () { + const user = Users.findOne({_id: this.userId}); + if(!user) return []; + return Teachers.find({orgId: user.orgId}); +}); diff --git a/imports/collections/teachers/index.js b/imports/collections/teachers/index.js deleted file mode 100644 index db39d20..0000000 --- a/imports/collections/teachers/index.js +++ /dev/null @@ -1,96 +0,0 @@ -// import {Parents } from '/imports/collections/parents/index' - -import _ from 'lodash'; -import { Meteor } from 'meteor/meteor'; -import { Mongo } from 'meteor/mongo'; -import { SimpleSchema } from 'meteor/aldeed:simple-schema'; - -import { Orgs } from '/imports/collections/orgs/index'; -import { Users } from '/imports/collections/users/index'; - -class Teacher { - constructor(doc) { - _.assign(this, doc); - }; - - getUserIds() { - return _.filter(_.map(this.users, 'userId')); - }; -}; -export { Teacher }; - -class TeachersCollection extends Mongo.Collection { - insert(item, callback) { - _.assign(item, { - createdAt: new Date().getTime(), - }); - return super.insert(item, callback); - }; -}; - -export const Teachers = new TeachersCollection('Teachers', { - transform: (item) => { - return new Teacher(item); - }, -}); - -_.assign(Teachers, { - allStudents: () => { - const user = Users.current(); - if(!user) return null; - return Orgs.find({'users.userId': user._id}); - }, - current: () => { - const user = Users.current(); - if(!user) return null; - return Orgs.findOne({_id: user.orgId}); - }, - currentOrgUsers: () => { - const OrgsArr = Orgs.current(); - if(!OrgsArr) return null; - return OrgsArr.users; - }, - -}); - -Teachers.deny({ - insert() { return true; }, - update() { return true; }, - remove() { return true; }, -}); - - -Teachers.schema = new SimpleSchema({ - userId: { type: String }, - orgId: { type: String }, - type: { type: String }, - gender: { type: String, optional: true }, - services: { - type: Object, - optional: true, - blackbox: true, - }, - - isMetaUser: { type: Boolean, optional: true }, - - createdAt: { type: Date, autoValue: function(){return new Date();}} - -}); - -Teachers.attachSchema(Teachers.schema); - -Teachers.privateFields = { - orgId: 1, - address: 1, - - isMetaUser: 1, - createdAt: 1, -}; - -Teachers.publicFields = { - firstName: 1, - lastName: 1, - emails: 1, - - createdAt: 1, -}; diff --git a/imports/collections/teachers/methods.js b/imports/collections/teachers/methods.js deleted file mode 100644 index 17bd50b..0000000 --- a/imports/collections/teachers/methods.js +++ /dev/null @@ -1,22 +0,0 @@ -// import {Parents } from '/imports/collections/parents/methods' -import _ from 'lodash'; -import { Meteor } from 'meteor/meteor'; -import { ValidatedMethod } from 'meteor/mdg:validated-method'; -import { SimpleSchema } from 'meteor/aldeed:simple-schema'; -import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; -import { Bert } from 'meteor/themeteorchef:bert'; -import { Users } from '/imports/collections/users/index'; -import { Teachers } from '/imports/collections/teachers/index'; -import { Orgs } from '/imports/collections/orgs/index'; -export const teachersMethods = new ValidatedMethod({ - name: 'teachers.method', - - validate: new SimpleSchema({ - itemId: { type: String }, - }).validator(), - - run({itemId}) { - return {}; - }, - -}); diff --git a/imports/collections/teachers/publications.js b/imports/collections/teachers/publications.js deleted file mode 100644 index bfd6b17..0000000 --- a/imports/collections/teachers/publications.js +++ /dev/null @@ -1,12 +0,0 @@ -import { Meteor } from 'meteor/meteor'; -import { check, Match } from 'meteor/check' - -import { Orgs } from '/imports/collections/orgs/index'; -import { Users } from '/imports/collections/users/index'; -import { Teachers } from '/imports/collections/teachers/index'; - -Meteor.publish('teachers.forMyOrg', function () { - const user = Users.findOne({_id: this.userId}); - if(!user) return []; - return Teachers.find({orgId: user.orgId}); -}); diff --git a/imports/collections/users/index.js b/imports/collections/users/index.js index 1afdfe0..76604dd 100644 --- a/imports/collections/users/index.js +++ b/imports/collections/users/index.js @@ -101,7 +101,7 @@ Users.deny({ Users.roles = { 'STUDENT': 'STUDENT', - 'TEACHER': 'TEACHER', + 'STAFF': 'STAFF', 'ADMIN': 'ADMIN', 'PARENT': 'PARENT' }; diff --git a/imports/server/collections.js b/imports/server/collections.js index 74ee38f..fad96f9 100644 --- a/imports/server/collections.js +++ b/imports/server/collections.js @@ -7,5 +7,5 @@ import '/imports/collections/students/methods'; import '/imports/collections/students/publications'; import '/imports/collections/students/serverCsvUpload'; -import '/imports/collections/teachers/methods'; -import '/imports/collections/teachers/publications'; +import '/imports/collections/staff/methods'; +import '/imports/collections/staff/publications';