Commit bdd4abb61022f7a971cf2f1663ab24a55ce3169c

Authored by Deepak
1 parent 316564385f
Exists in master

some cleanup

imports/client/app/routes.js
1 /* eslint-disable max-len */ 1 /* eslint-disable max-len */
2 2
3 import React from 'react'; 3 import React from 'react';
4 import { render } from 'react-dom'; 4 import { render } from 'react-dom';
5 import { Router, Route, 5 import { Router, Route,
6 IndexRoute, browserHistory } from 'react-router'; 6 IndexRoute, browserHistory } from 'react-router';
7 import { Meteor } from 'meteor/meteor'; 7 import { Meteor } from 'meteor/meteor';
8 8
9 /** 9 /**
10 * General Components 10 * General Components
11 */ 11 */
12 import Index from '/imports/client/views/app/module/Index';
13 import NotFound from '/imports/client/views/org/NotFound'; 12 import NotFound from '/imports/client/views/org/NotFound';
14 13
15 /** 14 /**
16 * Org Components 15 * Org Components
17 */ 16 */
18 17
19 import { App } from '/imports/client/layouts/OrgApp'; 18 import { App } from '/imports/client/layouts/OrgApp';
20 import { AppModule } from '/imports/client/views/org/app/module/Index'; 19 import { AppModule } from '/imports/client/views/org/app/module/Index';
21 import { Orgs } from '/imports/collections/orgs/index'; 20 import { Orgs } from '/imports/collections/orgs/index';
22 import { importCsvController } from '/imports/client/views/org/importCsv/index' 21 import { importCsvController } from '/imports/client/views/org/importCsv/index'
23 22
24 //admin 23 //admin
25 import { StudentDataController } from '/imports/client/views/org/admin/students/index' 24 import { StudentDataController } from '/imports/client/views/org/admin/students/index'
26 import { staffViewController } from '/imports/client/views/org/admin/staff/index' 25 import { staffViewController } from '/imports/client/views/org/admin/staff/index'
27 import { ParentViewController } from '/imports/client/views/org/admin/parents/index' 26 import { ParentViewController } from '/imports/client/views/org/admin/parents/index'
27 import { AdminSettingsController } from '/imports/client/views/org/admin/settings/index'
28 //students 28 //students
29 29
30 //teachers 30 //teachers
31 31
32 //parents 32 //parents
33 33
34
35
36 /**
37 * NonOrg Components
38 */
39 import Signup from '/imports/client/views/nonOrg/enter/SignupView';
40 import { NonOrgApp } from '/imports/client/layouts/NonOrgApp';
41 import {NonOrgAppModule} from '/imports/client/views/nonOrg/app/module/Index';
42
43 /** 34 /**
44 * Invalid Org Components 35 * Invalid Org Components
45 */ 36 */
46 37
47 /** 38 /**
48 There are three types of routes 39 There are three types of routes
49 1)getOrgRoutes: all the routes that should be present for a registered org 40 1)getOrgRoutes: all the routes that should be present for a registered org
50 2)getInvalidOrgRoute: all the routes where someone tries to enter a subdomain which hasn't been registered yet (404 mostly :D) 41 2)getInvalidOrgRoute: all the routes where someone tries to enter a subdomain which hasn't been registered yet (404 mostly :D)
51 3)getNonOrgRoutes: all routes linked to normal site, ie signing up a new org. CHeking out demo and everything internal 42 3)getNonOrgRoutes: all routes linked to normal site, ie signing up a new org. CHeking out demo and everything internal
52 **/ 43 **/
53 const getOrgRoutes = () => ( 44 const getOrgRoutes = () => (
54 <Router history={ browserHistory }> 45 <Router history={ browserHistory }>
55 <Route path="/" component={ App }> 46 <Route path="/" component={ App }>
56 <IndexRoute name="index" component={ AppModule } /> 47 <IndexRoute name="index" component={ AppModule } />
57 <Route name="import" path="/import" component={ importCsvController } /> 48 <Route name="import" path="/import" component={ importCsvController } />
58 <Route name="student" path="/students" component={ StudentDataController } /> 49 <Route name="student" path="/students" component={ StudentDataController } />
59 <Route name="staff" path="/staff" component={ staffViewController } /> 50 <Route name="staff" path="/staff" component={ staffViewController } />
60 <Route name="parent" path="/parents" component={ ParentViewController } /> 51 <Route name="parent" path="/parents" component={ ParentViewController } />
52 <Route name="settings" path="/settings" component={ AdminSettingsController } />
61 <Route path="*" component={ NotFound } /> 53 <Route path="*" component={ NotFound } />
62 </Route> 54 </Route>
63 </Router> 55 </Router>
64 ) 56 )
65 57
66 58
67 const getInvalidOrgRoute = () => ( 59 const getInvalidOrgRoute = () => (
68 <Router history={ browserHistory }> 60 <Router history={ browserHistory }>
69 <Route path="/" component={ App }> 61 <Route path="/" component={ App }>
70 <IndexRoute name="index" component={ NotFound } /> 62 <IndexRoute name="index" component={ NotFound } />
71 <Route path="*" component={ NotFound } /> 63 <Route path="*" component={ NotFound } />
72 </Route> 64 </Route>
73 </Router> 65 </Router>
74 ) 66 )
75 67
68
69 /**
70 * NonOrg Components
71 */
72 import Signup from '/imports/client/views/nonOrg/enter/SignupView';
73 import { NonOrgApp } from '/imports/client/layouts/NonOrgApp';
74 import {NonOrgAppModule} from '/imports/client/views/nonOrg/app/module/Index';
75
76 const getNonOrgRoutes = () => ( 76 const getNonOrgRoutes = () => (
77 <Router history={ browserHistory }> 77 <Router history={ browserHistory }>
78 <Route path="/" component={ NonOrgApp }> 78 <Route path="/" component={ NonOrgApp }>
79 <IndexRoute name="index" component={ NonOrgAppModule } /> 79 <IndexRoute name="index" component={ NonOrgAppModule } />
80 <Route name="signup" path="/signup" component={ Signup } /> 80 <Route name="signup" path="/signup" component={ Signup } />
81 <Route path="*" component={ NotFound } /> 81 <Route path="*" component={ NotFound } />
82 </Route> 82 </Route>
83 </Router> 83 </Router>
84 ) 84 )
85 85
86 //Authenticate function to give access to users only 86 //Authenticate function to give access to users only
87 const authenticate = (nextState, replace) => { 87 const authenticate = (nextState, replace) => {
88 if (!Meteor.loggingIn() && !Meteor.userId()) { 88 if (!Meteor.loggingIn() && !Meteor.userId()) {
89 replace({ 89 replace({
90 pathname: '/login', 90 pathname: '/login',
91 state: { nextPathname: nextState.location.pathname }, 91 state: { nextPathname: nextState.location.pathname },
92 }); 92 });
93 } 93 }
94 }; 94 };
95 95
96 96
97 /** 97 /**
98 98
99 **/ 99 **/
100 const detectOrg = () => { 100 const detectOrg = () => {
101 orgSlug = ""; 101 orgSlug = "";
102 //www.app.ydapp.in
103 //
102 var hostnameArray = document.location.hostname.split( "." ); 104 var hostnameArray = document.location.hostname.split( "." );
105 //['www','app', 'ydapp','in'];
103 if(hostnameArray[0] !== "www"){ 106 if(hostnameArray[0] !== "www"){
104 if((hostnameArray[1]==='localhost'||hostnameArray[1]==='ydapp')){ 107 if((hostnameArray[1]==='localhost'||hostnameArray[1]==='ydapp')){
105 orgSlug = hostnameArray[0]; 108 orgSlug = hostnameArray[0];
106 } 109 }
107 }else{ 110 }else{
108 if((hostnameArray[2]==='localhost'||hostnameArray[2]==='ydapp')){ 111 if((hostnameArray[2]==='localhost'||hostnameArray[2]==='ydapp')){
109 orgSlug = hostnameArray[1]; 112 orgSlug = hostnameArray[1];
110 } 113 }
111 } 114 }
112 115
113 if(orgSlug!==""){ 116 if(orgSlug!==""){
114 console.log(orgSlug); 117 console.log(orgSlug);
115 Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) { 118 Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) {
119 console.log(err);
120 console.log(res);
116 if(res){ 121 if(res){
117 Session.set('orgId', res._id); 122 Session.set('orgId', res._id);
118 Session.set('orgSlug', orgSlug); 123 Session.set('orgSlug', orgSlug);
119 render(getOrgRoutes(),document.getElementById('app')); 124 render(getOrgRoutes(),document.getElementById('app'));
120 }else{ 125 }else{
121 render(getInvalidOrgRoute(),document.getElementById('app')); 126 render(getInvalidOrgRoute(),document.getElementById('app'));
122 } 127 }
123 }); 128 });
124 }else{ 129 }else{
125 render(getNonOrgRoutes(),document.getElementById('app')); 130 render(getNonOrgRoutes(),document.getElementById('app'));
126 } 131 }
imports/client/layouts/OrgApp.js
1 import React, { Component } from 'react'; 1 import React, { Component } from 'react';
2 import { Grid } from 'react-bootstrap'; 2 import { Grid } from 'react-bootstrap';
3 import {AppNavigationController} from '/imports/client/views/org/app/module/navigation/index'; 3 import {AppNavigationController} from '/imports/client/views/org/app/module/navigation/index';
4 /** 4 /**
5 * user based redirection will take place here 5 * user based redirection will take place here
6 */ 6 */
7 export class App extends Component { 7 export class App extends Component {
8 constructor(props) { 8 constructor(props) {
9 super(props); 9 super(props);
10 this.state = { 10 this.state = {
11 11
12 }; 12 };
13 }; 13 };
14 render(){ 14 render(){
15 return ( 15 return (
16 <div> 16 <div className="app-main-layout">
17 <AppNavigationController />
18 { this.props.children } 17 { this.props.children }
19 <Grid>
20
21 </Grid>
22 </div> 18 </div>
23 ) 19 )
24 } 20 }
25 } 21 }
26 22
imports/client/views/app/module/Index.js
1 import React from 'react'; File was deleted
2 import { Jumbotron } from 'react-bootstrap';
3
4 const Index = () => (
5 <div className="Index">
6 <Jumbotron className="text-center">
7 <h2>Base</h2>
8 <p>A starting point for Meteor applications.</p>
9 <p><a className="btn btn-success" href="https://themeteorchef.com/base" role="button">Read the Documentation</a></p>
10 <p style={ { fontSize: '16px', color: '#aaa' } }>Currently at v4.11.1</p>
11 </Jumbotron>
12 </div>
13 );
14
15 export default Index;
16 1 import React from 'react';
imports/client/views/app/module/navigation/AppNavigation.js
1 import React from 'react'; File was deleted
2 import { Navbar } from 'react-bootstrap';
3 import { Link } from 'react-router';
4 import PublicNavigation from './PublicNavigation.js';
5 import AuthenticatedNavigation from './AuthenticatedNavigation.js';
6
7 const renderNavigation = hasUser => (hasUser ? <AuthenticatedNavigation /> : <PublicNavigation />);
8
9 const AppNavigation = ({ hasUser }) => (
10 <Navbar>
11 <Navbar.Header>
12 <Navbar.Brand>
13 <Link to="/">Application Name</Link>
14 </Navbar.Brand>
15 <Navbar.Toggle />
16 </Navbar.Header>
17 <Navbar.Collapse>
18 { renderNavigation(hasUser) }
19 </Navbar.Collapse>
20 </Navbar>
21 );
22
23 AppNavigation.propTypes = {
24 hasUser: React.PropTypes.object,
25 };
26
27 export default AppNavigation;
28 1 import React from 'react';
imports/client/views/app/module/navigation/AuthenticatedNavigation.js
1 import React from 'react'; File was deleted
2 import { browserHistory } from 'react-router';
3 import { LinkContainer } from 'react-router-bootstrap';
4 import { Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap';
5 import { Meteor } from 'meteor/meteor';
6
7 const handleLogout = () => Meteor.logout(() => browserHistory.push('/login'));
8
9 const userName = () => {
10 const user = Meteor.user();
11 const name = user && user.profile ? user.profile.name : '';
12 return user ? `${name.first} ${name.last}` : '';
13 };
14
15 const AuthenticatedNavigation = () => (
16 <div>
17 <Nav>
18 <LinkContainer to="/documents">
19 <NavItem eventKey={ 2 } href="/documents">Documents</NavItem>
20 </LinkContainer>
21 </Nav>
22 <Nav pullRight>
23 <NavDropdown eventKey={ 3 } title={ userName() } id="basic-nav-dropdown">
24 <MenuItem eventKey={ 3.1 } onClick={ handleLogout }>Logout</MenuItem>
25 </NavDropdown>
26 </Nav>
27 </div>
28 );
29
30 export default AuthenticatedNavigation;
31 1 import React from 'react';
imports/client/views/app/module/navigation/Loading.js
1 import React from 'react'; File was deleted
2
3 const Loading = () => (
4 <svg
5 version="1.1"
6 className="Loading"
7 xmlns="http://www.w3.org/2000/svg"
8 x="0px"
9 y="0px"
10 width="40px"
11 height="40px"
12 viewBox="0 0 40 40"
13 enableBackground="new 0 0 40 40">
14 <path
15 opacity="1.0"
16 fill="#eee"
17 d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,
18 14.946,14.946s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,
19 5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634c0-6.425,
20 5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,
21 26.541,26.626,31.749,20.201,31.749z"/>
22 <path
23 fill="#da5347"
24 d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0
25 C22.32,8.481,24.301,9.057,26.013,10.047z">
26 </path>
27 </svg>
28 );
29
30 export default Loading;
31 1 import React from 'react';
imports/client/views/app/module/navigation/PublicNavigation.js
1 import React from 'react'; File was deleted
2 import { LinkContainer } from 'react-router-bootstrap';
3 import { Nav, NavItem } from 'react-bootstrap';
4
5 const PublicNavigation = () => (
6 <Nav pullRight>
7 <LinkContainer to="signup">
8 <NavItem eventKey={ 1 } href="/signup">Sign Up</NavItem>
9 </LinkContainer>
10 <LinkContainer to="login">
11 <NavItem eventKey={ 2 } href="/login">Log In</NavItem>
12 </LinkContainer>
13 </Nav>
14 );
15
16 export default PublicNavigation;
17 1 import React from 'react';
imports/client/views/app/module/navigation/index.js
1 import { composeWithTracker } from 'react-komposer'; File was deleted
2 import { Meteor } from 'meteor/meteor';
3 import AppNavigation from '../components/AppNavigation.js';
4
5 const composer = (props, onData) => onData(null, { hasUser: Meteor.user() });
6
7 export default composeWithTracker(composer, {}, {}, { pure: false })(AppNavigation);
8 1 import { composeWithTracker } from 'react-komposer';
imports/client/views/org/admin/settings/adminSettingsView.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 AdminSettingsView 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 {user, org} = this.props.data;
26 return (
27 <div className = "enterPane-box">
28 <h1>Settings</h1>
29 </div>
30 );
31 };
32
33 };
34
imports/client/views/org/admin/settings/index.js
File was created 1 // import { InviteSignupController } from '/imports/client/views/invite/signup/index'
2 import _ from 'lodash';
3 import {
4 composeWithTracker,
5 compose,
6 composeAll
7 } from 'react-komposer';
8 import { Loading } from '/imports/client/components/Loading';
9
10 import { Orgs } from '/imports/collections/orgs/index';
11 import { Users } from '/imports/collections/users/index';
12 import { AdminSettingsView } from './adminSettingsView';
13
14 const meteorTick = (props, onData) => {
15
16 const handles = [
17 Meteor.subscribe('users.current'),
18 Meteor.subscribe('orgs.current')
19 ];
20
21 if(_.every(handles, (handle) => (handle.ready()) )) {
22 const user = Users.current();
23 const org = Orgs.current();
24 onData(null, {
25 data: {
26 user: user,
27 org: org
28 },
29 });
30 }
31
32 return () => {
33 _.each(handles, (handle) => handle.stop() );
34 };
35 };
36
37
38 const reduxTick = (props, onData) => {
39 onData(null, {
40 data: {}
41 });
42 };
43
44
45 export const AdminSettingsController = composeAll(
46 composeWithTracker(meteorTick, Loading),
47 compose(reduxTick, Loading),
48 )(AdminSettingsView);
49
imports/client/views/org/admin/students/StudentView.js
1 import _ from 'lodash'; 1 import _ from 'lodash';
2 import { Meteor } from 'meteor/meteor'; 2 import { Meteor } from 'meteor/meteor';
3 3
4 import React, { Component } from 'react'; 4 import React, { Component } from 'react';
5 import { Link,browserHistory } from 'react-router'; 5 import { Link,browserHistory } from 'react-router';
6 import { Navbar,Modal, Nav, NavItem, 6 import { Navbar,Modal, Nav, NavItem,
7 Glyphicon, Collapse, FormGroup, FormControl, Panel, 7 Glyphicon, Collapse, FormGroup, FormControl, Panel,
8 NavbarToggler, NavbarBrand, Table, ButtonToolbar, 8 NavbarToggler, NavbarBrand, Table, ButtonToolbar,
9 NavLink, DropdownItem, DropdownToggle, DropdownMenu, 9 NavLink, DropdownItem, DropdownToggle, DropdownMenu,
10 NavDropdown, MenuItem, Breadcrumb, Button } from 'react-bootstrap'; 10 NavDropdown, MenuItem, Breadcrumb, Button } from 'react-bootstrap';
11 import { StudentTable } from './view/StudentTable'; 11 import { StudentTable } from './view/StudentTable';
12 import { Header } from '../Header'; 12 import { Header } from '../Header';
13 import { AdminSidebar } from '../Sidebar' 13 import { AdminSidebar } from '../Sidebar'
14 import { AdminBreadcrumb } from '../Breadcrumb' 14 import { AdminBreadcrumb } from '../Breadcrumb'
15 import { UploadCsv } from './UploadCsv'; 15 import { UploadCsv } from './UploadCsv';
16 import { AddStudent } from './add/addStudent'; 16 import { AddStudent } from './add/addStudent';
17 import { Students } from '/imports/collections/students/index'; 17 import { Students } from '/imports/collections/students/index';
18 import './student.css' 18 import './student.css'
19 19
20 export class StudentView extends Component { 20 export class StudentView extends Component {
21 21
22 constructor(props) { 22 constructor(props) {
23 super(props); 23 super(props);
24 this.state = { 24 this.state = {
25 show: false, 25 show: false,
26 firstNameSearch: "", 26 firstNameSearch: "",
27 lastNameSearch: "", 27 lastNameSearch: "",
28 }; 28 };
29 this.showModal = this.showModal.bind(this); 29 this.showModal = this.showModal.bind(this);
30 this.hideModal = this.hideModal.bind(this); 30 this.hideModal = this.hideModal.bind(this);
31 this.onUpdate = this.onUpdate.bind(this); 31 this.onUpdate = this.onUpdate.bind(this);
32 }; 32 };
33 33
34 showModal() { 34 showModal() {
35 this.setState({show: true}); 35 this.setState({show: true});
36 } 36 }
37 37
38 hideModal() { 38 hideModal() {
39 this.setState({show: false}); 39 this.setState({show: false});
40 } 40 }
41 onUpdate(key, value) { 41 onUpdate(key, value) {
42 this.setState({[key]: value}); 42 this.setState({[key]: value});
43 }; 43 };
44 44
45 render() { 45 render() {
46 firstNameSearch = this.state.firstNameSearch; 46 firstNameSearch = this.state.firstNameSearch;
47 lastNameSearch = this.state.lastNameSearch; 47 lastNameSearch = this.state.lastNameSearch;
48 var students =_.filter(this.props.data.students,function(item){ 48 var students =_.filter(this.props.data.students,function(item){
49 if(item.firstName){ 49 if(item.firstName){
50 return _.includes(item.firstName.toLowerCase(),firstNameSearch.toLowerCase()); 50 return _.includes(item.firstName.toLowerCase(),firstNameSearch.toLowerCase());
51 } 51 }
52 }); 52 });
53 return ( 53 return (
54 <div className="appLayout-box"> 54 <div className="appLayout-box">
55 <div className="page-container"> 55 <div className="page-container">
56 <div className="page-content"> 56 <div className="page-content">
57 <AdminSidebar 57 <AdminSidebar
58 user = {this.props.data.user} 58 user = {this.props.data.user}
59 org = {this.props.data.org} 59 org = {this.props.data.org}
60 /> 60 />
61 {/*end sidebar*/} 61 {/*end sidebar*/}
62 <div className="content-wrapper"> 62 <div className="content-wrapper">
63 <AdminBreadcrumb /> 63 <AdminBreadcrumb />
64 {/*content*/} 64 {/*content*/}
65 65
66 <div className="content has-detached-left"> 66 <div className="content has-detached-left">
67 <div className="container-detached"> 67 <div className="container-detached">
68 <div className=""> 68 <div className="">
69 <Header/> 69 <Header/>
70 <StudentTable 70 <StudentTable
71 data = {this.props.data} 71 data = {this.props.data}
72 students = {students} 72 studentData = {studentData}
73 /> 73 />
74 <AddStudent/> 74 <AddStudent/>
75 <UploadCsv /> 75 <UploadCsv />
76 </div> 76 </div>
77 </div> 77 </div>
78 </div> 78 </div>
79 </div> 79 </div>
80 </div> 80 </div>
81 </div> 81 </div>
82 </div> 82 </div>
83 ); 83 );
84 }; 84 };
85 85
86 }; 86 };
87 87
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
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 self = this;
31 if (this.state.currentStep === 3) { 32 if (this.state.currentStep === 3) {
32 addStudentManually.call(this.form.state.values, function(err, result){ 33 Meteor.call('student.addManually',this.form.state.values, function(err, result){
33 console.log("err"); 34 console.log("err");
34 console.log(err); 35 console.log(err);
35 console.log("result"); 36 console.log("result");
36 console.log(result); 37 console.log(result);
37 if(!err){ 38 if(!err){
38 this.props.modalState(); 39 self.props.hideModal();
39 } 40 }
40 }); 41 });
41 } 42 }
42 } 43 }
43 44
44 //render callback 45 //render callback
45 render() { 46 render() {
46 return ( 47 return (
47 <Form 48 <Form
48 onSubmit={this.handleSubmit} 49 onSubmit={this.handleSubmit}
49 ref={form => this.form = form} 50 ref={form => this.form = form}
50 initialValues={{ 51 initialValues={{
51 gender: 'male', 52 gender: 'male',
52 parentGender: 'male', 53 parentGender: 'male',
54 admissionId: "123",
55 firstName: "first",
56 lastName: "last",
57 email: "deepak125.dk+21@gmail.com",
58 dob: "04/04/1989",
59 gender: "male",
60 rollNo: "1",
61 studentClass: "2",
62 section: "B",
63 community: "SC",
64 bloodGroup: "B+",
65 phone: "9876543321",
66 address: "address",
67 city: "chennai",
68 state: "tn",
69 parentName: "parentName",
70 parentEmail: "deepak125.dk+41@gmail.com",
71 relation: "father",
72 profession: "farmer",
73 parentGender: "male",
74 parentPhone: "987655412",
75 parentAddress: "parentAddress",
76 parentCity: "parentCity",
77 parentState: "parentState",
78 parentZipcode: "parentZipcode",
53 }} 79 }}
54 > 80 >
55 {({ values, setValue, getValue, isSubmitted, isDirty }) => ( 81 {({ values, setValue, getValue, isSubmitted, isDirty }) => (
56 <Validator 82 <Validator
57 values={values} 83 values={values}
58 ref={validator => this.validator = validator} 84 ref={validator => this.validator = validator}
59 validations={{ 85 validations={{
60 admissionId: [(value) => isRequired('Admission id', value)], 86 admissionId: [(value) => isRequired('Admission id', value)],
61 firstName: [(value) => isRequired('First name', value)], 87 firstName: [(value) => isRequired('First name', value)],
62 lastName: [(value) => isRequired('Last name', value)], 88 lastName: [(value) => isRequired('Last name', value)],
63 email: [(value) => isRequired('Email', value), isValidEmail], 89 email: [(value) => isRequired('Email', value), isValidEmail],
64 dob: [(value) => isRequired('Date of birth', value)], 90 dob: [(value) => isRequired('Date of birth', value)],
65 gender: [(value) => isRequired('Gender', value)], 91 gender: [(value) => isRequired('Gender', value)],
66 rollNo: [(value) => this.state.currentStep === 1 && isRequired('Roll no', value)], 92 rollNo: [(value) => this.state.currentStep === 1 && isRequired('Roll no', value)],
67 studentClass: [(value) => this.state.currentStep === 1 && isRequired('Class', value)], 93 studentClass: [(value) => this.state.currentStep === 1 && isRequired('Class', value)],
68 section: [(value) => this.state.currentStep === 1 && isRequired('Section', value)], 94 section: [(value) => this.state.currentStep === 1 && isRequired('Section', value)],
69 community: [(value) => this.state.currentStep === 1 && isRequired('Community', value)], 95 community: [(value) => this.state.currentStep === 1 && isRequired('Community', value)],
70 bloodGroup: [(value) => this.state.currentStep === 1 && isRequired('Blood group', value)], 96 bloodGroup: [(value) => this.state.currentStep === 1 && isRequired('Blood group', value)],
71 phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], 97 phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)],
72 address: [(value) => this.state.currentStep === 2 && isRequired('Address', value)], 98 address: [(value) => this.state.currentStep === 2 && isRequired('Address', value)],
73 city: [(value) => this.state.currentStep === 2 && isRequired('City', value)], 99 city: [(value) => this.state.currentStep === 2 && isRequired('City', value)],
74 state: [(value) => this.state.currentStep === 2 && isRequired('State', value)], 100 state: [(value) => this.state.currentStep === 2 && isRequired('State', value)],
75 parentName: [(value) => this.state.currentStep === 3 && isRequired('Parent name', value)], 101 parentName: [(value) => this.state.currentStep === 3 && isRequired('Parent name', value)],
76 parentEmail: [(value) => this.state.currentStep === 3 && isRequired('Parent email', value), (value) => this.state.currentStep === 3 && isValidEmail(value)], 102 parentEmail: [(value) => this.state.currentStep === 3 && isRequired('Parent email', value), (value) => this.state.currentStep === 3 && isValidEmail(value)],
77 relation: [(value) => this.state.currentStep === 3 && isRequired('Relation', value)], 103 relation: [(value) => this.state.currentStep === 3 && isRequired('Relation', value)],
78 profession: [(value) => this.state.currentStep === 3 && isRequired('Profession', value)], 104 profession: [(value) => this.state.currentStep === 3 && isRequired('Profession', value)],
79 parentGender: [(value) => this.state.currentStep === 3 && isRequired('Parent gender', value)], 105 parentGender: [(value) => this.state.currentStep === 3 && isRequired('Parent gender', value)],
80 parentPhone: [(value) => this.state.currentStep === 3 && isRequired('Parent phone', value)], 106 parentPhone: [(value) => this.state.currentStep === 3 && isRequired('Parent phone', value)],
81 parentAddress: [(value) => this.state.currentStep === 3 && isRequired('Parent address', value)], 107 parentAddress: [(value) => this.state.currentStep === 3 && isRequired('Parent address', value)],
82 parentCity: [(value) => this.state.currentStep === 3 && isRequired('Parent city', value)], 108 parentCity: [(value) => this.state.currentStep === 3 && isRequired('Parent city', value)],
83 parentState: [(value) => this.state.currentStep === 3 && isRequired('Parent state', value)], 109 parentState: [(value) => this.state.currentStep === 3 && isRequired('Parent state', value)],
84 parentZipcode: [(value) => this.state.currentStep === 3 && isRequired('Parent zip code', value)], 110 parentZipcode: [(value) => this.state.currentStep === 3 && isRequired('Parent zip code', value)],
85 }} 111 }}
86 > 112 >
87 {({ errors }) => ( 113 {({ errors }) => (
88 <StudentForm 114 <StudentForm
89 isDirty={isDirty} 115 isDirty={isDirty}
90 setValue={setValue} 116 setValue={setValue}
91 getValue={getValue} 117 getValue={getValue}
92 isSubmitted={isSubmitted} 118 isSubmitted={isSubmitted}
93 errors={errors} 119 errors={errors}
94 onNextClick={this.handleNextClick} 120 onNextClick={this.handleNextClick}
95 onBackClick={this.handleBackClick} 121 onBackClick={this.handleBackClick}
96 currentStep={this.state.currentStep} 122 currentStep={this.state.currentStep}
97 /> 123 />
98 )} 124 )}
99 </Validator> 125 </Validator>
100 )} 126 )}
101 </Form> 127 </Form>
102 ) 128 )
103 } 129 }
104 } 130 }
105 131
imports/client/views/org/admin/students/add/addStudent.js
1 import _ from 'lodash'; 1 import _ from 'lodash';
2 import { Meteor } from 'meteor/meteor'; 2 import { Meteor } from 'meteor/meteor';
3 import React, { Component } from 'react'; 3 import React, { Component } from 'react';
4 import { Link,browserHistory } from 'react-router'; 4 import { Link,browserHistory } from 'react-router';
5 import { FormGroup,Panel,Table, 5 import { FormGroup,Panel,Table,
6 ButtonToolbar,Modal, 6 ButtonToolbar,Modal,
7 FormControl,Glyphicon,Button } from 'react-bootstrap'; 7 FormControl,Glyphicon,Button } from 'react-bootstrap';
8 import { AddStudentFormContainer } from './AddStudentFormContainer'; 8 import { AddStudentFormContainer } from './AddStudentFormContainer';
9 9
10 const style = { 10 const style = {
11 margin: 12, 11 margin: 12,
12 }; 12 };
13 export class AddStudent extends Component { 13 export class AddStudent extends Component {
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.showModal = this.showModal.bind(this); 19 this.showModal = this.showModal.bind(this);
20 this.hideModal = this.hideModal.bind(this); 20 this.hideModal = this.hideModal.bind(this);
21 this.onUpdate = this.onUpdate.bind(this); 21 this.onUpdate = this.onUpdate.bind(this);
22 }; 22 };
23 23
24 showModal() { 24 showModal() {
25 this.setState({show: true}); 25 this.setState({show: true});
26 } 26 }
27 27
28 hideModal() { 28 hideModal() {
29 this.setState({show: false}); 29 this.setState({show: false});
30 } 30 }
31 onUpdate(key, value) { 31 onUpdate(key, value) {
32 this.setState({[key]: value}); 32 this.setState({[key]: value});
33 }; 33 };
34 34
35 render() { 35 render() {
36 return ( 36 return (
37 <ButtonToolbar> 37 <ButtonToolbar>
38 <Button bsStyle="primary" onClick={this.showModal}> 38 <Button bsStyle="primary" onClick={this.showModal}>
39 Add Student 39 Add Student
40 </Button> 40 </Button>
41 <Modal 41 <Modal
42 {...this.props} 42 {...this.props}
43 show={this.state.show} 43 show={this.state.show}
44 onHide={this.hideModal} 44 onHide={this.hideModal}
45 dialogClassName="custom-modal" 45 dialogClassName="custom-modal"
46 bsSize="large" 46 bsSize="large"
47 > 47 >
48 <Modal.Header closeButton> 48 <Modal.Header closeButton>
49 <Modal.Title id="contained-modal-title-lg">Add Student</Modal.Title> 49 <Modal.Title id="contained-modal-title-lg">Add Student</Modal.Title>
50 </Modal.Header> 50 </Modal.Header>
51 <Modal.Body> 51 <Modal.Body>
52 <AddStudentFormContainer 52 <AddStudentFormContainer
53 modalState = {this.hideModal} 53 hideModal = {this.hideModal}
54 /> 54 />
55 </Modal.Body> 55 </Modal.Body>
56 {/* 56 {/*
57 <Modal.Footer> 57 <Modal.Footer>
58 <Button onClick={this.hideModal}>Close</Button> 58 <Button onClick={this.hideModal}>Close</Button>
59 </Modal.Footer> 59 </Modal.Footer>
60 */} 60 */}
61 </Modal> 61 </Modal>
62 </ButtonToolbar> 62 </ButtonToolbar>
63 ); 63 );
64 }; 64 };
65 65
66 }; 66 };
67 67
imports/client/views/org/admin/students/index.js
1 // import { StudentDataController } from '/imports/client/views/org/admin/students/index' 1 // import { StudentDataController } from '/imports/client/views/org/admin/students/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 { StudentView } from './StudentView'; 12 import { StudentView } from './StudentView';
13 import { Students } from '/imports/collections/students/index'; 13 import { Students } from '/imports/collections/students/index';
14 14
15 15
16 const meteorTick = (props, onData) => { 16 const meteorTick = (props, onData) => {
17 17
18 const handles = [ 18 const handles = [
19 Meteor.subscribe('users.current'), 19 Meteor.subscribe('users.current'),
20 Meteor.subscribe('orgs.current'), 20 Meteor.subscribe('orgs.current'),
21 Meteor.subscribe('users.forMyOrg'), 21 Meteor.subscribe('users.forMyOrg'),
22 Meteor.subscribe('student.forMyOrg'), 22 Meteor.subscribe('student.forMyOrg'),
23 ]; 23 ];
24 24
25 if(_.every(handles, (handle) => (handle.ready()) )) { 25 if(_.every(handles, (handle) => (handle.ready()) )) {
26 const user = Users.current(); 26 const user = Users.current();
27 const org = Orgs.current(); 27 const org = Orgs.current();
28 students = Users.find({"role":"STUDENT"}).fetch() ? Users.find({"role":"STUDENT"}).fetch() : ""; 28 students = Users.find({"role":"STUDENT"}).fetch() ? Users.find({"role":"STUDENT"}).fetch() : "";
29 console.log(students);
30 studentData = Students.find().fetch() ? Students.find().fetch() : ""; 29 studentData = Students.find().fetch() ? Students.find().fetch() : "";
31 var mergedData; 30 for(var i=0; i< studentData.length; i++){
32 console.log(studentData); 31 for(var j=0; j< students.length; j++){
33 for(var i=0; i< students.length; i++){ 32 if(studentData[i].userId == students[j]._id && studentData[i].admissionId){
34 for(var j=0; j< studentData.length; j++){ 33 studentData[i].firstName = students[j].firstName;
35 if(students[i]._id == studentData[j].userId && studentData[j].admissionId){ 34 studentData[i].lastName = students[j].lastName;
36 students[i].admissionId = studentData[j].admissionId; 35 }else{
37 students[i].class = studentData[j].class; 36
38 students[i].dob = studentData[j].dob;
39 } 37 }
40 } 38 }
41 } 39 }
42 onData(null, { 40 onData(null, {
43 data: { 41 data: {
44 user: user, 42 user: user,
45 org: org, 43 org: org,
46 students: students,
47 studentData: studentData 44 studentData: studentData
48 }, 45 },
49 }); 46 });
50 } 47 }
51 48
52 return () => { 49 return () => {
53 _.each(handles, (handle) => handle.stop() ); 50 _.each(handles, (handle) => handle.stop() );
54 }; 51 };
55 }; 52 };
56 53
57 54
58 const reduxTick = (props, onData) => { 55 const reduxTick = (props, onData) => {
59 onData(null, { 56 onData(null, {
60 data: {} 57 data: {}
61 }); 58 });
62 }; 59 };
63 60
64 61
65 export const StudentDataController = composeAll( 62 export const StudentDataController = composeAll(
66 composeWithTracker(meteorTick, Loading), 63 composeWithTracker(meteorTick, Loading),
67 compose(reduxTick, Loading), 64 compose(reduxTick, Loading),
68 )(StudentView); 65 )(StudentView);
69 66
imports/client/views/org/admin/students/view/StudentTable.js
1 import _ from 'lodash'; 1 import _ from 'lodash';
2 import { Meteor } from 'meteor/meteor'; 2 import { Meteor } from 'meteor/meteor';
3 3
4 import React, { Component } from 'react'; 4 import React, { Component } from 'react';
5 import { Link,browserHistory } from 'react-router'; 5 import { Link,browserHistory } from 'react-router';
6 import { FormGroup,Panel,Table, 6 import { FormGroup,Panel,Table,
7 ButtonToolbar,Modal, 7 ButtonToolbar,Modal,
8 FormControl,Glyphicon,Button, } from 'react-bootstrap'; 8 FormControl,Glyphicon,Button, } from 'react-bootstrap';
9 import {moment} from 'meteor/momentjs:moment' 9 import {moment} from 'meteor/momentjs:moment'
10 import {StudentRow} from './StudentRow' 10 import {StudentRow} from './StudentRow'
11 import {BootstrapTable, TableHeaderColumn}from 'react-bootstrap-table'; 11 import {BootstrapTable, TableHeaderColumn}from 'react-bootstrap-table';
12 12
13 const options = { 13 const options = {
14 page: 0, // which page you want to show as default 14 page: 0, // which page you want to show as default
15 sizePerPageList: [ { 15 sizePerPageList: [ {
16 text: '5', value: 5 16 text: '5', value: 5
17 }, { 17 }, {
18 text: '10', value: 10 18 text: '10', value: 10
19 }], // you can change the dropdown list for size per page 19 }], // you can change the dropdown list for size per page
20 sizePerPage: 5, // which size per page you want to locate as default 20 sizePerPage: 5, // which size per page you want to locate as default
21 pageStartIndex: 0, // where to start counting the pages 21 pageStartIndex: 0, // where to start counting the pages
22 paginationSize: 3, // the pagination bar size. 22 paginationSize: 3, // the pagination bar size.
23 prePage: 'Prev', // Previous page button text 23 prePage: 'Prev', // Previous page button text
24 nextPage: 'Next', // Next page button text 24 nextPage: 'Next', // Next page button text
25 firstPage: 'First', // First page button text 25 firstPage: 'First', // First page button text
26 lastPage: 'Last', // Last page button text 26 lastPage: 'Last', // Last page button text
27 paginationShowsTotal: false, // Accept bool or function 27 paginationShowsTotal: false, // Accept bool or function
28 paginationPosition: 'bottom' // default is bottom, top and both is all available 28 paginationPosition: 'bottom' // default is bottom, top and both is all available
29 // hideSizePerPage: true > You can hide the dropdown for sizePerPage 29 // hideSizePerPage: true > You can hide the dropdown for sizePerPage
30 // alwaysShowAllBtns: true // Always show next and previous button 30 // alwaysShowAllBtns: true // Always show next and previous button
31 // withFirstAndLast: false > Hide the going to First and Last page button 31 // withFirstAndLast: false > Hide the going to First and Last page button
32 }; 32 };
33 33
34 function dateFormatter(cell, row) { 34 function dateFormatter(cell, row) {
35 if(cell){ 35 if(cell){
36 cell = new Date(cell); 36 cell = new Date(cell);
37 return `${('0' + cell.getDate()).slice(-2)}/${('0' + (cell.getMonth() + 1)).slice(-2)}/${cell.getFullYear()}`; 37 return `${('0' + cell.getDate()).slice(-2)}/${('0' + (cell.getMonth() + 1)).slice(-2)}/${cell.getFullYear()}`;
38 } 38 }
39 } 39 }
40 export class StudentTable extends Component { 40 export class StudentTable extends Component {
41 41
42 constructor(props) { 42 constructor(props) {
43 super(props); 43 super(props);
44 this.state = { 44 this.state = {
45 show: false, 45 show: false,
46 panleOpen: true, 46 panleOpen: true,
47 }; 47 };
48 this.onUpdate = this.onUpdate.bind(this); 48 this.onUpdate = this.onUpdate.bind(this);
49 this.togglePanel = this.togglePanel.bind(this); 49 this.togglePanel = this.togglePanel.bind(this);
50 }; 50 };
51 onUpdate(key, value) { 51 onUpdate(key, value) {
52 this.setState({[key]: value}); 52 this.setState({[key]: value});
53 }; 53 };
54 togglePanel(){ 54 togglePanel(){
55 this.setState({panleOpen: !this.state.panleOpen}); 55 this.setState({panleOpen: !this.state.panleOpen});
56 } 56 }
57 57
58 render() { 58 render() {
59 studentData = this.props.studentData;
60 console.log("this.props.studentData");
61 console.log(this.props.studentData);
59 return ( 62 return (
60 <div className="panel panel-flat"> 63 <div className="panel panel-flat">
61 <div className="panel-heading"> 64 <div className="panel-heading">
62 <h5 className="panel-title">Student Details</h5> 65 <h5 className="panel-title">Student Details</h5>
63 <div className="heading-elements"> 66 <div className="heading-elements">
64 <ul className="icons-list"> 67 <ul className="icons-list">
65 <li onClick={this.togglePanel}><a data-action="collapse" className={this.state.panleOpen?"rotate-180":null}></a></li> 68 <li onClick={this.togglePanel}><a data-action="collapse" className={this.state.panleOpen?"rotate-180":null}></a></li>
66 </ul> 69 </ul>
67 </div> 70 </div>
68 </div> 71 </div>
69 <Panel collapsible expanded={this.state.panleOpen}> 72 <Panel collapsible expanded={this.state.panleOpen}>
70 <BootstrapTable data={ this.props.students } pagination={ true } options={ options } > 73 <BootstrapTable data={ studentData } pagination={ true } options={ options } >
71 <TableHeaderColumn dataField='admissionId' isKey={ true } dataSort={ true } filter={ { type: 'TextFilter' } }>Admission Id</TableHeaderColumn> 74 <TableHeaderColumn dataField='_id' isKey={ true } dataSort={ true } filter={ { type: 'TextFilter' } }>Admission Id</TableHeaderColumn>
72 <TableHeaderColumn dataField='firstName' dataSort={ true } filter={ { type: 'TextFilter' } }>First Name</TableHeaderColumn> 75 <TableHeaderColumn dataField='firstName' dataSort={ true } filter={ { type: 'TextFilter' } }>First Name</TableHeaderColumn>
73 <TableHeaderColumn dataField='lastName' dataSort={ true } filter={ { type: 'TextFilter' } }>Last Name</TableHeaderColumn> 76 <TableHeaderColumn dataField='lastName' dataSort={ true } filter={ { type: 'TextFilter' } }>Last Name</TableHeaderColumn>
74 <TableHeaderColumn dataField='class' dataSort={ true } filter={ { type: 'TextFilter' } }>Class</TableHeaderColumn> 77 <TableHeaderColumn dataField='class' dataSort={ true } filter={ { type: 'TextFilter' } }>Class</TableHeaderColumn>
75 <TableHeaderColumn dataField='dob' dataFormat={ dateFormatter } >DOB</TableHeaderColumn> 78 <TableHeaderColumn dataField='dob' dataFormat={ dateFormatter } >DOB</TableHeaderColumn>
76 </BootstrapTable> 79 </BootstrapTable>
77 </Panel> 80 </Panel>
78 </div> 81 </div>
79 ); 82 );
80 }; 83 };
81 84
82 }; 85 };
83 86
imports/client/views/org/app/module/AppLayout.js
1 import _ from 'lodash'; 1 import _ from 'lodash';
2 import { Meteor } from 'meteor/meteor'; 2 import { Meteor } from 'meteor/meteor';
3 import React, { Component } from 'react'; 3 import React, { Component } from 'react';
4 import { Link } from 'react-router'; 4 import { Link } from 'react-router';
5 import { Avatar } from '/imports/client/components/Avatar'; 5 import { Avatar } from '/imports/client/components/Avatar';
6 import { Icon } from '/imports/client/components/Icon'; 6 import { Icon } from '/imports/client/components/Icon';
7 import classNames from 'classnames'; 7 import classNames from 'classnames';
8 import { EnterModule } from '/imports/client/views/org/enter/module/index'; 8 import { EnterModule } from '/imports/client/views/org/enter/module/index';
9 // import { VerifyModule } from '/imports/client/views/verify/module/index'; 9 // import { VerifyModule } from '/imports/client/views/verify/module/index';
10 import { Navbar,Modal, Nav, NavItem, 10 import { Navbar,Modal, Nav, NavItem,
11 Glyphicon, Collapse, 11 Glyphicon, Collapse,
12 NavbarToggler, NavbarBrand, 12 NavbarToggler, NavbarBrand,
13 NavLink, DropdownItem, DropdownToggle, DropdownMenu, 13 NavLink, DropdownItem, DropdownToggle, DropdownMenu,
14 NavDropdown, MenuItem, Breadcrumb } from 'react-bootstrap'; 14 NavDropdown, MenuItem, Breadcrumb } from 'react-bootstrap';
15 import { VerifyModule } from '/imports/client/views/verify/module/index' 15 import { VerifyModule } from '/imports/client/views/verify/module/index'
16 import { AdminAppLayout } from '/imports/client/views/org/admin/AdminLayout' 16 import { AdminAppLayout } from '/imports/client/views/org/admin/AdminLayout'
17 17
18 var Accordion = require('react-bootstrap').Accordion; 18 var Accordion = require('react-bootstrap').Accordion;
19 var Panel = require('react-bootstrap').Panel; 19 var Panel = require('react-bootstrap').Panel;
20 export class AppLayout extends Component { 20 export class AppLayout extends Component {
21 21
22 render() { 22 render() {
23 const {user, org} = this.props.data; 23 const {user, org} = this.props.data;
24
25 if(!user) { 24 if(!user) {
26 return ( 25 return (
27 <EnterModule 26 <EnterModule
28 pane = {this.props.location.query.enter} 27 pane = {this.props.location.query.enter}
29 location = {this.props.location} 28 location = {this.props.location}
30 /> 29 />
31 ); 30 );
32 } 31 }else if(!user.isEmailVerified()) {
33 if(!user.isEmailVerified()) {
34 return ( 32 return (
35 <VerifyModule 33 <VerifyModule
36 pane = {this.props.location.query.verify} 34 pane = {this.props.location.query.verify}
37 location = {this.props.location} 35 location = {this.props.location}
38 /> 36 />
39 ); 37 );
40 } 38 }else if(user.role==='ADMIN'){
41 if(user.role==='ADMIN'){
42 return( 39 return(
43 <AdminAppLayout 40 <AdminAppLayout
44 user = {user} 41 user = {user}
45 org = {org} 42 org = {org}
46 /> 43 />
47 ); 44 );
45 }else{
46 return (
47 null
48 );
48 } 49 }
49
50 return (
51 null
52 );
imports/client/views/org/enter/ForgotPane.js
1 import React from 'react'; 1 import React from 'react';
2 import { Link } from 'react-router'; 2 import { Link } from 'react-router';
3 import { ActionButton } from '/imports/client/components/ActionButton'; 3 import { ActionButton } from '/imports/client/components/ActionButton';
4 import { setQueryParam } from '/imports/client/app/utils/setQueryParam'; 4 import { setQueryParam } from '/imports/client/app/utils/setQueryParam';
5 import { Button, Form, FormGroup, Label, Input, FormText, Col } from 'reactstrap'; 5 import { Button, Form, FormGroup, Label, Input, FormText, Col } from 'reactstrap';
6 import { Alert } from 'reactstrap'; 6 import { Alert } from 'reactstrap';
7 import 'velocity-animate'; 7 import 'velocity-animate';
8 import 'velocity-animate/velocity.ui'; 8 import 'velocity-animate/velocity.ui';
9 import { VelocityComponent, VelocityTransitionGroup, velocityHelpers } from 'velocity-react'; 9 import { VelocityComponent, VelocityTransitionGroup, velocityHelpers } from 'velocity-react';
10 import ReactSVG from 'react-svg' 10 import ReactSVG from 'react-svg'
11 11
12 export class ForgotPane extends React.Component { 12 export class ForgotPane extends React.Component {
13 13
14 render() { 14 render() {
15 return ( 15 return (
16 <Col lg={{ size: 6, pull: 2, push: 2, offset: 1 }} md={{ size: 9, pull: 1, push: 1 }} sm={{ size: 10, push: 1, pull: 1 }}> 16 <Col sm={{ size: 12, push: 1, pull: 1 }}>
17 <VelocityTransitionGroup enter={{ animation: "transition.slideRightIn"}} leave={{animation: "transition.fadeOut" }} runOnMount={true}> 17 <VelocityTransitionGroup enter={{ animation: "transition.slideRightIn"}} leave={{animation: "transition.fadeOut" }} runOnMount={true}>
18 <div className="enterPane__centerVerticallyWrapper"> 18 <div className="enterPane__centerVerticallyWrapper">
19 <Link 19 <Link
20 to={ setQueryParam(this.props.location, { enter: 'login' }) }> 20 to={ setQueryParam(this.props.location, { enter: 'login' }) }>
21 <ReactSVG 21 <ReactSVG
22 path="/files/images/svg/logo2--white.svg" 22 path="/files/images/svg/logo2--white.svg"
23 className="enterPane__logo" 23 className="enterPane__logo"
24 /> 24 />
25 </Link> 25 </Link>
26 <div className="enterPane__box"> 26 <div className="enterPane__box">
27 <div className="enterPane__header"> 27 <div className="enterPane__header">
28 Reset your password 28 Reset your password
29 </div> 29 </div>
30 <Alert color="danger" isOpen={ this.props.data.error.length !== 0 }> 30 <Alert color="danger" isOpen={ this.props.data.error.length !== 0 }>
31 { this.props.data.error } 31 { this.props.data.error }
32 </Alert> 32 </Alert>
33 <Alert color="success" isOpen={ this.props.data.message.length !== 0 }> 33 <Alert color="success" isOpen={ this.props.data.message.length !== 0 }>
34 { this.props.data.message } 34 { this.props.data.message }
35 </Alert> 35 </Alert>
36 <Form onSubmit={ (e) => this.props.onForgot(e) }> 36 <Form onSubmit={ (e) => this.props.onForgot(e) }>
37 <FormGroup> 37 <FormGroup>
38 <Input type="email" size="lg" 38 <Input type="email" size="lg"
39 value={ this.props.data.email } 39 value={ this.props.data.email }
40 onChange={ (e) => this.props.onUpdate('email', e.currentTarget.value) } 40 onChange={ (e) => this.props.onUpdate('email', e.currentTarget.value) }
41 name="email" 41 name="email"
42 id="email" 42 id="email"
43 placeholder="Enter your email" /> 43 placeholder="Enter your email" />
44 </FormGroup> 44 </FormGroup>
45 <FormGroup> 45 <FormGroup>
46 <ActionButton 46 <ActionButton
47 loading={ this.props.data.loading }> 47 loading={ this.props.data.loading }>
48 <Button 48 <Button
49 color="success" size="lg" 49 color="success" size="lg"
50 type="submit" 50 type="submit"
51 block> 51 block>
52 Reset password 52 Reset password
53 </Button> 53 </Button>
54 </ActionButton> 54 </ActionButton>
55 </FormGroup> 55 </FormGroup>
56 <FormGroup className="enterPane__formGroup--center"> 56 <FormGroup className="enterPane__formGroup--center">
57 <Link className="enterPane__link" 57 <Link className="enterPane__link"
58 to={ setQueryParam(this.props.location, { enter: 'login' }) }> 58 to={ setQueryParam(this.props.location, { enter: 'login' }) }>
59 Log In 59 Log In
60 </Link> 60 </Link>
61 </FormGroup> 61 </FormGroup>
62 </Form> 62 </Form>
63 </div> 63 </div>
64 </div> 64 </div>
65 </VelocityTransitionGroup> 65 </VelocityTransitionGroup>
66 </Col> 66 </Col>
67 ); 67 );
68 } 68 }
69 } 69 }
70 70
imports/collections/students/methods.js
1 // import { } from '/imports/collections/students/methods'; 1 // import { } from '/imports/collections/students/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 { Students } from '/imports/collections/students/index'; 9 import { Students } from '/imports/collections/students/index';
10 import { Parents } from '/imports/collections/parents/index'; 10 import { Parents } from '/imports/collections/parents/index';
11 import { Orgs } from '/imports/collections/orgs/index'; 11 import { Orgs } from '/imports/collections/orgs/index';
12 export const studentMethods = new ValidatedMethod({ 12 export const studentMethods = new ValidatedMethod({
13 name: 'student.method', 13 name: 'student.method',
14 14
15 validate: new SimpleSchema({ 15 validate: new SimpleSchema({
16 itemId: { type: String }, 16 itemId: { type: String },
17 }).validator(), 17 }).validator(),
18 18
19 run({itemId}) { 19 run({itemId}) {
20 return {}; 20 return {};
21 }, 21 },
22 22
23 }); 23 });
24
25 export const addStudentManually = new ValidatedMethod({
26 name: 'student.addManually',
27
28 validate: new SimpleSchema({
29 admissionId: { type: String },
30 firstName: { type: String },
31 lastName: { type: String },
32 email: { type: String },
33 dob: { type: String },
34 gender: { type: String },
35 rollNo: { type: String },
36 studentClass: { type: String },
37 section: { type: String },
38 community: { type: String },
39 bloodGroup: { type: String },
40 phone: { type: String },
41 address: { type: String },
42 city: { type: String },
43 state: { type: String },
44 parentName: { type: String },
45 parentEmail: { type: String },
46 relation: { type: String },
47 profession: { type: String },
48 parentGender: { type: String },
49 parentPhone: { type: String },
50 parentAddress: { type: String },
51 parentCity: { type: String },
52 parentState: { type: String },
53 parentZipcode: { type: String },
54 }).validator(),
55
56 run(data) {
57 console.log("data");
58 console.log(data);
59 const user = Users.findOne({_id: this.userId});
60 orgId = user.orgId;
61 newStudentId = Users.insert({
62 emails: [{address:data.email, verified: false}],
63 firstName: data.firstName,
64 lastName: data.lastName,
65 orgId: orgId,
66 role: 'STUDENT'
67 });
68 newParentUserId = Users.insert({
69 emails: [{address:data.parentEmail, verified: false}],
70 firstName: data.parentName,
71 orgId: orgId,
72 role: 'PARENT'
73 });
74 if(newParentUserId){
75 newParentId = Parents.insert({
76 userId: newParentUserId,
77 orgId: orgId,
78 address: data.address,
79 gender: data.gender,
80 dob: data.dob,
81 rollNo: data.rollNo,
82 studentClass: data.studentClass,
83 section: data.section,
84 bloodGroup: data.bloodGroup,
85 community: data.community,
86 relationship: data.relation,
87 });
88 }
89 if(newStudentId){
90 Students.insert({
91 userId: newStudentId,
92 orgId: orgId,
93 admissionId: data.admissionId,
94 address: data.address,
95 gender: data.gender,
96 dob: data.dob,
97 rollNo: data.rollNo,
98 class: data.studentClass,
99 section: data.section,
100 bloodGroup: data.bloodGroup,
101 community: data.community,
102 parent: [{id: newParentUserId, relationship: data.relation}]
103 });
104 }
105 return {newStudentId};
106 },
107
108 });
109 24
imports/collections/students/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 { Students } from '/imports/collections/students/index'; 6 import { Students } from '/imports/collections/students/index';
7 7
8 Meteor.publish('student.forMyOrg', function () { 8 Meteor.publish('student.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 Students.find({orgId: user.orgId}); 11 return Students.find({orgId: user.orgId,"admissionId" : {"$exists" : true, "$ne" : ""}});
12 }); 12 });
13 13
imports/collections/students/serverMethods.js
File was created 1 // import { } from '/imports/collections/students/methods';
2 import _ from 'lodash';
3 import { Meteor } from 'meteor/meteor';
4 import { ValidatedMethod } from 'meteor/mdg:validated-method';
5 import { SimpleSchema } from 'meteor/aldeed:simple-schema';
6 import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
7 import { Bert } from 'meteor/themeteorchef:bert';
8 import { Users } from '/imports/collections/users/index';
9 import { Students } from '/imports/collections/students/index';
10 import { Parents } from '/imports/collections/parents/index';
11 import { Orgs } from '/imports/collections/orgs/index';
12 export const studentServerMethods = new ValidatedMethod({
13 name: 'student.serverMethod',
14
15 validate: new SimpleSchema({
16 itemId: { type: String },
17 }).validator(),
18
19 run({itemId}) {
20 return {};
21 },
22
23 });
24
25 export const addStudentManually = new ValidatedMethod({
26 name: 'student.addManually',
27
28 validate: new SimpleSchema({
29 admissionId: { type: String },
30 firstName: { type: String },
31 lastName: { type: String },
32 email: { type: String },
33 dob: { type: String },
34 gender: { type: String },
35 rollNo: { type: String },
36 studentClass: { type: String },
37 section: { type: String },
38 community: { type: String },
39 bloodGroup: { type: String },
40 phone: { type: String },
41 address: { type: String },
42 city: { type: String },
43 state: { type: String },
44 parentName: { type: String },
45 parentEmail: { type: String },
46 relation: { type: String },
47 profession: { type: String },
48 parentGender: { type: String },
49 parentPhone: { type: String },
50 parentAddress: { type: String },
51 parentCity: { type: String },
52 parentState: { type: String },
53 parentZipcode: { type: String },
54 }).validator(),
55
56 run(data) {
57 console.log("data");
58 console.log(data);
59 const user = Users.findOne({_id: this.userId});
60 orgId = user.orgId;
61 newStudentId = Users.insert({
62 emails: [{address:data.email, verified: false}],
63 firstName: data.firstName,
64 lastName: data.lastName,
65 orgId: orgId,
66 role: 'STUDENT'
67 });
68 newParentUserId = Users.insert({
69 emails: [{address:data.parentEmail, verified: false}],
70 firstName: data.parentName,
71 orgId: orgId,
72 role: 'PARENT'
73 });
74 if(newParentUserId){
75 newParentId = Parents.insert({
76 userId: newParentUserId,
77 orgId: orgId,
78 address: data.address,
79 gender: data.gender,
80 dob: data.dob,
81 rollNo: data.rollNo,
82 studentClass: data.studentClass,
83 section: data.section,
84 bloodGroup: data.bloodGroup,
85 community: data.community,
86 relationship: data.relation,
87 });
88 }
89 if(newStudentId){
90 Students.insert({
91 userId: newStudentId,
92 orgId: orgId,
93 admissionId: data.admissionId,
94 address: data.address,
95 gender: data.gender,
96 dob: data.dob,
97 rollNo: data.rollNo,
98 class: data.studentClass,
99 section: data.section,
100 bloodGroup: data.bloodGroup,
101 community: data.community,
102 parent: [{id: newParentUserId, relationship: data.relation}]
103 });
104 }
105 return {newStudentId};
106 },
107
108 });
109
imports/server/collections.js
1 import '/imports/collections/orgs/publications' 1 import '/imports/collections/orgs/publications'
2 import '/imports/collections/orgs/methods'; 2 import '/imports/collections/orgs/methods';
3 3
4 import '/imports/collections/users/publications'; 4 import '/imports/collections/users/publications';
5 5
6 import '/imports/collections/students/methods'; 6 import '/imports/collections/students/methods';
7 import '/imports/collections/students/publications'; 7 import '/imports/collections/students/publications';
8 import '/imports/collections/students/serverCsvUpload'; 8 import '/imports/collections/students/serverCsvUpload';
9 import '/imports/collections/students/serverMethods';
9 10
10 import '/imports/collections/staff/methods'; 11 import '/imports/collections/staff/methods';
11 import '/imports/collections/staff/publications'; 12 import '/imports/collections/staff/publications';
12 import '/imports/collections/staff/serverCsvUpload'; 13 import '/imports/collections/staff/serverCsvUpload';
13 14
14 import '/imports/collections/parents/methods'; 15 import '/imports/collections/parents/methods';
15 import '/imports/collections/parents/publications'; 16 import '/imports/collections/parents/publications';
16 17