From 796a9c53f517c6c11c3a06ed6a8e597011fca904 Mon Sep 17 00:00:00 2001 From: Deepak Date: Mon, 20 Mar 2017 10:09:29 +0530 Subject: [PATCH] add student form --- imports/client/views/org/admin/students/FabMenu.js | 11 ++-- .../views/org/admin/students/StudentTable.js | 2 +- .../client/views/org/admin/students/StudentView.js | 26 ++------- .../client/views/org/admin/students/addStudent.js | 64 ++++++++++++++++++++++ .../views/org/admin/students/addStudentForm.js | 50 +++++++++++++---- imports/collections/students/methods.js | 4 -- 6 files changed, 111 insertions(+), 46 deletions(-) create mode 100644 imports/client/views/org/admin/students/addStudent.js diff --git a/imports/client/views/org/admin/students/FabMenu.js b/imports/client/views/org/admin/students/FabMenu.js index 1b005e8..aff655a 100644 --- a/imports/client/views/org/admin/students/FabMenu.js +++ b/imports/client/views/org/admin/students/FabMenu.js @@ -7,13 +7,11 @@ import { FormGroup,Panel,Table, ButtonToolbar,Modal, FormControl,Glyphicon,Button } from 'react-bootstrap'; import { AddStudentForm } from './addStudentForm'; -import FloatingActionButton from 'material-ui/FloatingActionButton'; -import ContentAdd from 'material-ui/svg-icons/content/add'; + const style = { - marginRight: 20, + margin: 12, }; export class FabMenuView extends Component { - constructor(props) { super(props); this.state = { @@ -28,9 +26,8 @@ export class FabMenuView extends Component { render() { return (
- - - + +
); }; diff --git a/imports/client/views/org/admin/students/StudentTable.js b/imports/client/views/org/admin/students/StudentTable.js index 7957919..f7b8c86 100644 --- a/imports/client/views/org/admin/students/StudentTable.js +++ b/imports/client/views/org/admin/students/StudentTable.js @@ -51,7 +51,7 @@ export class StudentTable extends Component { this.props.data.students.map(function(student, i) { return( - + {student.firstName} {student.lastName} VII diff --git a/imports/client/views/org/admin/students/StudentView.js b/imports/client/views/org/admin/students/StudentView.js index 3df8dd5..a64a3bc 100644 --- a/imports/client/views/org/admin/students/StudentView.js +++ b/imports/client/views/org/admin/students/StudentView.js @@ -6,10 +6,10 @@ import { Link,browserHistory } from 'react-router'; import { FormGroup,Panel,Table, ButtonToolbar,Modal, FormControl,Glyphicon,Button } from 'react-bootstrap'; -import { AddStudentForm } from './addStudentForm'; +import { AddStudent } from './addStudent'; import { StudentTable } from './StudentTable'; import { Header } from './Header'; -import { FabMenuView } from './FabMenu'; +import { FabMenuView } from './FabMenu'; export class StudentView extends Component { @@ -43,7 +43,7 @@ export class StudentView extends Component { - + @@ -79,25 +79,7 @@ export class StudentView extends Component { -
-
-
- -
- -
-
-
-
+ diff --git a/imports/client/views/org/admin/students/addStudent.js b/imports/client/views/org/admin/students/addStudent.js new file mode 100644 index 0000000..581ea46 --- /dev/null +++ b/imports/client/views/org/admin/students/addStudent.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 { AddStudentForm } from './addStudentForm'; + +const style = { + margin: 12, +}; +export class AddStudent 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/students/addStudentForm.js b/imports/client/views/org/admin/students/addStudentForm.js index fa3c589..976fff3 100644 --- a/imports/client/views/org/admin/students/addStudentForm.js +++ b/imports/client/views/org/admin/students/addStudentForm.js @@ -3,7 +3,7 @@ import { Meteor } from 'meteor/meteor'; import React, { Component } from 'react'; import { Link,browserHistory } from 'react-router'; -import { FormGroup,InputGroup, +import { Form, FormGroup,InputGroup, DropdownButton,MenuItem,ControlLabel, SplitButton, FormControl,Glyphicon,Button } from 'react-bootstrap'; @@ -15,22 +15,38 @@ export class AddStudentForm extends Component { constructor(props) { super(props); this.state = { - firstName: "", - lastName: "", - middleName: "", - dob: "", + admissionId: "", + firstName: "", + lastName: "", + middleName: "", + email: "", + dob: "", + gender: "", + rollNo: "", + class: "", + section: "", + bloodGroup: "", + phone: "", + address: "", + city: "", + state: "", + parentName: "", + parentEmail: "", + relation: "", + profession: "", + parentGender: "", + parentPhone: "", + parentAddress: "", + parentCity: "", + parentState: "", + parentZipcode: "", }; this.onUpdate = this.onUpdate.bind(this); - this.aFunction = this.aFunction.bind(this); }; onUpdate(key, value) { this.setState({[key]: value}); }; - aFunction(e){ - console.log(e); - console.log(e); - } addStudent(e){ e.preventDefault(); e.persist(); @@ -54,7 +70,17 @@ export class AddStudentForm extends Component { } render() { return ( -
this.addStudent(e) }> + this.addStudent(e) }> + + Admission Id + this.onUpdate('firstName',e.target.value)} + /> + + First Name -
+ ); }; diff --git a/imports/collections/students/methods.js b/imports/collections/students/methods.js index 7ba181a..a8a2011 100644 --- a/imports/collections/students/methods.js +++ b/imports/collections/students/methods.js @@ -31,9 +31,6 @@ export const addStudentManually = new ValidatedMethod({ }).validator(), run({firstName,middleName,lastName}) { - console.log(firstName); - console.log(middleName); - console.log(lastName); const user = Users.findOne({_id: this.userId}); orgId = user.orgId; newUserId = Users.insert({ @@ -44,7 +41,6 @@ export const addStudentManually = new ValidatedMethod({ orgId: orgId, role: 'STUDENT' }); - log(newUserId); if(newUserId){ Students.insert({ userId: newUserId, -- 2.0.0