From d67b1f9a0cd27f9321f7d0497a24d2353c1783ca Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Mon, 14 Mar 2016 09:48:06 -0400 Subject: [PATCH 01/32] Made student component --- class/InternshipView.php | 25 +++-- .../editInternshipView/InternshipView.jsx | 106 ++++++++++++++++++ templates/editInternshipView.tpl | 13 +++ 3 files changed, 135 insertions(+), 9 deletions(-) create mode 100644 javascript/editInternshipView/InternshipView.jsx create mode 100644 templates/editInternshipView.tpl diff --git a/class/InternshipView.php b/class/InternshipView.php index f2e30411..9a95aae8 100644 --- a/class/InternshipView.php +++ b/class/InternshipView.php @@ -31,6 +31,7 @@ public function __construct(Internship $internship, Student $student = null, Wor public function display() { + /* $tpl = array(); $tpl['TITLE'] = 'Edit Internship'; @@ -39,37 +40,43 @@ public function display() // Get the Form object $form = $internshipForm->getForm(); + */ /* * If 'missing' is set then we have been redirected * back to the form because the user didn't type in something and * somehow got past the javascript. */ +/* if (isset($_REQUEST['missing'])) { $missing = explode(' ', $_REQUEST['missing']); - +*/ /* * Set classes on field we are missing. */ +/* foreach ($missing as $m) { //$form->addCssClass($m, 'has-error'); $form->addExtraTag($m, 'data-has-error="true"'); } - +*/ /* Plug old values back into form fields. */ - $form->plugIn($_GET); + // $form->plugIn($_GET); /* Re-add hidden fields with object ID's */ - $form->addHidden('id', $this->intern->id); - } + // $form->addHidden('id', $this->intern->id); + // } - $form->mergeTemplate($tpl); + //$form->mergeTemplate($tpl); - $this->showWarnings(); - $this->showStudentWarnings(); + //$this->showWarnings(); + //$this->showStudentWarnings(); - return \PHPWS_Template::process($form->getTemplate(), 'intern', 'internshipView.tpl'); + //return \PHPWS_Template::process($form->getTemplate(), 'intern', 'internshipView.tpl'); + $content = array(); + //javascriptMod('intern', 'editInternshipView'); + return \PHPWS_Template::process($content, 'intern', 'editInternshipView.tpl'); } private function showWarnings() diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx new file mode 100644 index 00000000..5bee1a61 --- /dev/null +++ b/javascript/editInternshipView/InternshipView.jsx @@ -0,0 +1,106 @@ + +var EditInternshipInterface = React.createClass({ + render: function() { + return ( +
+ +
+ ); + } +}); + +var StudentInformation = React.createClass({ + render: function() { + return ( +
+
+ +
+ +
+ Student +
+ +

temp

+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ @appstate.edu +
+
+
+ +
+ +

temp

+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +

temp

+
+ +
+ +

temp

+
+ +
+ +

temp

+
+
+
+
+
+ ); + } +}); + + +React.render( + , document.getElementById('editInternshipInterface') +); \ No newline at end of file diff --git a/templates/editInternshipView.tpl b/templates/editInternshipView.tpl new file mode 100644 index 00000000..e0c49b50 --- /dev/null +++ b/templates/editInternshipView.tpl @@ -0,0 +1,13 @@ + + +
+ + + + + + + + + \ No newline at end of file From c897909f8ad159edffadf8099a2e80d32c82f776 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Tue, 22 Mar 2016 16:09:41 -0400 Subject: [PATCH 02/32] Finalized the student component. --- class/Command/EditInternshipRest.php | 158 +++++++++++++++++ class/Command/ShowInternship.php | 53 +++--- class/Command/StateRest.php | 2 +- class/Internship.php | 2 +- class/InternshipInventory.php | 4 + class/InternshipView.php | 8 +- .../editInternshipView/InternshipView.jsx | 165 ++++++++++++++++-- .../emergencyContact/EmgContactList.jsx | 2 +- templates/editInternshipView.tpl | 6 +- 9 files changed, 348 insertions(+), 52 deletions(-) create mode 100644 class/Command/EditInternshipRest.php diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php new file mode 100644 index 00000000..56b37530 --- /dev/null +++ b/class/Command/EditInternshipRest.php @@ -0,0 +1,158 @@ +post(); + exit; + case 'DELETE': + $this->delete(); + exit; + case 'GET': + $data = $this->get(); + echo (json_encode($data)); + exit; + default: + header('HTTP/1.1 405 Method Not Allowed'); + exit; + } + } + + public function post() + { + + } + + public function delete() + { + + } + + public function get() + { + // Load the Internship + try{ + $intern = InternshipFactory::getInternshipById($_REQUEST['internshipId']); + }catch(\Intern\Exception\InternshipNotFoundException $e){ + \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); + return; + } + + if($intern === false) { + \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); + //TODO redirect to the search interface + return; + } + + // Load a fresh copy of the student data from the web service + try { + $student = StudentProviderFactory::getProvider()->getStudent($intern->getBannerId(), $intern->getTerm()); + } catch(\Intern\Exception\StudentNotFoundException $e) { + $studentId = $intern->getBannerId(); + $student = null; + \NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, "We couldn't find a student with an ID of {$studentId} in Banner. This probably means this person is not an active student."); + } + + // Format intern data + $intern = $this->formatIntern($intern); + + // Load the WorkflowState + $wfState = $intern->getWorkflowState(); + + // Load the agency + $agency = AgencyFactory::getAgencyById($intern->getAgencyId()); + + // Grab Student Data + $studentData = $this->getStudentData($student, $intern); + + // Load the documents + $docs = $intern->getDocuments(); + if($docs === null) { + $docs = array(); // if no docs, setup an empty array + } + + $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agency, "docs" => $docs); + return $content; + } + + public function formatIntern($intern) + { + $birthday = $intern->getBirthDateFormatted(); + if(is_null($birthday)) { + $intern->birth_date = null; + } else { + $intern->birth_date = $birthday; + } + + $intern->campus = $intern->getCampusFormatted(); + $intern->level = $intern->getLevelFormatted(); + + return $intern; + } + + public function getStudentData($student, $intern) + { + $data = array(); + + // Student object can be null, so be sure we actually have a student first + // TODO: newer PHP versions provide syntax to clean up this logic + if(isset($student)){ + // Credit Hours + $creditHours = $student->getCreditHours(); + if(isset($creditHours)) + { + $data['enrolled_credit_hours'] = $creditHours; + }else{ + $data['enrolled_credit_hours'] = null; + // $this->tpl['ENROLLED_CREDIT_HORUS'] = 'Not Available'; + } + + + // Grad date + $gradDate = $student->getGradDate(); + if(isset($gradDate)) + { + $data['grad_date'] = date('n/j/Y', $gradDate); + }else{ + $data['grad_date'] = null; + //$this->tpl['GRAD_DATE'] = 'Not Available'; + } + + // Major selector + $majors = $student->getMajors(); + $majorsCount = sizeof($majors); + if($majorsCount == 1) { + // Only one major, so display it + $data['major'] = $intern->getMajorDescription(); + } else if($majorsCount > 1) { + // Add a repeat for each major + foreach($majors as $m) { + if($intern->getMajorCode() == $m->getCode()){ + $data['majors_repeat'][] = array('code' => $m->getCode(), 'desc' => $m->getDescription(), 'active' => 'active', 'checked' => 'checked'); + } else { + $data['majors_repeat'][] = array('code' => $m->getCode(), 'desc' => $m->getDescription(), 'active' => '', 'checked' => ''); + } + } + } + } else { + $data['enrolled_credit_hours'] = null; + $data['grad_date'] = null; + $data['major'] = null; + //$this->tpl['ENROLLED_CREDIT_HORUS'] = 'Not Available'; + //$this->tpl['GRAD_DATE'] = 'Not Available'; + } + return $data; + } +} + diff --git a/class/Command/ShowInternship.php b/class/Command/ShowInternship.php index 762b4f49..5c67e2bb 100644 --- a/class/Command/ShowInternship.php +++ b/class/Command/ShowInternship.php @@ -8,6 +8,20 @@ class ShowInternship { + public function test() + { + + switch($_SERVER['REQUEST_METHOD']) { + case 'GET': + $data = $this->get(); + echo (json_encode($data)); + exit; + default: + header('HTTP/1.1 405 Method Not Allowed'); + exit; + } + } + public function execute() { // Make sure an 'internship_id' key is set on the request @@ -17,43 +31,22 @@ public function execute() \PHPWS_Core::reroute('index.php'); } - // Load the Internship - try{ - $intern = InternshipFactory::getInternshipById($_REQUEST['internship_id']); - }catch(\Intern\Exception\InternshipNotFoundException $e){ - \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); - return; - } + - if($intern === false) { - \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); - //TODO redirect to the search interface - return; - } + $tpl = array(); + //javascriptMod('intern', 'editInternshipView'); - // Load a fresh copy of the student data from the web service - try { - $student = StudentProviderFactory::getProvider()->getStudent($intern->getBannerId(), $intern->getTerm()); - } catch(\Intern\Exception\StudentNotFoundException $e) { - $studentId = $intern->getBannerId(); - $student = null; - \NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, "We couldn't find a student with an ID of {$studentId} in Banner. This probably means this person is not an active student."); - } + javascript('jquery'); + $tpl['INTERN_ID'] = $_REQUEST['internship_id']; - // Load the WorkflowState - $wfState = $intern->getWorkflowState(); + return \PHPWS_Template::process($tpl, 'intern', 'editInternshipView.tpl'); - // Load the agency - $agency = AgencyFactory::getAgencyById($intern->getAgencyId()); - - // Load the documents - $docs = $intern->getDocuments(); - if($docs === null) { - $docs = array(); // if no docs, setup an empty array - } +/* + $view = new InternshipView($intern, $student, $wfState, $agency, $docs); return $view->display(); + */ } } diff --git a/class/Command/StateRest.php b/class/Command/StateRest.php index adc0fca9..3f5c2bdc 100644 --- a/class/Command/StateRest.php +++ b/class/Command/StateRest.php @@ -32,7 +32,7 @@ public function get() $sth = $pdo->prepare($sql); $sth->execute(); - $result = $sth->fetchAll(PDO::FETCH_ASSOC); + $result = $sth->fetchAll(\PDO::FETCH_ASSOC); return $result; } diff --git a/class/Internship.php b/class/Internship.php index 17de27c9..6a9b6291 100644 --- a/class/Internship.php +++ b/class/Internship.php @@ -795,7 +795,7 @@ public function setState(WorkflowState $state){ public function getWorkflowState() { $stateName = $this->getStateName(); - + if(is_null($stateName)){ return null; } diff --git a/class/InternshipInventory.php b/class/InternshipInventory.php index f6cd99c4..948778b8 100644 --- a/class/InternshipInventory.php +++ b/class/InternshipInventory.php @@ -207,6 +207,10 @@ public function handleRequest() $ctrl = new Command\EmergencyContactRest(); $ctrl->execute(); break; + case 'editInternshipRest': + $ctrl = new Command\EditInternshipRest(); + $ctrl->execute(); + break; default: $menu = new UI\InternMenu(); $this->content = $menu->display(); diff --git a/class/InternshipView.php b/class/InternshipView.php index 9a95aae8..230ee16a 100644 --- a/class/InternshipView.php +++ b/class/InternshipView.php @@ -74,9 +74,13 @@ public function display() //$this->showStudentWarnings(); //return \PHPWS_Template::process($form->getTemplate(), 'intern', 'internshipView.tpl'); - $content = array(); + $tpl = array(); //javascriptMod('intern', 'editInternshipView'); - return \PHPWS_Template::process($content, 'intern', 'editInternshipView.tpl'); + + javascript('jquery'); + $tpl['INTERN_ID'] = $this->intern->getId(); + + return \PHPWS_Template::process($tpl, 'intern', 'editInternshipView.tpl'); } private function showWarnings() diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 5bee1a61..c0af52bd 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -1,9 +1,59 @@ var EditInternshipInterface = React.createClass({ + getInitialState: function() { + return { + internData: null, + stateData: null + }; + }, + componentWillMount: function(){ + this.getInternData(); + this.getStates(); + }, + getInternData: function(){ + // Grabs the internship data + $.ajax({ + url: 'index.php?module=intern&action=editInternshipRest&internshipId='+internshipId, + type: 'GET', + dataType: 'json', + success: function(data) { + console.log(data); + this.setState({internData: data}); + }.bind(this), + error: function(xhr, status, err) { + alert("Failed to load intern data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, + getStates: function(){ + // Grabs the State data + $.ajax({ + url: 'index.php?module=intern&action=stateRest', + type: 'GET', + dataType: 'json', + success: function(data) { + this.setState({stateData: data}); + }.bind(this), + error: function(xhr, status, err) { + alert("Failed to load state data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, render: function() { + if(this.state.internData != null){ + var interface = + }else{ + var interface =

+ Loading Internship... +

; + } return (
- + {interface}
); } @@ -11,6 +61,22 @@ var EditInternshipInterface = React.createClass({ var StudentInformation = React.createClass({ render: function() { + var intern = this.props.intern; + var student = this.props.student; + var stateData = ''; + + if(this.props.states != null){ + stateData = this.props.states.map(function (state) { + return ( + + ); + }.bind(this)); + } + return (
@@ -21,76 +87,107 @@ var StudentInformation = React.createClass({ Student
-

temp

+

{intern.banner}

-
+
-
+
-
+
- @appstate.edu + @appstate.edu
-

temp

+

{intern.birth_date}

-
+
-
+
-
+
+
-
+
-
+
-

temp

+

{intern.gpa}

-

temp

+

{intern.campus}

-

temp

+

{intern.level}

+
+ +
+ + +
+
+ + {student.majors_repeat.map(function (major) { + return ( + + ); + })} + +
+
+
+ +
+ +

{student.grad_date}

+
+ +
+ +

{student.enrolled_credit_hours}

@@ -100,6 +197,44 @@ var StudentInformation = React.createClass({ } }); +var StateDropDown = React.createClass({ + render: function() { + var optionSelect =
+ if (this.props.active == 1 && this.props.stuState == this.props.sAbbr){ + optionSelect = + }else if(this.props.active == 1){ + optionSelect = + } + return ( + optionSelect + ); + } +}); + +var MajorSelector = React.createClass({ + render: function() { + var setActive = (this.props.active == 'active') ? true : false; + + var activeButton = classNames({ + 'btn' : true, + 'btn-default' : true, + 'active' : setActive + }); + + if (this.props.checked == 'checked'){ + var majorSelect = + }else{ + var majorSelect = + } + return ( + majorSelect + ); + } +}); React.render( , document.getElementById('editInternshipInterface') diff --git a/javascript/emergencyContact/EmgContactList.jsx b/javascript/emergencyContact/EmgContactList.jsx index 0bcf95d4..7b7f46bc 100644 --- a/javascript/emergencyContact/EmgContactList.jsx +++ b/javascript/emergencyContact/EmgContactList.jsx @@ -205,7 +205,7 @@ var EmergencyContactList = React.createClass({ }.bind(this)); }else{ - var eData =

Loading Emergency Contacts...

; + var eData =

Loading Emergency Contacts...

; } return ( diff --git a/templates/editInternshipView.tpl b/templates/editInternshipView.tpl index e0c49b50..ff014a6a 100644 --- a/templates/editInternshipView.tpl +++ b/templates/editInternshipView.tpl @@ -1,8 +1,10 @@ - -
+ + + + + +--> + + + + + + + - + - \ No newline at end of file + \ No newline at end of file From 11580ca99bf4472dc1e811e0115f5f6ca34fcabe Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Thu, 7 Apr 2016 15:38:35 -0400 Subject: [PATCH 04/32] Added Faculty Advisor and Status --- .../editInternshipView/InternshipView.jsx | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 5c5cd303..9b43caa0 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -77,6 +77,7 @@ var EditInternshipInterface = React.createClass({
+
@@ -313,6 +314,73 @@ var InternStatus = React.createClass({ } }); +var FacultyInfo = React.createClass({ + render: function() { + return ( +
+ Faculty Advisor +
+
+ +
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+

+   +

+
+
+ +
+
+

+   +

+
+
+ +
+
+

+   +

+
+
+
+ +
+   +
+
+
+ +
+
+ ); + } + +}); + ReactDOM.render( , document.getElementById('editInternshipInterface') From bc2b9c996b3df3d858580166b7aba9b36304ebe7 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Wed, 4 May 2016 16:06:56 -0400 Subject: [PATCH 05/32] Implemented Faculty Advisor Component. --- class/Command/FacultyDeptRest.php | 4 +- class/Department.php | 2 +- .../editInternshipView/InternshipView.jsx | 241 ++++++++++++++++-- 3 files changed, 223 insertions(+), 24 deletions(-) diff --git a/class/Command/FacultyDeptRest.php b/class/Command/FacultyDeptRest.php index d72a71ca..1cbd87f3 100644 --- a/class/Command/FacultyDeptRest.php +++ b/class/Command/FacultyDeptRest.php @@ -29,8 +29,8 @@ public function execute() private function get() { - PHPWS_Core::initModClass('intern', 'Department.php'); - $departments = Department::getDepartmentsAssocForUsername(Current_User::getUsername()); + \PHPWS_Core::initModClass('intern', 'Department.php'); + $departments = \Intern\Department::getDepartmentsAssocForUsername(\Current_User::getUsername()); $props = array(); diff --git a/class/Department.php b/class/Department.php index f81c541b..7292338a 100644 --- a/class/Department.php +++ b/class/Department.php @@ -140,7 +140,7 @@ public static function getDepartmentsAssocForUsername($username, $includeHiddenD $db->setIndexBy('id'); - $depts[-1] = 'Select Department'; + $depts = array(); $depts += $db->select('col'); return $depts; diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 9b43caa0..45d633cd 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -3,12 +3,15 @@ var EditInternshipInterface = React.createClass({ getInitialState: function() { return { internData: null, + departmentData: null, + facultyData: null, stateData: null }; }, componentWillMount: function(){ this.getInternData(); this.getStates(); + this.getDepartmentData(); }, getInternData: function(){ // Grabs the internship data @@ -41,6 +44,43 @@ var EditInternshipInterface = React.createClass({ }.bind(this) }); }, + //getFacultyListForDept&department + getFacultyData: function(deptNum){ + // Grabs the State data + $.ajax({ + url: 'index.php?module=intern&action=getFacultyListForDept&department='+deptNum, + type: 'GET', + dataType: 'json', + success: function(data) { + if(data != '') + { + data.unshift({first_name: "None", last_name: "", id: "-1"}); + this.setState({facultyData: data}); + } else { + this.setState({facultyData: null}); + } + }.bind(this), + error: function(xhr, status, err) { + alert("Failed to load faculty data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, + getDepartmentData: function(){ + // Grabs the State data + $.ajax({ + url: 'index.php?module=intern&action=facultyDeptRest', + type: 'GET', + dataType: 'json', + success: function(data) { + this.setState({departmentData: data}); + }.bind(this), + error: function(xhr, status, err) { + alert("Failed to load department data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, render: function() { if(this.state.internData != null){ var interface =
@@ -77,7 +117,11 @@ var EditInternshipInterface = React.createClass({
- +
@@ -291,7 +335,7 @@ var InternStatus = React.createClass({

-

Next status

+

Next Status

@@ -305,7 +349,7 @@ var InternStatus = React.createClass({
- +
@@ -314,30 +358,185 @@ var InternStatus = React.createClass({ } }); -var FacultyInfo = React.createClass({ +var FacultyInterface = React.createClass({ + getInitialState: function(){ + return {showDetails: false, facultyID: null}; + }, + //Query for list of departments for first drop down + //Query based on chosen department for second drop down + //Use second dropdown information for details page. + componentWillMount: function() { + this.getFacultyData(); + }, + getFacultyData: function() { + if (this.props.deptNumber !== '') + { + this.setState({facultyID: null, showDetails: true}, this.props.getFacultyData(this.props.deptNumber)); + } else { + this.setState({facultyID: null, showDetails: false}); + } + }, + setFacultyID: function(num) { + this.setState({facultyID: num, showDetails: true}); + }, + hideDetailInfo: function() { + this.setState({facultyID: null,showDetails: false}); + }, render: function() { + + if (this.props.departmentData == null){ + return (
) + } + var facultyDetail = null; + var facultyData = this.props.facultyData; + var facultyID = (this.state.facultyID != null) ? this.state.facultyID :this.props.facultyID; + var dept = this.props.departmentData; + var deptNum = this.props.deptNumber; + + //FIX DEPT NAME + // WORK HERE TUESDAY - GETTING CHANGE BUTTON WORKING + if(facultyData != null){ + facultyDetail = facultyData.map(function (faculty) { + if(facultyID == faculty.id) + return (); + }.bind(this)); + } //this.props.facultyID == null return (
Faculty Advisor -
-
- -
+ {(this.state.showDetails) ? facultyDetail + : } +
+ ); + } + +}); + +var FacultyDropDown = React.createClass({ + handleDeptDrop: function(e) { + var deptNum = e.target.value; + + this.props.getFacultyData(deptNum); + }, + handleFaculty: function(e) { + var faculty = e.target.value; + this.props.setFacultyID(faculty); + + }, + render: function() { + var departments = this.props.departmentData; + var facultyData = this.props.facultyData; + var deptNumber = this.props.deptNumber; + + if (this.props.facultyData == null){ + var ddFaculty = + } else { + var ddFaculty = + } + return( +
+
+ +
+
-
- -
+
+
+ +
+ {ddFaculty}
-
+
+ ); + } +}); + +var FacultyDetail = React.createClass({ + handleClick: function() { + this.props.hideDetailInfo(); + }, + render: function() { + var name = this.props.fname + " " + this.props.lname + " - " + this.props.dept; + + + // Format Faculty Email + var emailInfo = "mailto:" + this.props.username + "@appstate.edu"; + var email = {this.props.username + "@appstate.edu"} + + // Format Faculty Phone + var phone = ''; + if(this.props.phone !== ''){ + var phoneInfo = "tel:+1" + this.props.phone; + phone = {this.props.phone} ; + } else { + phone = Has not been set; + } + + // Format Faculty Fax + var fax = ''; + if(this.props.fax !== ''){ + var faxInfo = "fax:+1" + this.props.fax; + fax = {this.props.fax} ; + } else { + fax = Has not been set; + } + + // Format Faculty Address + var address = ''; + if(this.props.address1 !== '' && this.props.address1 !== null){ + address += this.props.address1; + + if (this.props.address2 !== '') { + address += "
" + this.props.address2; + } + } else { + address = Address has not been set; + } + if(this.props.city !== '' && this.props.city !== null && this.props.state !== '' && this.props.state !== null){ + address += "
" + this.props.city + ", " + this.props.state; + } + if(this.props.zip !== '' && this.props.zip !== null) { + address += " " + this.props.zip; + } + + + return ( +
-
-
+
{name}
@@ -346,7 +545,8 @@ var FacultyInfo = React.createClass({

-   +   + {email}

@@ -354,7 +554,8 @@ var FacultyInfo = React.createClass({

-   +   + {phone}

@@ -362,7 +563,8 @@ var FacultyInfo = React.createClass({

-   +   + {fax}

@@ -370,15 +572,12 @@ var FacultyInfo = React.createClass({
  -
+
{address}
-
- ); } - }); ReactDOM.render( From fc0ae5a70d66320d4ce016ec247ec4cbdf9ea030 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Thu, 5 May 2016 09:36:54 -0400 Subject: [PATCH 06/32] Workflow interface working, but not functional. --- class/Command/EditInternshipRest.php | 21 ++++++++++++- .../editInternshipView/InternshipView.jsx | 31 ++++++++++++++----- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 56b37530..bdc08bd8 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -67,8 +67,27 @@ public function get() // Format intern data $intern = $this->formatIntern($intern); + $state = $intern->getWorkflowState(); // Load the WorkflowState - $wfState = $intern->getWorkflowState(); + $transitions = $state->getTransitions($intern); + + $workflow = array('status'=>$state->getFriendlyName()); + + // Generate the array of radio buttons to add (one for each possible transition) + $radioButtons = array(); + + foreach($transitions as $t){ + $radioButtons[$t->getName()] = $t->getActionName(); + } + + $workflow['workflowAction'] = $radioButtons; + $workflow['allow'] = true; + + if(!\Current_User::allow('intern', 'oied_certify') || $intern->isDomestic()){ + $workflow['allow'] = false; + } + + $wfState = $workflow; // Load the agency $agency = AgencyFactory::getAgencyById($intern->getAgencyId()); diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 45d633cd..374d40aa 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -116,7 +116,9 @@ var EditInternshipInterface = React.createClass({
- + + Status

- Current Status: WORKFLOW_STATE + Current Status: {status}

@@ -339,17 +349,22 @@ var InternStatus = React.createClass({
- -
- -
- + {Object.keys(workflowAction).map(function(key) { + return( +
+ +
) + })} +
- + { allow ? + : + } +
From a3872ed0c9f84b2708b642ae319e657a8e642f3b Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Fri, 6 May 2016 09:21:02 -0400 Subject: [PATCH 07/32] Created Course & Term and Type interface - Not functional --- class/Command/EditInternshipRest.php | 5 +- .../editInternshipView/InternshipView.jsx | 117 ++++++++++++++++-- 2 files changed, 110 insertions(+), 12 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index bdc08bd8..00997b24 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -6,6 +6,7 @@ use \Intern\AgencyFactory; use \Intern\InternshipView; use \Intern\StudentProviderFactory; +use \Intern\Internship; class EditInternshipRest { @@ -101,7 +102,9 @@ public function get() $docs = array(); // if no docs, setup an empty array } - $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agency, "docs" => $docs); + $expType = Internship::getTypesAssoc(); + + $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agency, "docs" => $docs, "experience_type" => $expType); return $content; } diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 374d40aa..e7082c1a 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -124,6 +124,10 @@ var EditInternshipInterface = React.createClass({ deptNumber = {this.state.internData.intern.department_id} getFacultyData = {this.getFacultyData} facultyID = {this.state.internData.intern.faculty_id} /> + + + +
@@ -274,15 +278,11 @@ var StudentInformation = React.createClass({ var StateDropDown = React.createClass({ render: function() { - var optionSelect =
if (this.props.active == 1 && this.props.stuState == this.props.sAbbr){ - optionSelect = - }else if(this.props.active == 1){ - optionSelect = + return + }else { + return } - return ( - optionSelect - ); } }); @@ -350,10 +350,15 @@ var InternStatus = React.createClass({
{Object.keys(workflowAction).map(function(key) { - return( -
- -
) + if(key === "Intern\\WorkflowTransition\\LeaveTransition"){ + return(
+ +
) + } else { + return(
+ +
) + } })}
@@ -595,6 +600,96 @@ var FacultyDetail = React.createClass({ } }); +var CourseAndTerm = React.createClass({ + render: function() { + return( +
+
+ Term & Course Information + +
+ +

TERM

+
+ + +
+ +
+
+ +
+ +
+
+ +
+ +
COURSE_SUBJ
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ Decimal values will be rounded. +
+
+ +
+ +
+ (Limit 28 characters; Banner) +
+
+
+
+ ); + } +}); + + +var TypeInterface = React.createClass({ + render: function() { + var expType = this.props.experience_type; + return( +
+
+ Type +
+
+ {Object.keys(expType).map(function(key) { + if(key === "internship"){ + return(
+ +
) + } else { + return(
+ +
) + } + })} +
+ +
+
+
+ ); + } +}); + + ReactDOM.render( , document.getElementById('editInternshipInterface') From eb3a3898ddf27f85f641ceeffce2f29895f9bf9d Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Mon, 16 May 2016 15:51:59 -0400 Subject: [PATCH 08/32] Interface is completed however contract component is still broken, undefines unresolved, and there is no way to create new hosts. --- class/Command/EditInternshipRest.php | 4 +- .../editInternshipView/InternshipView.jsx | 511 +++++++++++++++--- 2 files changed, 444 insertions(+), 71 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 00997b24..87a7252a 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -7,6 +7,7 @@ use \Intern\InternshipView; use \Intern\StudentProviderFactory; use \Intern\Internship; +use \Intern\Subject; class EditInternshipRest { @@ -103,8 +104,9 @@ public function get() } $expType = Internship::getTypesAssoc(); + $subjects = array("-1" => "Select subject...") + Subject::getSubjects(); - $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agency, "docs" => $docs, "experience_type" => $expType); + $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agency, "docs" => $docs, "experience_type" => $expType, "subjects" => $subjects); return $content; } diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index e7082c1a..e6dd5726 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -20,7 +20,7 @@ var EditInternshipInterface = React.createClass({ type: 'GET', dataType: 'json', success: function(data) { - console.log(data); + console.log(data); this.setState({internData: data}); }.bind(this), error: function(xhr, status, err) { @@ -83,64 +83,108 @@ var EditInternshipInterface = React.createClass({ }, render: function() { if(this.state.internData != null){ - var interface =
-

- Edit Internship -

- - - -
-
- -
- -
- Delete -
- -
- -
-
- - -
-
- - - - -
- -
- - - - - - - -
-
- - -
+ return }else{ - var interface =

- Loading Internship... -

; + return(

+ Loading Internship... +

+ ); } - return ( + } +}); + +var MainInterface = React.createClass({ + render: function() { + var internData = this.props.internData; + var stateData = this.props.stateData; + var facultyData = this.props.facultyData; + var departmentData = this.props.departmentData; + + return(
- {interface} +

+ Edit Internship +

+ +
+ +
+
+ +
+ +
+ Delete +
+ +
+ +
+
+ + +
+
+ + +
+ +
+ + + + + + + +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ + +
); } @@ -279,7 +323,7 @@ var StudentInformation = React.createClass({ var StateDropDown = React.createClass({ render: function() { if (this.props.active == 1 && this.props.stuState == this.props.sAbbr){ - return + return }else { return } @@ -331,7 +375,7 @@ var InternStatus = React.createClass({ render: function() { var status = this.props.workflow.status; var workflowAction = this.props.workflow.workflowAction; - var allow = this.props.workflow.allow; + var oiedAllow = this.props.workflow.allow; // ************** // NOT DONE!!! * @@ -350,7 +394,7 @@ var InternStatus = React.createClass({
{Object.keys(workflowAction).map(function(key) { - if(key === "Intern\\WorkflowTransition\\LeaveTransition"){ + if(key == "Intern\\WorkflowTransition\\LeaveTransition"){ return(
) @@ -366,8 +410,8 @@ var InternStatus = React.createClass({
- { allow ? - : + { oiedAllow ? + : }
@@ -602,6 +646,8 @@ var FacultyDetail = React.createClass({ var CourseAndTerm = React.createClass({ render: function() { + var intern = this.props.intern; + var subjects = this.props.subjects; return(
@@ -609,7 +655,7 @@ var CourseAndTerm = React.createClass({
-

TERM

+

{intern.term}

@@ -624,30 +670,42 @@ var CourseAndTerm = React.createClass({
- -
COURSE_SUBJ
+ +
+ +
+
-
+
-
+
-
+
Decimal values will be rounded.
-
+
(Limit 28 characters; Banner)
@@ -670,11 +728,11 @@ var TypeInterface = React.createClass({ {Object.keys(expType).map(function(key) { if(key === "internship"){ return(
- +
) } else { return(
- +
) } })} @@ -690,6 +748,319 @@ var TypeInterface = React.createClass({ }); +var NoteBox = React.createClass({ + render: function() { + return( +
+
+ NOTES +
+
+ +
+
+ ); + } +}); + +var ChangeLog = React.createClass({ + render: function() { + return( +
+
+
CHANGE_LOG
+
+
+ ); + } +}); + + + + + + + + +// <--------------------------------------------Host Information Section----------------------------------------------> + +var HostInterface = React.createClass({ + render: function() { + var hostData = this.props.hostData; + var intern = this.props.intern; + return( +
+
+

Host Information: {hostData.name}

+
+
+
+
+ + + +
+
+ + +
+
+
+
+ ); + } +}); + +var Location = React.createClass({ + render: function() { + var intern = this.props.intern; + return( +
+
+ Location + +
+ +

{intern.international}

+
+ +
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +

STATE

+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ ); + } +}); + + + +var Compensation = React.createClass({ + render: function() { + var hostData = this.props.hostData; + var intern = this.props.intern; + var allow = intern.stipend; + var rButtons; + + if(intern.paid == 0){ + rButtons =
+ + +
+ } else { + rButtons =
+ + +
+ } + + return( +
+
+ Compensation +
+
+ + {rButtons} + +
+ { allow ? + : + } +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+ ); + } +}); + +var Contracts = React.createClass({ + render: function() { + return( +
+
+ {this.props.title} +
+
+
    +
  • DOWNLOAD  DELETE
  • +
+
+
UPLOAD_DOC
+
+
+
+ ); + } +}); + +var HostDetails = React.createClass({ + render: function() { + var hostData = this.props.hostData; + var stateData = ''; + + if(this.props.states != null){ + stateData = this.props.states.map(function (state) { + return ( + + ); + }.bind(this)); + } + return( +
+
+ Host Details +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ ); + } +}); + +var SupervisorInfo = React.createClass({ + render: function() { + var hostData = this.props.hostData; + return( +
+
+ Supervisor Information +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ ); + } +}); + ReactDOM.render( , document.getElementById('editInternshipInterface') From 63652f8ac77fcdad1cc0ff51b6de9e27421ae979 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Tue, 24 May 2016 09:42:26 -0400 Subject: [PATCH 09/32] Added ability to grab the information from the main form when clicking the save button. --- .../editInternshipView/InternshipView.jsx | 164 ++++++++++++++---- 1 file changed, 127 insertions(+), 37 deletions(-) diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index e6dd5726..6a2cd705 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -13,6 +13,12 @@ var EditInternshipInterface = React.createClass({ this.getStates(); this.getDepartmentData(); }, + saveInternship: function(e){ + e.preventDefault(); + var form = e.target; + + this.refs.mainInterface.buildInternshipData(form); + }, getInternData: function(){ // Grabs the internship data $.ajax({ @@ -87,7 +93,9 @@ var EditInternshipInterface = React.createClass({ facultyData = {this.state.facultyData} departmentData = {this.state.departmentData} stateData = {this.state.stateData} - getFacultyData = {this.getFacultyData} /> + getFacultyData = {this.getFacultyData} + saveInternship = {this.saveInternship} + ref = "mainInterface"/> }else{ return(

Loading Internship... @@ -98,6 +106,24 @@ var EditInternshipInterface = React.createClass({ }); var MainInterface = React.createClass({ + buildInternshipData: function(form) { + var student = this.refs.student.grabStudentData(); + var status = this.refs.status.grabStatusData(form); + var faculty = this.refs.faculty.grabFacultyData(); + var term = this.refs.term.grabCourseAndTerm(); + var type = this.refs.type.grabTypeData(form); + + + var internship = {student: student, + status: status, + faculty: faculty, + term: term, + type: type}; + + console.log(internship); + //Host Information + //var status = this.refs.student.grabStudentData(); + }, render: function() { var internData = this.props.internData; var stateData = this.props.stateData; @@ -110,11 +136,11 @@ var MainInterface = React.createClass({ Edit Internship -

+
- +
@@ -129,26 +155,31 @@ var MainInterface = React.createClass({
- +
- + + facultyID = {internData.intern.faculty_id} + ref = "faculty" /> - + - +
@@ -191,6 +222,20 @@ var MainInterface = React.createClass({ }); var StudentInformation = React.createClass({ + grabStudentData: function() { + + var student = { fname: this.refs.fname.value, + lname: this.refs.lname.value, + mname: this.refs.mname.value, + email: this.refs.email.value, + address: this.refs.address.value, + city: this.refs.city.value, + state: this.refs.state.value, + zip: this.refs.zip.value, + phone: this.refs.phone.value,} + + return student; + }, render: function() { var intern = this.props.intern; var student = this.props.student; @@ -218,24 +263,24 @@ var StudentInformation = React.createClass({
-
+
-
+
-
+
- @appstate.edu + @appstate.edu
@@ -247,28 +292,28 @@ var StudentInformation = React.createClass({
-
+
-
+
-
+
-
+
-
+
@@ -372,14 +417,20 @@ var EmgContactList = React.createClass({ }); var InternStatus = React.createClass({ + grabStatusData: function(form) { + var status = { status: form.elements.workflowOption.value, + oied: form.elements.oiedCert.checked} + + return status; + }, render: function() { var status = this.props.workflow.status; var workflowAction = this.props.workflow.workflowAction; var oiedAllow = this.props.workflow.allow; -// ************** -// NOT DONE!!! * -// ************** +/**************** + NOT DONE!!! * + ****************/ return (
@@ -400,7 +451,7 @@ var InternStatus = React.createClass({
) } else { return(
- +
) } })} @@ -410,8 +461,8 @@ var InternStatus = React.createClass({
- { oiedAllow ? - : + { oiedAllow ? + : }
@@ -435,7 +486,7 @@ var FacultyInterface = React.createClass({ getFacultyData: function() { if (this.props.deptNumber !== '') { - this.setState({facultyID: null, showDetails: true}, this.props.getFacultyData(this.props.deptNumber)); + this.setState({facultyID: this.props.facultyID, showDetails: true}, this.props.getFacultyData(this.props.deptNumber)); } else { this.setState({facultyID: null, showDetails: false}); } @@ -446,6 +497,10 @@ var FacultyInterface = React.createClass({ hideDetailInfo: function() { this.setState({facultyID: null,showDetails: false}); }, + grabFacultyData: function() { + var faculty = {faculty_id: this.state.facultyID}; + return faculty; + }, render: function() { if (this.props.departmentData == null){ @@ -458,7 +513,6 @@ var FacultyInterface = React.createClass({ var deptNum = this.props.deptNumber; //FIX DEPT NAME - // WORK HERE TUESDAY - GETTING CHANGE BUTTON WORKING if(facultyData != null){ facultyDetail = facultyData.map(function (faculty) { if(facultyID == faculty.id) @@ -645,6 +699,16 @@ var FacultyDetail = React.createClass({ }); var CourseAndTerm = React.createClass({ + grabCourseAndTerm: function(form) { + var courseTerm = {termStart: this.refs.startDate.value, + termEnd: this.refs.endDate.value, + courseSubj: this.refs.courseSubj.value, + courseNum: this.refs.courseNum.value, + section: this.refs.courseSect.value, + creditHours: this.refs.courseCH.value, + title: this.refs.courseTitle.value}; + return courseTerm; + }, render: function() { var intern = this.props.intern; var subjects = this.props.subjects; @@ -661,23 +725,23 @@ var CourseAndTerm = React.createClass({
-
+
-
+
- {Object.keys(subjects).map(function (key) { if ((intern.course_subj === key) || (intern.course_subj === null && key == -1)){ return }else { - return + return } }.bind(this)) } @@ -688,24 +752,24 @@ var CourseAndTerm = React.createClass({
-
+
-
+
-
+
Decimal values will be rounded.
-
+
(Limit 28 characters; Banner)
@@ -717,6 +781,11 @@ var CourseAndTerm = React.createClass({ var TypeInterface = React.createClass({ + grabTypeData: function(form) { + var type = { type: form.elements.typeOption.value} + + return type; + }, render: function() { var expType = this.props.experience_type; return( @@ -749,6 +818,9 @@ var TypeInterface = React.createClass({ var NoteBox = React.createClass({ + grabNoteData: function() { + + }, render: function() { return(
@@ -785,6 +857,9 @@ var ChangeLog = React.createClass({ // <--------------------------------------------Host Information Section----------------------------------------------> var HostInterface = React.createClass({ + buildHostData: function() { + + }, render: function() { var hostData = this.props.hostData; var intern = this.props.intern; @@ -814,6 +889,9 @@ var HostInterface = React.createClass({ }); var Location = React.createClass({ + grabLocationData: function() { + + }, render: function() { var intern = this.props.intern; return( @@ -868,6 +946,9 @@ var Location = React.createClass({ var Compensation = React.createClass({ + grabCompensationData: function() { + + }, render: function() { var hostData = this.props.hostData; var intern = this.props.intern; @@ -920,6 +1001,9 @@ var Compensation = React.createClass({ }); var Contracts = React.createClass({ + grabContractData: function() { + + }, render: function() { return(
@@ -940,6 +1024,9 @@ var Contracts = React.createClass({ }); var HostDetails = React.createClass({ + grabHostData: function() { + + }, render: function() { var hostData = this.props.hostData; var stateData = ''; @@ -995,6 +1082,9 @@ var HostDetails = React.createClass({ }); var SupervisorInfo = React.createClass({ + grabSupervisorData: function() { + + }, render: function() { var hostData = this.props.hostData; return( From 34093f43c8a6c20fdd4b58e6afe68307fd49ecb4 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Mon, 20 Jun 2016 15:25:22 -0400 Subject: [PATCH 10/32] Added the ability to see multiple agencies for an internship and added aesthetics for the save buttons for the save button (prevention of double click). --- class/Command/EditInternshipRest.php | 14 +- class/InternshipAgencyFactory.php | 30 +++ .../editInternshipView/InternshipView.jsx | 187 ++++++++++++++---- 3 files changed, 189 insertions(+), 42 deletions(-) create mode 100644 class/InternshipAgencyFactory.php diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 87a7252a..74011838 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -4,6 +4,7 @@ use \Intern\InternshipFactory; use \Intern\AgencyFactory; +use \Intern\InternshipAgencyFactory; use \Intern\InternshipView; use \Intern\StudentProviderFactory; use \Intern\Internship; @@ -91,8 +92,15 @@ public function get() $wfState = $workflow; - // Load the agency - $agency = AgencyFactory::getAgencyById($intern->getAgencyId()); + $agencies = InternshipAgencyFactory::getHostInfoById($intern->getId()); + + // foreach($agencies as $a){ + // // Load the agency + // var_dump(AgencyFactory::getAgencyById($a['agency_id'])); + // //$agencies[] += AgencyFactory::getAgencyById($a['agency_id']); + // } + // //var_dump($agencies); + // exit; // Grab Student Data $studentData = $this->getStudentData($student, $intern); @@ -106,7 +114,7 @@ public function get() $expType = Internship::getTypesAssoc(); $subjects = array("-1" => "Select subject...") + Subject::getSubjects(); - $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agency, "docs" => $docs, "experience_type" => $expType, "subjects" => $subjects); + $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agencies, "docs" => $docs, "experience_type" => $expType, "subjects" => $subjects); return $content; } diff --git a/class/InternshipAgencyFactory.php b/class/InternshipAgencyFactory.php new file mode 100644 index 00000000..326e212d --- /dev/null +++ b/class/InternshipAgencyFactory.php @@ -0,0 +1,30 @@ +getPDO(); + + $stmt = $pdo->prepare("SELECT * FROM intern_internshipAgency + JOIN intern_agency ON intern_internshipAgency.agency_id = intern_agency.id + WHERE intern_internshipAgency.internship_id = :id"); + $stmt->execute(array('id' => $id)); + $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); +//var_dump($id); + return $result; + } +} + diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 6a2cd705..7ba5e5b0 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -5,7 +5,8 @@ var EditInternshipInterface = React.createClass({ internData: null, departmentData: null, facultyData: null, - stateData: null + stateData: null, + submitted: false }; }, componentWillMount: function(){ @@ -16,8 +17,22 @@ var EditInternshipInterface = React.createClass({ saveInternship: function(e){ e.preventDefault(); var form = e.target; - - this.refs.mainInterface.buildInternshipData(form); + var thisComponent = this; + + this.setState({submitted: true}, function(){ + // After disabling submit buttons, use callback to validate the data + if(!false){ + // If the data doesn't validate, wait a second before re-enabling the submit button + // This makes sure the user sees the "Creating..." spinner, instead of it re-rendering + // so fast that they don't think it did anything + setTimeout(function(){ + thisComponent.setState({submitted: false}); + thisComponent.refs.mainInterface.buildInternshipData(form); + }, 1000); + + return; + } + }); }, getInternData: function(){ // Grabs the internship data @@ -93,6 +108,7 @@ var EditInternshipInterface = React.createClass({ facultyData = {this.state.facultyData} departmentData = {this.state.departmentData} stateData = {this.state.stateData} + submitted = {this.state.submitted} getFacultyData = {this.getFacultyData} saveInternship = {this.saveInternship} ref = "mainInterface"/> @@ -112,7 +128,9 @@ var MainInterface = React.createClass({ var faculty = this.refs.faculty.grabFacultyData(); var term = this.refs.term.grabCourseAndTerm(); var type = this.refs.type.grabTypeData(form); + var host = this.refs.host.buildHostData(form); + console.log(host); var internship = {student: student, status: status, @@ -140,7 +158,7 @@ var MainInterface = React.createClass({
- +
@@ -190,7 +208,7 @@ var MainInterface = React.createClass({
- +
@@ -198,9 +216,16 @@ var MainInterface = React.createClass({
- + {internData.agency.map(function (agency) { + return ( + + ); + })} +
@@ -221,6 +246,20 @@ var MainInterface = React.createClass({ } }); +var SaveInternshipButton = React.createClass({ + render: function() { + var button = null; + if(this.props.submitted) { + button = ; + } else { + button = ; + } + return ( + button + ); + } +}); + var StudentInformation = React.createClass({ grabStudentData: function() { @@ -484,7 +523,7 @@ var FacultyInterface = React.createClass({ this.getFacultyData(); }, getFacultyData: function() { - if (this.props.deptNumber !== '') + if (this.props.deptNumber !== '' && this.props.facultyID != null) { this.setState({facultyID: this.props.facultyID, showDetails: true}, this.props.getFacultyData(this.props.deptNumber)); } else { @@ -504,6 +543,7 @@ var FacultyInterface = React.createClass({ render: function() { if (this.props.departmentData == null){ + return (
) } var facultyDetail = null; @@ -514,6 +554,7 @@ var FacultyInterface = React.createClass({ //FIX DEPT NAME if(facultyData != null){ + //console.log("Made it") facultyDetail = facultyData.map(function (faculty) { if(facultyID == faculty.id) return ( var HostInterface = React.createClass({ - buildHostData: function() { - + buildHostData: function(form) { + var location = this.refs.location.grabLocationData(); + var compensation = this.refs.compensation.grabCompensationData(form); + var contract = this.refs.contract.grabContractData(); + var hostDetails = this.refs.hDetails.grabHostData(); + var superDetails = this.refs.sDetails.grabSupervisorData(); + + var hostData = {location: location, + compensation: compensation, + contract: contract, + hostDetails: hostDetails, + superDetails: superDetails}; + + return hostData; }, render: function() { var hostData = this.props.hostData; @@ -871,15 +927,18 @@ var HostInterface = React.createClass({
- + - + intern = {intern} + ref = "compensation" /> +
- + states = {this.props.states} + domestic = {intern.domestic} + ref = "hDetails" /> +
@@ -890,10 +949,27 @@ var HostInterface = React.createClass({ var Location = React.createClass({ grabLocationData: function() { + var locationData = { + loc_address: this.refs.locAddress.value, + loc_city: this.refs.locCity.value, + loc_zip: this.refs.locZip.value, + loc_start: this.refs.locStart.value, + loc_end: this.refs.locEnd.value + }; + return locationData; }, render: function() { - var intern = this.props.intern; + var hostData = this.props.hostData; + var domestic = this.props.domestic; + + if(domestic){ + var locState = "State"; + var zip = "Zip"; + } else { + var locState = "Country"; + var zip = "Postal Code"; + } return(
@@ -901,41 +977,48 @@ var Location = React.createClass({
-

{intern.international}

+

{hostData.international}

- +
-
+
-
+
- -

STATE

+ +

{hostData.loc_state}

+ {!domestic ?
+ +

{hostData.loc_province}

+
+ : null} + +
- -
+ +
-
+
-
+
@@ -946,27 +1029,53 @@ var Location = React.createClass({ var Compensation = React.createClass({ - grabCompensationData: function() { + getInitialState: function() { + return { + paid: false, + stipend: false + }; + }, + componentWillMount: function() { + var intern = this.props.intern; + if(intern.paid == true){ + this.setState({paid: true}); + } + if(intern.stipend == true){ + this.setState({stipend: true}); + } + }, + grabCompensationData: function(form) { + var sOption = "r" + this.props.hostData.id; + console.log(form.elements.r23) + var compensationData = { + paid: form.elements.sOption.checked, + //stipend: form.elements.sOption.checked, + pay_rate: this.refs.payRate.value, + avg_hours_week: this.refs.hoursPerWeek.value + }; + + return compensationData; }, render: function() { var hostData = this.props.hostData; var intern = this.props.intern; var allow = intern.stipend; var rButtons; - - if(intern.paid == 0){ +var rName = "r" + hostData.id; + if(this.state.paid == false){ rButtons =
- - + +
} else { rButtons =
- - + +
} - + var stipendBox = "stipendOption"; + //console.log(stipendBox); return(
@@ -977,8 +1086,8 @@ var Compensation = React.createClass({ {rButtons}
- { allow ? - : + { this.state.stipend ? + : }
@@ -986,12 +1095,12 @@ var Compensation = React.createClass({
-
+
-
+
From 1af5dc46fc27bed569cdb140c8519da4cc8793ba Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Tue, 28 Jun 2016 11:04:33 -0400 Subject: [PATCH 11/32] Allowed internships to have multiple hosts though saving does not work. --- class/Command/EditInternshipRest.php | 33 +++++++++++++++-- .../editInternshipView/InternshipView.jsx | 36 +++++++++++-------- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 74011838..89787f4e 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -107,9 +107,11 @@ public function get() // Load the documents $docs = $intern->getDocuments(); - if($docs === null) { - $docs = array(); // if no docs, setup an empty array - } + // if($docs === null) { + // $docs = array(); // if no docs, setup an empty array + // } else { + $docs = $this->setupDocumentList($docs, $intern->getId()); + //} $expType = Internship::getTypesAssoc(); $subjects = array("-1" => "Select subject...") + Subject::getSubjects(); @@ -186,5 +188,30 @@ public function getStudentData($student, $intern) } return $data; } + + private function setupDocumentList($docs, $id) + { + $data = array(); + + // Document list + if (!is_null($docs)) { + foreach ($docs as $doc) { + $data['docs'][] = array('DOWNLOAD' => $doc->getDownloadLink('blah'), + 'DELETE' => $doc->getDeleteLink()); + } + } + + // Document upload button + $folder = new \Intern\InternFolder(\Intern\InternDocument::getFolderId()); + $data['UPLOAD_DOC'] = $folder->documentUpload($id); + + return $data; + } + + private function setupChangeHistory() + { + $historyView = new ChangeHistoryView($this->intern); + $this->tpl['CHANGE_LOG'] = $historyView->show(); + } } diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 7ba5e5b0..5af52cd2 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -1,3 +1,5 @@ +// !! internshipId is hardcoded as a global variable !! + var EditInternshipInterface = React.createClass({ getInitialState: function() { @@ -147,7 +149,7 @@ var MainInterface = React.createClass({ var stateData = this.props.stateData; var facultyData = this.props.facultyData; var departmentData = this.props.departmentData; - + var deleteURL = "index.php?module=intern&action=DeleteInternship&internship_id=" + internshipId; return(

@@ -162,7 +164,7 @@ var MainInterface = React.createClass({

@@ -1046,36 +1048,40 @@ var Compensation = React.createClass({ } }, grabCompensationData: function(form) { - var sOption = "r" + this.props.hostData.id; - console.log(form.elements.r23) + var compensationData = { - paid: form.elements.sOption.checked, - //stipend: form.elements.sOption.checked, + paid: this.state.paid, + stipend: this.state.stipend, pay_rate: this.refs.payRate.value, avg_hours_week: this.refs.hoursPerWeek.value }; return compensationData; }, + changePaid: function(e) { + this.setState({paid: e.currentTarget.value}); + }, + changeStipend: function(e) { + this.setState({stipend: e.currentTarget.checked}); + }, render: function() { var hostData = this.props.hostData; var intern = this.props.intern; var allow = intern.stipend; var rButtons; -var rName = "r" + hostData.id; + var rName = this.props.hostData.id; if(this.state.paid == false){ rButtons =
- - + +
} else { rButtons =
- - + +
} - var stipendBox = "stipendOption"; - //console.log(stipendBox); + return(
@@ -1086,8 +1092,8 @@ var rName = "r" + hostData.id; {rButtons}
- { this.state.stipend ? - : + { this.state.stipend ? + : }
From 0762e2f05727ccb93c4aa3f450de22bbc7c99290 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Tue, 28 Jun 2016 12:30:36 -0400 Subject: [PATCH 12/32] Fixed student UI errors in the form (formatting). --- class/Command/EditInternshipRest.php | 1 + javascript/editInternshipView/InternshipView.jsx | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 89787f4e..20b352e1 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -130,6 +130,7 @@ public function formatIntern($intern) } $intern->campus = $intern->getCampusFormatted(); + $intern->level = $intern->getLevelFormatted(); $intern->level = $intern->getLevelFormatted(); return $intern; diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 5af52cd2..668ccda5 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -394,12 +394,20 @@ var StudentInformation = React.createClass({
-

{student.grad_date}

+

+ {student.grad_date == null ? Not Available + : student.grad_date + } +

-

{student.enrolled_credit_hours}

+

+ {student.enrolled_credit_hours == null ? Not Available + : student.enrolled_credit_hours + } +

); From a23d68ecbdc7a7382a0c440d3b0b3b808627f555 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Wed, 6 Jul 2016 11:37:29 -0400 Subject: [PATCH 13/32] Cleaned up ui bugs and made Change History and Notes functional. --- class/ChangeHistoryView.php | 25 ++++--- class/Command/EditInternshipRest.php | 10 ++- .../editInternshipView/InternshipView.jsx | 74 +++++++++++++++---- 3 files changed, 80 insertions(+), 29 deletions(-) diff --git a/class/ChangeHistoryView.php b/class/ChangeHistoryView.php index d11d6c5e..4104a3a8 100644 --- a/class/ChangeHistoryView.php +++ b/class/ChangeHistoryView.php @@ -15,35 +15,40 @@ public function show() { $tpl = array(); - $tpl['CHANGELOG_REPEAT'] = array(); - $changes = ChangeHistoryFactory::getChangesForInternship($this->internship); if(is_null($changes)){ return ""; } + // Needed for key value in react -> ChangeFields class + // untill something better can be thought of. + $id = 0; + foreach($changes as $change){ $changeFields = array(); + $changeFields['id'] = $id++; - $changeFields['RELATIVE_DATE'] = $change->getRelativeDate(); - $changeFields['EXACT_DATE'] = $change->getFormattedDate(); - $changeFields['USERNAME'] = $change->getUsername(); + $changeFields['relative_date'] = $change->getRelativeDate(); + $changeFields['exact_date'] = $change->getFormattedDate(); + $changeFields['username'] = $change->getUsername(); if($change->getFromStateFriendlyname() != $change->getToStateFriendlyName()){ - $changeFields['FROM_STATE'] = $change->getFromStateFriendlyName(); - $changeFields['TO_STATE'] = $change->getToStateFriendlyName(); + $changeFields['from_state'] = $change->getFromStateFriendlyName(); + $changeFields['to_state'] = $change->getToStateFriendlyName(); } $note = $change->getNote(); if(!is_null($note)){ - $changeFields['NOTE'] = $note; + $changeFields['note'] = $note; + } else { + $changeFields['note'] = ''; } - $tpl['changelog_repeat'][] = $changeFields; + $tpl[] = $changeFields; } - return \PHPWS_Template::process($tpl, 'intern', 'changeHistory.tpl'); + return $tpl; } } diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 20b352e1..67706026 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -113,10 +113,12 @@ public function get() $docs = $this->setupDocumentList($docs, $intern->getId()); //} + $notes = $this->setupChangeHistory($intern); + $expType = Internship::getTypesAssoc(); $subjects = array("-1" => "Select subject...") + Subject::getSubjects(); - $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agencies, "docs" => $docs, "experience_type" => $expType, "subjects" => $subjects); + $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agencies, "docs" => $docs, "notes" => $notes, "experience_type" => $expType, "subjects" => $subjects); return $content; } @@ -209,10 +211,10 @@ private function setupDocumentList($docs, $id) return $data; } - private function setupChangeHistory() + private function setupChangeHistory($intern) { - $historyView = new ChangeHistoryView($this->intern); - $this->tpl['CHANGE_LOG'] = $historyView->show(); + $historyView = new \Intern\ChangeHistoryView($intern); + return $historyView->show(); } } diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 668ccda5..0423abdb 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -241,7 +241,7 @@ var MainInterface = React.createClass({
- +
); @@ -395,7 +395,7 @@ var StudentInformation = React.createClass({

- {student.grad_date == null ? Not Available + {student.grad_date == null ? Not Available : student.grad_date }

@@ -404,7 +404,7 @@ var StudentInformation = React.createClass({

- {student.enrolled_credit_hours == null ? Not Available + {student.enrolled_credit_hours == null ? Not Available : student.enrolled_credit_hours }

@@ -561,7 +561,7 @@ var FacultyInterface = React.createClass({ var facultyID = (this.state.facultyID != null) ? this.state.facultyID :this.props.facultyID; var dept = this.props.departmentData; var deptNum = this.props.deptNumber; - +console.log(deptNum); //FIX DEPT NAME if(facultyData != null){ //console.log("Made it") @@ -655,7 +655,7 @@ var FacultyDetail = React.createClass({ this.props.hideDetailInfo(); }, render: function() { - var name = this.props.fname + " " + this.props.lname + " - " + this.props.dept; + var name = this.props.fname + " " + this.props.lname + " - " + this.props.deptname; // Format Faculty Email @@ -779,12 +779,12 @@ var CourseAndTerm = React.createClass({
-
+
-
+
@@ -877,14 +877,28 @@ var NoteBox = React.createClass({ }, render: function() { return( +
-
- NOTES -
-
- -
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ ); } }); @@ -894,14 +908,44 @@ var ChangeLog = React.createClass({ return(
-
CHANGE_LOG
+

Change History

+ {this.props.noteData.map(function (notes) { + return ( + + ); + }.bind(this))}
); } }); - +var ChangeFields = React.createClass({ + render: function() { + return( +
+
+

+ {this.props.exactDate}Changed {this.props.relativeData} ago by {this.props.username} +

+ {this.props.fromState != undefined ? +
    +
  • Status changed from {this.props.fromState} to {this.props.toState} +
  • +
+ : null} +
{this.props.note}
+
+
+ ); + } +}); From 76dd11c9811fc1289fb393f4adb8674df372b8cf Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Mon, 14 Mar 2016 09:48:06 -0400 Subject: [PATCH 14/32] Made student component --- class/InternshipView.php | 26 +++-- .../editInternshipView/InternshipView.jsx | 106 ++++++++++++++++++ templates/editInternshipView.tpl | 13 +++ 3 files changed, 136 insertions(+), 9 deletions(-) create mode 100644 javascript/editInternshipView/InternshipView.jsx create mode 100644 templates/editInternshipView.tpl diff --git a/class/InternshipView.php b/class/InternshipView.php index fed30572..c767babd 100644 --- a/class/InternshipView.php +++ b/class/InternshipView.php @@ -31,6 +31,7 @@ public function __construct(Internship $internship, Student $student = null, Wor public function display() { + /* $tpl = array(); // Setup the form @@ -38,39 +39,46 @@ public function display() // Get the Form object $form = $internshipForm->getForm(); + */ /* * If 'missing' is set then we have been redirected * back to the form because the user didn't type in something and * somehow got past the javascript. */ +/* if (isset($_REQUEST['missing'])) { $missing = explode(' ', $_REQUEST['missing']); - +*/ /* * Set classes on field we are missing. */ +/* foreach ($missing as $m) { //$form->addCssClass($m, 'has-error'); $form->addExtraTag($m, 'data-has-error="true"'); } - +*/ /* Plug old values back into form fields. */ - $form->plugIn($_GET); + // $form->plugIn($_GET); /* Re-add hidden fields with object ID's */ - $form->addHidden('id', $this->intern->id); - } + // $form->addHidden('id', $this->intern->id); + // } + + //$form->mergeTemplate($tpl); - $form->mergeTemplate($tpl); + //$this->showWarnings(); + //$this->showStudentWarnings(); - $this->showWarnings(); - $this->showStudentWarnings(); javascript('jquery'); - return \PHPWS_Template::process($form->getTemplate(), 'intern', 'internshipView.tpl'); + $content = array(); + //javascriptMod('intern', 'editInternshipView'); + return \PHPWS_Template::process($content, 'intern', 'editInternshipView.tpl'); + } private function showWarnings() diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx new file mode 100644 index 00000000..5bee1a61 --- /dev/null +++ b/javascript/editInternshipView/InternshipView.jsx @@ -0,0 +1,106 @@ + +var EditInternshipInterface = React.createClass({ + render: function() { + return ( +
+ +
+ ); + } +}); + +var StudentInformation = React.createClass({ + render: function() { + return ( +
+
+ +
+ +
+ Student +
+ +

temp

+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ @appstate.edu +
+
+
+ +
+ +

temp

+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +

temp

+
+ +
+ +

temp

+
+ +
+ +

temp

+
+
+
+
+
+ ); + } +}); + + +React.render( + , document.getElementById('editInternshipInterface') +); \ No newline at end of file diff --git a/templates/editInternshipView.tpl b/templates/editInternshipView.tpl new file mode 100644 index 00000000..e0c49b50 --- /dev/null +++ b/templates/editInternshipView.tpl @@ -0,0 +1,13 @@ + + +
+ + + + + + + + + \ No newline at end of file From 3559bda712c0fe742b972a47cb0177a0bd46ab25 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Tue, 22 Mar 2016 16:09:41 -0400 Subject: [PATCH 15/32] Finalized the student component. --- class/Command/EditInternshipRest.php | 158 +++++++++++++++++ class/Command/ShowInternship.php | 52 +++--- class/Internship.php | 2 +- class/InternshipInventory.php | 5 +- class/InternshipView.php | 1 - .../editInternshipView/InternshipView.jsx | 165 ++++++++++++++++-- .../emergencyContact/EmgContactList.jsx | 2 +- templates/editInternshipView.tpl | 6 +- 8 files changed, 341 insertions(+), 50 deletions(-) create mode 100644 class/Command/EditInternshipRest.php diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php new file mode 100644 index 00000000..56b37530 --- /dev/null +++ b/class/Command/EditInternshipRest.php @@ -0,0 +1,158 @@ +post(); + exit; + case 'DELETE': + $this->delete(); + exit; + case 'GET': + $data = $this->get(); + echo (json_encode($data)); + exit; + default: + header('HTTP/1.1 405 Method Not Allowed'); + exit; + } + } + + public function post() + { + + } + + public function delete() + { + + } + + public function get() + { + // Load the Internship + try{ + $intern = InternshipFactory::getInternshipById($_REQUEST['internshipId']); + }catch(\Intern\Exception\InternshipNotFoundException $e){ + \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); + return; + } + + if($intern === false) { + \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); + //TODO redirect to the search interface + return; + } + + // Load a fresh copy of the student data from the web service + try { + $student = StudentProviderFactory::getProvider()->getStudent($intern->getBannerId(), $intern->getTerm()); + } catch(\Intern\Exception\StudentNotFoundException $e) { + $studentId = $intern->getBannerId(); + $student = null; + \NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, "We couldn't find a student with an ID of {$studentId} in Banner. This probably means this person is not an active student."); + } + + // Format intern data + $intern = $this->formatIntern($intern); + + // Load the WorkflowState + $wfState = $intern->getWorkflowState(); + + // Load the agency + $agency = AgencyFactory::getAgencyById($intern->getAgencyId()); + + // Grab Student Data + $studentData = $this->getStudentData($student, $intern); + + // Load the documents + $docs = $intern->getDocuments(); + if($docs === null) { + $docs = array(); // if no docs, setup an empty array + } + + $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agency, "docs" => $docs); + return $content; + } + + public function formatIntern($intern) + { + $birthday = $intern->getBirthDateFormatted(); + if(is_null($birthday)) { + $intern->birth_date = null; + } else { + $intern->birth_date = $birthday; + } + + $intern->campus = $intern->getCampusFormatted(); + $intern->level = $intern->getLevelFormatted(); + + return $intern; + } + + public function getStudentData($student, $intern) + { + $data = array(); + + // Student object can be null, so be sure we actually have a student first + // TODO: newer PHP versions provide syntax to clean up this logic + if(isset($student)){ + // Credit Hours + $creditHours = $student->getCreditHours(); + if(isset($creditHours)) + { + $data['enrolled_credit_hours'] = $creditHours; + }else{ + $data['enrolled_credit_hours'] = null; + // $this->tpl['ENROLLED_CREDIT_HORUS'] = 'Not Available'; + } + + + // Grad date + $gradDate = $student->getGradDate(); + if(isset($gradDate)) + { + $data['grad_date'] = date('n/j/Y', $gradDate); + }else{ + $data['grad_date'] = null; + //$this->tpl['GRAD_DATE'] = 'Not Available'; + } + + // Major selector + $majors = $student->getMajors(); + $majorsCount = sizeof($majors); + if($majorsCount == 1) { + // Only one major, so display it + $data['major'] = $intern->getMajorDescription(); + } else if($majorsCount > 1) { + // Add a repeat for each major + foreach($majors as $m) { + if($intern->getMajorCode() == $m->getCode()){ + $data['majors_repeat'][] = array('code' => $m->getCode(), 'desc' => $m->getDescription(), 'active' => 'active', 'checked' => 'checked'); + } else { + $data['majors_repeat'][] = array('code' => $m->getCode(), 'desc' => $m->getDescription(), 'active' => '', 'checked' => ''); + } + } + } + } else { + $data['enrolled_credit_hours'] = null; + $data['grad_date'] = null; + $data['major'] = null; + //$this->tpl['ENROLLED_CREDIT_HORUS'] = 'Not Available'; + //$this->tpl['GRAD_DATE'] = 'Not Available'; + } + return $data; + } +} + diff --git a/class/Command/ShowInternship.php b/class/Command/ShowInternship.php index b15f4cfd..685abb46 100644 --- a/class/Command/ShowInternship.php +++ b/class/Command/ShowInternship.php @@ -8,6 +8,20 @@ class ShowInternship { + public function test() + { + + switch($_SERVER['REQUEST_METHOD']) { + case 'GET': + $data = $this->get(); + echo (json_encode($data)); + exit; + default: + header('HTTP/1.1 405 Method Not Allowed'); + exit; + } + } + public function execute() { // Make sure an 'internship_id' key is set on the request @@ -17,43 +31,23 @@ public function execute() \PHPWS_Core::reroute('index.php'); } - // Load the Internship - try{ - $intern = InternshipFactory::getInternshipById($_REQUEST['internship_id']); - }catch(\Intern\Exception\InternshipNotFoundException $e){ - \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); - return; - } + - if($intern === false) { - \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); - //TODO redirect to the search interface - return; - } + $tpl = array(); + //javascriptMod('intern', 'editInternshipView'); - // Load a fresh copy of the student data from the web service - try { - $student = ExternalDataProviderFactory::getProvider()->getStudent($intern->getBannerId(), $intern->getTerm()); - } catch(\Intern\Exception\StudentNotFoundException $e) { - $studentId = $intern->getBannerId(); - $student = null; - \NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, "We couldn't find a student with an ID of {$studentId} in Banner. This probably means this person is not an active student."); - } + javascript('jquery'); + $tpl['INTERN_ID'] = $_REQUEST['internship_id']; - // Load the WorkflowState - $wfState = $intern->getWorkflowState(); - // Load the agency - $agency = AgencyFactory::getAgencyById($intern->getAgencyId()); + return \PHPWS_Template::process($tpl, 'intern', 'editInternshipView.tpl'); - // Load the documents - $docs = $intern->getDocuments(); - if($docs === null) { - $docs = array(); // if no docs, setup an empty array - } +/* + $view = new InternshipView($intern, $student, $wfState, $agency, $docs); return $view->display(); + */ } } diff --git a/class/Internship.php b/class/Internship.php index 20042638..24785258 100644 --- a/class/Internship.php +++ b/class/Internship.php @@ -817,7 +817,7 @@ public function setState(WorkflowState $state){ public function getWorkflowState() { $stateName = $this->getStateName(); - + if(is_null($stateName)){ return null; } diff --git a/class/InternshipInventory.php b/class/InternshipInventory.php index 3136c9ab..ea35ca5f 100644 --- a/class/InternshipInventory.php +++ b/class/InternshipInventory.php @@ -237,7 +237,10 @@ public function handleRequest() $ctrl = new Command\EmergencyContactRest(); $ctrl->execute(); break; - + case 'editInternshipRest': + $ctrl = new Command\EditInternshipRest(); + $ctrl->execute(); + break; default: $menu = new UI\InternMenu(); $this->content = $menu->display(); diff --git a/class/InternshipView.php b/class/InternshipView.php index c767babd..dba3f834 100644 --- a/class/InternshipView.php +++ b/class/InternshipView.php @@ -72,7 +72,6 @@ public function display() //$this->showWarnings(); //$this->showStudentWarnings(); - javascript('jquery'); $content = array(); diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 5bee1a61..c0af52bd 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -1,9 +1,59 @@ var EditInternshipInterface = React.createClass({ + getInitialState: function() { + return { + internData: null, + stateData: null + }; + }, + componentWillMount: function(){ + this.getInternData(); + this.getStates(); + }, + getInternData: function(){ + // Grabs the internship data + $.ajax({ + url: 'index.php?module=intern&action=editInternshipRest&internshipId='+internshipId, + type: 'GET', + dataType: 'json', + success: function(data) { + console.log(data); + this.setState({internData: data}); + }.bind(this), + error: function(xhr, status, err) { + alert("Failed to load intern data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, + getStates: function(){ + // Grabs the State data + $.ajax({ + url: 'index.php?module=intern&action=stateRest', + type: 'GET', + dataType: 'json', + success: function(data) { + this.setState({stateData: data}); + }.bind(this), + error: function(xhr, status, err) { + alert("Failed to load state data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, render: function() { + if(this.state.internData != null){ + var interface = + }else{ + var interface =

+ Loading Internship... +

; + } return (
- + {interface}
); } @@ -11,6 +61,22 @@ var EditInternshipInterface = React.createClass({ var StudentInformation = React.createClass({ render: function() { + var intern = this.props.intern; + var student = this.props.student; + var stateData = ''; + + if(this.props.states != null){ + stateData = this.props.states.map(function (state) { + return ( + + ); + }.bind(this)); + } + return (
@@ -21,76 +87,107 @@ var StudentInformation = React.createClass({ Student
-

temp

+

{intern.banner}

-
+
-
+
-
+
- @appstate.edu + @appstate.edu
-

temp

+

{intern.birth_date}

-
+
-
+
-
+
+
-
+
-
+
-

temp

+

{intern.gpa}

-

temp

+

{intern.campus}

-

temp

+

{intern.level}

+
+ +
+ + +
+
+ + {student.majors_repeat.map(function (major) { + return ( + + ); + })} + +
+
+
+ +
+ +

{student.grad_date}

+
+ +
+ +

{student.enrolled_credit_hours}

@@ -100,6 +197,44 @@ var StudentInformation = React.createClass({ } }); +var StateDropDown = React.createClass({ + render: function() { + var optionSelect =
+ if (this.props.active == 1 && this.props.stuState == this.props.sAbbr){ + optionSelect = + }else if(this.props.active == 1){ + optionSelect = + } + return ( + optionSelect + ); + } +}); + +var MajorSelector = React.createClass({ + render: function() { + var setActive = (this.props.active == 'active') ? true : false; + + var activeButton = classNames({ + 'btn' : true, + 'btn-default' : true, + 'active' : setActive + }); + + if (this.props.checked == 'checked'){ + var majorSelect = + }else{ + var majorSelect = + } + return ( + majorSelect + ); + } +}); React.render( , document.getElementById('editInternshipInterface') diff --git a/javascript/emergencyContact/EmgContactList.jsx b/javascript/emergencyContact/EmgContactList.jsx index 0bcf95d4..7b7f46bc 100644 --- a/javascript/emergencyContact/EmgContactList.jsx +++ b/javascript/emergencyContact/EmgContactList.jsx @@ -205,7 +205,7 @@ var EmergencyContactList = React.createClass({ }.bind(this)); }else{ - var eData =

Loading Emergency Contacts...

; + var eData =

Loading Emergency Contacts...

; } return ( diff --git a/templates/editInternshipView.tpl b/templates/editInternshipView.tpl index e0c49b50..ff014a6a 100644 --- a/templates/editInternshipView.tpl +++ b/templates/editInternshipView.tpl @@ -1,8 +1,10 @@ - -
+ + + + + +--> + + + + + + + - + - \ No newline at end of file + \ No newline at end of file From f1b44973a4268dd1d72936bb6d699c0af04f46b0 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Thu, 7 Apr 2016 15:38:35 -0400 Subject: [PATCH 17/32] Added Faculty Advisor and Status --- .../editInternshipView/InternshipView.jsx | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 5c5cd303..9b43caa0 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -77,6 +77,7 @@ var EditInternshipInterface = React.createClass({
+
@@ -313,6 +314,73 @@ var InternStatus = React.createClass({ } }); +var FacultyInfo = React.createClass({ + render: function() { + return ( +
+ Faculty Advisor +
+
+ +
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+

+   +

+
+
+ +
+
+

+   +

+
+
+ +
+
+

+   +

+
+
+
+ +
+   +
+
+
+ +
+
+ ); + } + +}); + ReactDOM.render( , document.getElementById('editInternshipInterface') From 99b4ac8dc2771d526a0b186eed10ed5fcf59ca2a Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Wed, 4 May 2016 16:06:56 -0400 Subject: [PATCH 18/32] Implemented Faculty Advisor Component. --- class/Command/FacultyDeptRest.php | 5 +- class/Department.php | 147 +++++++++++ .../editInternshipView/InternshipView.jsx | 241 ++++++++++++++++-- 3 files changed, 371 insertions(+), 22 deletions(-) diff --git a/class/Command/FacultyDeptRest.php b/class/Command/FacultyDeptRest.php index 873b13f0..52502bc8 100644 --- a/class/Command/FacultyDeptRest.php +++ b/class/Command/FacultyDeptRest.php @@ -31,7 +31,10 @@ public function execute() private function get() { - $departments = DepartmentFactory::getDepartmentsAssocForUsername(\Current_User::getUsername()); + + \PHPWS_Core::initModClass('intern', 'Department.php'); + $departments = \Intern\Department::getDepartmentsAssocForUsername(\Current_User::getUsername()); + $props = array(); diff --git a/class/Department.php b/class/Department.php index 6e4c3d2a..2db5bbd6 100644 --- a/class/Department.php +++ b/class/Department.php @@ -30,8 +30,155 @@ public function getCSV() return array('Department' => $this->name); } + public function getId(){ return $this->id; + + /** + * @Override Editable::getEditAction + */ + public static function getEditAction() + { + return 'edit_dept'; + } + + /** + * @Override Editable::getEditPermission + */ + public static function getEditPermission() + { + return 'edit_dept'; + } + + /** + * @Override Editable::getDeletePermission + */ + public static function getDeletePermission() + { + return 'delete_dept'; + } + + /** + * @Override Editable::del + * + * Do not show the 'Force Delete?' link if this delete fails. + */ + public function del() + { + if(!\Current_User::allow('intern', $this->getDeletePermission())){ + return \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'You do not have permission to delete departments.'); + } + + if($this->id == 0){ + // Item wasn't loaded correctly + \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "Error occurred while loading information from database."); + return; + } + + $name = $this->getName(); + + try{ + // Try to delete item + if(!$this->delete()){ + // Something bad happend. This should have been caught in the check above... + \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, "Error occurred removing $name from database."); + return; + } + // Item deleted successfully. + \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, "Deleted $name"); + }catch(Exception $e){ + if($e->getCode() == DB_ERROR_CONSTRAINT){ + return \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "One or more internship has $this->name as their department. Sorry, cannot delete."); + }else{ + return \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, $e->getMessage()); + } + } + } + + /** + * Return an associative array {id => dept. name} for all the + * departments in database. + * @param $except - Always show the department with this ID. Used for internships + * with a hidden department. We still want to see it in the select box. + */ + public static function getDepartmentsAssoc($except=null) + { + $db = self::getDb(); + $db->addOrder('name'); + $db->addColumn('id'); + $db->addColumn('name'); + $db->addWhere('hidden', 0, '=', 'OR'); + if(!is_null($except)) { + $db->addWhere('id', $except, '=', 'OR'); + } + + $db->setIndexBy('id'); + + return $db->select('col'); + } + + /** + * Return an associative array {id => dept. name} for all the departments + * that the user with $username is allowed to see. + * @param $includeHiddenDept - Include the department with this ID, even if it's hidden. Used for internships + * with a hidden department. We still want to see it in the select box. + */ + public static function getDepartmentsAssocForUsername($username, $includeHiddenDept = null) + { + $db = self::getDb(); + $db->addOrder('name'); + $db->addColumn('id'); + $db->addColumn('name'); + $db->addWhere('hidden', 0, '=', 'OR', 'grp'); + + if(!is_null($includeHiddenDept)){ + $db->addWhere('id', $includeHiddenDept, '=', 'OR', 'grp'); + } + + // If the user doesn't have the 'all_departments' permission, + // then add a join to limit to specific departments + if(!\Current_User::allow('intern', 'all_departments') && !\Current_User::isDeity()){ + $db->addJoin('LEFT', 'intern_department', 'intern_admin', 'id', 'department_id'); + $db->addWhere('intern_admin.username', $username); + } + + $db->setIndexBy('id'); + + $depts = array(); + $depts += $db->select('col'); + + return $depts; + } + + /** + * Add a department to database with the passed name. + */ + public static function add($name) + { + $name = trim($name); + if($name == ''){ + return \NQ::simple('intern', \Intern\NotifyUI::WARNING, 'No name given for new major. No major was added.'); + } + + $db = self::getDb(); + $db->addWhere('name', $name); + if($db->select('count') > 0){ + \NQ::simple('intern', \Intern\NotifyUI::WARNING, "Department $name already exists."); + return; + } + + // Create the new Department Obj. + $dept = new Department(); + + $dept->name = $name; + $dept->hidden = 0; // Be sure to set a default value for this, otherwise it gets set to null and screws things up + $dept->corequisite = 0; // Be sure to set a default value for this, otherwise it gets set to null and screws things up + + $dept->save(); + + // Successfully saved department to DB. Alert user and remind them the department they just saved. + \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, "Department $name added."); + } public function getName(){ diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 9b43caa0..45d633cd 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -3,12 +3,15 @@ var EditInternshipInterface = React.createClass({ getInitialState: function() { return { internData: null, + departmentData: null, + facultyData: null, stateData: null }; }, componentWillMount: function(){ this.getInternData(); this.getStates(); + this.getDepartmentData(); }, getInternData: function(){ // Grabs the internship data @@ -41,6 +44,43 @@ var EditInternshipInterface = React.createClass({ }.bind(this) }); }, + //getFacultyListForDept&department + getFacultyData: function(deptNum){ + // Grabs the State data + $.ajax({ + url: 'index.php?module=intern&action=getFacultyListForDept&department='+deptNum, + type: 'GET', + dataType: 'json', + success: function(data) { + if(data != '') + { + data.unshift({first_name: "None", last_name: "", id: "-1"}); + this.setState({facultyData: data}); + } else { + this.setState({facultyData: null}); + } + }.bind(this), + error: function(xhr, status, err) { + alert("Failed to load faculty data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, + getDepartmentData: function(){ + // Grabs the State data + $.ajax({ + url: 'index.php?module=intern&action=facultyDeptRest', + type: 'GET', + dataType: 'json', + success: function(data) { + this.setState({departmentData: data}); + }.bind(this), + error: function(xhr, status, err) { + alert("Failed to load department data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, render: function() { if(this.state.internData != null){ var interface =
@@ -77,7 +117,11 @@ var EditInternshipInterface = React.createClass({
- +
@@ -291,7 +335,7 @@ var InternStatus = React.createClass({

-

Next status

+

Next Status

@@ -305,7 +349,7 @@ var InternStatus = React.createClass({
- +
@@ -314,30 +358,185 @@ var InternStatus = React.createClass({ } }); -var FacultyInfo = React.createClass({ +var FacultyInterface = React.createClass({ + getInitialState: function(){ + return {showDetails: false, facultyID: null}; + }, + //Query for list of departments for first drop down + //Query based on chosen department for second drop down + //Use second dropdown information for details page. + componentWillMount: function() { + this.getFacultyData(); + }, + getFacultyData: function() { + if (this.props.deptNumber !== '') + { + this.setState({facultyID: null, showDetails: true}, this.props.getFacultyData(this.props.deptNumber)); + } else { + this.setState({facultyID: null, showDetails: false}); + } + }, + setFacultyID: function(num) { + this.setState({facultyID: num, showDetails: true}); + }, + hideDetailInfo: function() { + this.setState({facultyID: null,showDetails: false}); + }, render: function() { + + if (this.props.departmentData == null){ + return (
) + } + var facultyDetail = null; + var facultyData = this.props.facultyData; + var facultyID = (this.state.facultyID != null) ? this.state.facultyID :this.props.facultyID; + var dept = this.props.departmentData; + var deptNum = this.props.deptNumber; + + //FIX DEPT NAME + // WORK HERE TUESDAY - GETTING CHANGE BUTTON WORKING + if(facultyData != null){ + facultyDetail = facultyData.map(function (faculty) { + if(facultyID == faculty.id) + return (); + }.bind(this)); + } //this.props.facultyID == null return (
Faculty Advisor -
-
- -
+ {(this.state.showDetails) ? facultyDetail + : } +
+ ); + } + +}); + +var FacultyDropDown = React.createClass({ + handleDeptDrop: function(e) { + var deptNum = e.target.value; + + this.props.getFacultyData(deptNum); + }, + handleFaculty: function(e) { + var faculty = e.target.value; + this.props.setFacultyID(faculty); + + }, + render: function() { + var departments = this.props.departmentData; + var facultyData = this.props.facultyData; + var deptNumber = this.props.deptNumber; + + if (this.props.facultyData == null){ + var ddFaculty = + } else { + var ddFaculty = + } + return( +
+
+ +
+
-
- -
+
+
+ +
+ {ddFaculty}
-
+
+ ); + } +}); + +var FacultyDetail = React.createClass({ + handleClick: function() { + this.props.hideDetailInfo(); + }, + render: function() { + var name = this.props.fname + " " + this.props.lname + " - " + this.props.dept; + + + // Format Faculty Email + var emailInfo = "mailto:" + this.props.username + "@appstate.edu"; + var email = {this.props.username + "@appstate.edu"} + + // Format Faculty Phone + var phone = ''; + if(this.props.phone !== ''){ + var phoneInfo = "tel:+1" + this.props.phone; + phone = {this.props.phone} ; + } else { + phone = Has not been set; + } + + // Format Faculty Fax + var fax = ''; + if(this.props.fax !== ''){ + var faxInfo = "fax:+1" + this.props.fax; + fax = {this.props.fax} ; + } else { + fax = Has not been set; + } + + // Format Faculty Address + var address = ''; + if(this.props.address1 !== '' && this.props.address1 !== null){ + address += this.props.address1; + + if (this.props.address2 !== '') { + address += "
" + this.props.address2; + } + } else { + address = Address has not been set; + } + if(this.props.city !== '' && this.props.city !== null && this.props.state !== '' && this.props.state !== null){ + address += "
" + this.props.city + ", " + this.props.state; + } + if(this.props.zip !== '' && this.props.zip !== null) { + address += " " + this.props.zip; + } + + + return ( +
-
-
+
{name}
@@ -346,7 +545,8 @@ var FacultyInfo = React.createClass({

-   +   + {email}

@@ -354,7 +554,8 @@ var FacultyInfo = React.createClass({

-   +   + {phone}

@@ -362,7 +563,8 @@ var FacultyInfo = React.createClass({

-   +   + {fax}

@@ -370,15 +572,12 @@ var FacultyInfo = React.createClass({
  -
+
{address}
-
- ); } - }); ReactDOM.render( From c07f3b13b42183ebda250efd9db76762298ca5f2 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Thu, 5 May 2016 09:36:54 -0400 Subject: [PATCH 19/32] Workflow interface working, but not functional. --- class/Command/EditInternshipRest.php | 21 ++++++++++++- .../editInternshipView/InternshipView.jsx | 31 ++++++++++++++----- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 56b37530..bdc08bd8 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -67,8 +67,27 @@ public function get() // Format intern data $intern = $this->formatIntern($intern); + $state = $intern->getWorkflowState(); // Load the WorkflowState - $wfState = $intern->getWorkflowState(); + $transitions = $state->getTransitions($intern); + + $workflow = array('status'=>$state->getFriendlyName()); + + // Generate the array of radio buttons to add (one for each possible transition) + $radioButtons = array(); + + foreach($transitions as $t){ + $radioButtons[$t->getName()] = $t->getActionName(); + } + + $workflow['workflowAction'] = $radioButtons; + $workflow['allow'] = true; + + if(!\Current_User::allow('intern', 'oied_certify') || $intern->isDomestic()){ + $workflow['allow'] = false; + } + + $wfState = $workflow; // Load the agency $agency = AgencyFactory::getAgencyById($intern->getAgencyId()); diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 45d633cd..374d40aa 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -116,7 +116,9 @@ var EditInternshipInterface = React.createClass({
- + + Status

- Current Status: WORKFLOW_STATE + Current Status: {status}

@@ -339,17 +349,22 @@ var InternStatus = React.createClass({
- -
- -
- + {Object.keys(workflowAction).map(function(key) { + return( +
+ +
) + })} +
- + { allow ? + : + } +
From ba3a74c55908f38330206ce2943e0ff807af71f2 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Fri, 6 May 2016 09:21:02 -0400 Subject: [PATCH 20/32] Created Course & Term and Type interface - Not functional --- class/Command/EditInternshipRest.php | 5 +- .../editInternshipView/InternshipView.jsx | 117 ++++++++++++++++-- 2 files changed, 110 insertions(+), 12 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index bdc08bd8..00997b24 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -6,6 +6,7 @@ use \Intern\AgencyFactory; use \Intern\InternshipView; use \Intern\StudentProviderFactory; +use \Intern\Internship; class EditInternshipRest { @@ -101,7 +102,9 @@ public function get() $docs = array(); // if no docs, setup an empty array } - $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agency, "docs" => $docs); + $expType = Internship::getTypesAssoc(); + + $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agency, "docs" => $docs, "experience_type" => $expType); return $content; } diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 374d40aa..e7082c1a 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -124,6 +124,10 @@ var EditInternshipInterface = React.createClass({ deptNumber = {this.state.internData.intern.department_id} getFacultyData = {this.getFacultyData} facultyID = {this.state.internData.intern.faculty_id} /> + + + +
@@ -274,15 +278,11 @@ var StudentInformation = React.createClass({ var StateDropDown = React.createClass({ render: function() { - var optionSelect =
if (this.props.active == 1 && this.props.stuState == this.props.sAbbr){ - optionSelect = - }else if(this.props.active == 1){ - optionSelect = + return + }else { + return } - return ( - optionSelect - ); } }); @@ -350,10 +350,15 @@ var InternStatus = React.createClass({
{Object.keys(workflowAction).map(function(key) { - return( -
- -
) + if(key === "Intern\\WorkflowTransition\\LeaveTransition"){ + return(
+ +
) + } else { + return(
+ +
) + } })}
@@ -595,6 +600,96 @@ var FacultyDetail = React.createClass({ } }); +var CourseAndTerm = React.createClass({ + render: function() { + return( +
+
+ Term & Course Information + +
+ +

TERM

+
+ + +
+ +
+
+ +
+ +
+
+ +
+ +
COURSE_SUBJ
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ Decimal values will be rounded. +
+
+ +
+ +
+ (Limit 28 characters; Banner) +
+
+
+
+ ); + } +}); + + +var TypeInterface = React.createClass({ + render: function() { + var expType = this.props.experience_type; + return( +
+
+ Type +
+
+ {Object.keys(expType).map(function(key) { + if(key === "internship"){ + return(
+ +
) + } else { + return(
+ +
) + } + })} +
+ +
+
+
+ ); + } +}); + + ReactDOM.render( , document.getElementById('editInternshipInterface') From 9cb6c4424c0d74ab69358193e16bc5983cbc3804 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Mon, 16 May 2016 15:51:59 -0400 Subject: [PATCH 21/32] Interface is completed however contract component is still broken, undefines unresolved, and there is no way to create new hosts. --- class/Command/EditInternshipRest.php | 4 +- .../editInternshipView/InternshipView.jsx | 511 +++++++++++++++--- 2 files changed, 444 insertions(+), 71 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 00997b24..87a7252a 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -7,6 +7,7 @@ use \Intern\InternshipView; use \Intern\StudentProviderFactory; use \Intern\Internship; +use \Intern\Subject; class EditInternshipRest { @@ -103,8 +104,9 @@ public function get() } $expType = Internship::getTypesAssoc(); + $subjects = array("-1" => "Select subject...") + Subject::getSubjects(); - $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agency, "docs" => $docs, "experience_type" => $expType); + $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agency, "docs" => $docs, "experience_type" => $expType, "subjects" => $subjects); return $content; } diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index e7082c1a..e6dd5726 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -20,7 +20,7 @@ var EditInternshipInterface = React.createClass({ type: 'GET', dataType: 'json', success: function(data) { - console.log(data); + console.log(data); this.setState({internData: data}); }.bind(this), error: function(xhr, status, err) { @@ -83,64 +83,108 @@ var EditInternshipInterface = React.createClass({ }, render: function() { if(this.state.internData != null){ - var interface =
-

- Edit Internship -

- - - -
-
- -
- -
- Delete -
- -
- -
-
- - -
-
- - - - -
- -
- - - - - - - -
-
- - -
+ return }else{ - var interface =

- Loading Internship... -

; + return(

+ Loading Internship... +

+ ); } - return ( + } +}); + +var MainInterface = React.createClass({ + render: function() { + var internData = this.props.internData; + var stateData = this.props.stateData; + var facultyData = this.props.facultyData; + var departmentData = this.props.departmentData; + + return(
- {interface} +

+ Edit Internship +

+ +
+ +
+
+ +
+ +
+ Delete +
+ +
+ +
+
+ + +
+
+ + +
+ +
+ + + + + + + +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ +
+
+ + +
); } @@ -279,7 +323,7 @@ var StudentInformation = React.createClass({ var StateDropDown = React.createClass({ render: function() { if (this.props.active == 1 && this.props.stuState == this.props.sAbbr){ - return + return }else { return } @@ -331,7 +375,7 @@ var InternStatus = React.createClass({ render: function() { var status = this.props.workflow.status; var workflowAction = this.props.workflow.workflowAction; - var allow = this.props.workflow.allow; + var oiedAllow = this.props.workflow.allow; // ************** // NOT DONE!!! * @@ -350,7 +394,7 @@ var InternStatus = React.createClass({
{Object.keys(workflowAction).map(function(key) { - if(key === "Intern\\WorkflowTransition\\LeaveTransition"){ + if(key == "Intern\\WorkflowTransition\\LeaveTransition"){ return(
) @@ -366,8 +410,8 @@ var InternStatus = React.createClass({
- { allow ? - : + { oiedAllow ? + : }
@@ -602,6 +646,8 @@ var FacultyDetail = React.createClass({ var CourseAndTerm = React.createClass({ render: function() { + var intern = this.props.intern; + var subjects = this.props.subjects; return(
@@ -609,7 +655,7 @@ var CourseAndTerm = React.createClass({
-

TERM

+

{intern.term}

@@ -624,30 +670,42 @@ var CourseAndTerm = React.createClass({
- -
COURSE_SUBJ
+ +
+ +
+
-
+
-
+
-
+
Decimal values will be rounded.
-
+
(Limit 28 characters; Banner)
@@ -670,11 +728,11 @@ var TypeInterface = React.createClass({ {Object.keys(expType).map(function(key) { if(key === "internship"){ return(
- +
) } else { return(
- +
) } })} @@ -690,6 +748,319 @@ var TypeInterface = React.createClass({ }); +var NoteBox = React.createClass({ + render: function() { + return( +
+
+ NOTES +
+
+ +
+
+ ); + } +}); + +var ChangeLog = React.createClass({ + render: function() { + return( +
+
+
CHANGE_LOG
+
+
+ ); + } +}); + + + + + + + + +// <--------------------------------------------Host Information Section----------------------------------------------> + +var HostInterface = React.createClass({ + render: function() { + var hostData = this.props.hostData; + var intern = this.props.intern; + return( +
+
+

Host Information: {hostData.name}

+
+
+
+
+ + + +
+
+ + +
+
+
+
+ ); + } +}); + +var Location = React.createClass({ + render: function() { + var intern = this.props.intern; + return( +
+
+ Location + +
+ +

{intern.international}

+
+ +
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +

STATE

+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+
+ ); + } +}); + + + +var Compensation = React.createClass({ + render: function() { + var hostData = this.props.hostData; + var intern = this.props.intern; + var allow = intern.stipend; + var rButtons; + + if(intern.paid == 0){ + rButtons =
+ + +
+ } else { + rButtons =
+ + +
+ } + + return( +
+
+ Compensation +
+
+ + {rButtons} + +
+ { allow ? + : + } +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+ ); + } +}); + +var Contracts = React.createClass({ + render: function() { + return( +
+
+ {this.props.title} +
+
+
    +
  • DOWNLOAD  DELETE
  • +
+
+
UPLOAD_DOC
+
+
+
+ ); + } +}); + +var HostDetails = React.createClass({ + render: function() { + var hostData = this.props.hostData; + var stateData = ''; + + if(this.props.states != null){ + stateData = this.props.states.map(function (state) { + return ( + + ); + }.bind(this)); + } + return( +
+
+ Host Details +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ ); + } +}); + +var SupervisorInfo = React.createClass({ + render: function() { + var hostData = this.props.hostData; + return( +
+
+ Supervisor Information +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ ); + } +}); + ReactDOM.render( , document.getElementById('editInternshipInterface') From 95c1ed5c5150f511b9fc952de5ab13bd0e9181c7 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Tue, 24 May 2016 09:42:26 -0400 Subject: [PATCH 22/32] Added ability to grab the information from the main form when clicking the save button. --- .../editInternshipView/InternshipView.jsx | 164 ++++++++++++++---- 1 file changed, 127 insertions(+), 37 deletions(-) diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index e6dd5726..6a2cd705 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -13,6 +13,12 @@ var EditInternshipInterface = React.createClass({ this.getStates(); this.getDepartmentData(); }, + saveInternship: function(e){ + e.preventDefault(); + var form = e.target; + + this.refs.mainInterface.buildInternshipData(form); + }, getInternData: function(){ // Grabs the internship data $.ajax({ @@ -87,7 +93,9 @@ var EditInternshipInterface = React.createClass({ facultyData = {this.state.facultyData} departmentData = {this.state.departmentData} stateData = {this.state.stateData} - getFacultyData = {this.getFacultyData} /> + getFacultyData = {this.getFacultyData} + saveInternship = {this.saveInternship} + ref = "mainInterface"/> }else{ return(

Loading Internship... @@ -98,6 +106,24 @@ var EditInternshipInterface = React.createClass({ }); var MainInterface = React.createClass({ + buildInternshipData: function(form) { + var student = this.refs.student.grabStudentData(); + var status = this.refs.status.grabStatusData(form); + var faculty = this.refs.faculty.grabFacultyData(); + var term = this.refs.term.grabCourseAndTerm(); + var type = this.refs.type.grabTypeData(form); + + + var internship = {student: student, + status: status, + faculty: faculty, + term: term, + type: type}; + + console.log(internship); + //Host Information + //var status = this.refs.student.grabStudentData(); + }, render: function() { var internData = this.props.internData; var stateData = this.props.stateData; @@ -110,11 +136,11 @@ var MainInterface = React.createClass({ Edit Internship -

+
- +
@@ -129,26 +155,31 @@ var MainInterface = React.createClass({
- +
- + + facultyID = {internData.intern.faculty_id} + ref = "faculty" /> - + - +
@@ -191,6 +222,20 @@ var MainInterface = React.createClass({ }); var StudentInformation = React.createClass({ + grabStudentData: function() { + + var student = { fname: this.refs.fname.value, + lname: this.refs.lname.value, + mname: this.refs.mname.value, + email: this.refs.email.value, + address: this.refs.address.value, + city: this.refs.city.value, + state: this.refs.state.value, + zip: this.refs.zip.value, + phone: this.refs.phone.value,} + + return student; + }, render: function() { var intern = this.props.intern; var student = this.props.student; @@ -218,24 +263,24 @@ var StudentInformation = React.createClass({
-
+
-
+
-
+
- @appstate.edu + @appstate.edu
@@ -247,28 +292,28 @@ var StudentInformation = React.createClass({
-
+
-
+
-
+
-
+
-
+
@@ -372,14 +417,20 @@ var EmgContactList = React.createClass({ }); var InternStatus = React.createClass({ + grabStatusData: function(form) { + var status = { status: form.elements.workflowOption.value, + oied: form.elements.oiedCert.checked} + + return status; + }, render: function() { var status = this.props.workflow.status; var workflowAction = this.props.workflow.workflowAction; var oiedAllow = this.props.workflow.allow; -// ************** -// NOT DONE!!! * -// ************** +/**************** + NOT DONE!!! * + ****************/ return (
@@ -400,7 +451,7 @@ var InternStatus = React.createClass({
) } else { return(
- +
) } })} @@ -410,8 +461,8 @@ var InternStatus = React.createClass({
- { oiedAllow ? - : + { oiedAllow ? + : }
@@ -435,7 +486,7 @@ var FacultyInterface = React.createClass({ getFacultyData: function() { if (this.props.deptNumber !== '') { - this.setState({facultyID: null, showDetails: true}, this.props.getFacultyData(this.props.deptNumber)); + this.setState({facultyID: this.props.facultyID, showDetails: true}, this.props.getFacultyData(this.props.deptNumber)); } else { this.setState({facultyID: null, showDetails: false}); } @@ -446,6 +497,10 @@ var FacultyInterface = React.createClass({ hideDetailInfo: function() { this.setState({facultyID: null,showDetails: false}); }, + grabFacultyData: function() { + var faculty = {faculty_id: this.state.facultyID}; + return faculty; + }, render: function() { if (this.props.departmentData == null){ @@ -458,7 +513,6 @@ var FacultyInterface = React.createClass({ var deptNum = this.props.deptNumber; //FIX DEPT NAME - // WORK HERE TUESDAY - GETTING CHANGE BUTTON WORKING if(facultyData != null){ facultyDetail = facultyData.map(function (faculty) { if(facultyID == faculty.id) @@ -645,6 +699,16 @@ var FacultyDetail = React.createClass({ }); var CourseAndTerm = React.createClass({ + grabCourseAndTerm: function(form) { + var courseTerm = {termStart: this.refs.startDate.value, + termEnd: this.refs.endDate.value, + courseSubj: this.refs.courseSubj.value, + courseNum: this.refs.courseNum.value, + section: this.refs.courseSect.value, + creditHours: this.refs.courseCH.value, + title: this.refs.courseTitle.value}; + return courseTerm; + }, render: function() { var intern = this.props.intern; var subjects = this.props.subjects; @@ -661,23 +725,23 @@ var CourseAndTerm = React.createClass({
-
+
-
+
- {Object.keys(subjects).map(function (key) { if ((intern.course_subj === key) || (intern.course_subj === null && key == -1)){ return }else { - return + return } }.bind(this)) } @@ -688,24 +752,24 @@ var CourseAndTerm = React.createClass({
-
+
-
+
-
+
Decimal values will be rounded.
-
+
(Limit 28 characters; Banner)
@@ -717,6 +781,11 @@ var CourseAndTerm = React.createClass({ var TypeInterface = React.createClass({ + grabTypeData: function(form) { + var type = { type: form.elements.typeOption.value} + + return type; + }, render: function() { var expType = this.props.experience_type; return( @@ -749,6 +818,9 @@ var TypeInterface = React.createClass({ var NoteBox = React.createClass({ + grabNoteData: function() { + + }, render: function() { return(
@@ -785,6 +857,9 @@ var ChangeLog = React.createClass({ // <--------------------------------------------Host Information Section----------------------------------------------> var HostInterface = React.createClass({ + buildHostData: function() { + + }, render: function() { var hostData = this.props.hostData; var intern = this.props.intern; @@ -814,6 +889,9 @@ var HostInterface = React.createClass({ }); var Location = React.createClass({ + grabLocationData: function() { + + }, render: function() { var intern = this.props.intern; return( @@ -868,6 +946,9 @@ var Location = React.createClass({ var Compensation = React.createClass({ + grabCompensationData: function() { + + }, render: function() { var hostData = this.props.hostData; var intern = this.props.intern; @@ -920,6 +1001,9 @@ var Compensation = React.createClass({ }); var Contracts = React.createClass({ + grabContractData: function() { + + }, render: function() { return(
@@ -940,6 +1024,9 @@ var Contracts = React.createClass({ }); var HostDetails = React.createClass({ + grabHostData: function() { + + }, render: function() { var hostData = this.props.hostData; var stateData = ''; @@ -995,6 +1082,9 @@ var HostDetails = React.createClass({ }); var SupervisorInfo = React.createClass({ + grabSupervisorData: function() { + + }, render: function() { var hostData = this.props.hostData; return( From e38f01332787d73f6fc8b62f62e3a9906c28b2a9 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Mon, 20 Jun 2016 15:25:22 -0400 Subject: [PATCH 23/32] Added the ability to see multiple agencies for an internship and added aesthetics for the save buttons for the save button (prevention of double click). --- class/Command/EditInternshipRest.php | 14 +- class/InternshipAgencyFactory.php | 30 +++ .../editInternshipView/InternshipView.jsx | 187 ++++++++++++++---- 3 files changed, 189 insertions(+), 42 deletions(-) create mode 100644 class/InternshipAgencyFactory.php diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 87a7252a..74011838 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -4,6 +4,7 @@ use \Intern\InternshipFactory; use \Intern\AgencyFactory; +use \Intern\InternshipAgencyFactory; use \Intern\InternshipView; use \Intern\StudentProviderFactory; use \Intern\Internship; @@ -91,8 +92,15 @@ public function get() $wfState = $workflow; - // Load the agency - $agency = AgencyFactory::getAgencyById($intern->getAgencyId()); + $agencies = InternshipAgencyFactory::getHostInfoById($intern->getId()); + + // foreach($agencies as $a){ + // // Load the agency + // var_dump(AgencyFactory::getAgencyById($a['agency_id'])); + // //$agencies[] += AgencyFactory::getAgencyById($a['agency_id']); + // } + // //var_dump($agencies); + // exit; // Grab Student Data $studentData = $this->getStudentData($student, $intern); @@ -106,7 +114,7 @@ public function get() $expType = Internship::getTypesAssoc(); $subjects = array("-1" => "Select subject...") + Subject::getSubjects(); - $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agency, "docs" => $docs, "experience_type" => $expType, "subjects" => $subjects); + $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agencies, "docs" => $docs, "experience_type" => $expType, "subjects" => $subjects); return $content; } diff --git a/class/InternshipAgencyFactory.php b/class/InternshipAgencyFactory.php new file mode 100644 index 00000000..326e212d --- /dev/null +++ b/class/InternshipAgencyFactory.php @@ -0,0 +1,30 @@ +getPDO(); + + $stmt = $pdo->prepare("SELECT * FROM intern_internshipAgency + JOIN intern_agency ON intern_internshipAgency.agency_id = intern_agency.id + WHERE intern_internshipAgency.internship_id = :id"); + $stmt->execute(array('id' => $id)); + $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); +//var_dump($id); + return $result; + } +} + diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 6a2cd705..7ba5e5b0 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -5,7 +5,8 @@ var EditInternshipInterface = React.createClass({ internData: null, departmentData: null, facultyData: null, - stateData: null + stateData: null, + submitted: false }; }, componentWillMount: function(){ @@ -16,8 +17,22 @@ var EditInternshipInterface = React.createClass({ saveInternship: function(e){ e.preventDefault(); var form = e.target; - - this.refs.mainInterface.buildInternshipData(form); + var thisComponent = this; + + this.setState({submitted: true}, function(){ + // After disabling submit buttons, use callback to validate the data + if(!false){ + // If the data doesn't validate, wait a second before re-enabling the submit button + // This makes sure the user sees the "Creating..." spinner, instead of it re-rendering + // so fast that they don't think it did anything + setTimeout(function(){ + thisComponent.setState({submitted: false}); + thisComponent.refs.mainInterface.buildInternshipData(form); + }, 1000); + + return; + } + }); }, getInternData: function(){ // Grabs the internship data @@ -93,6 +108,7 @@ var EditInternshipInterface = React.createClass({ facultyData = {this.state.facultyData} departmentData = {this.state.departmentData} stateData = {this.state.stateData} + submitted = {this.state.submitted} getFacultyData = {this.getFacultyData} saveInternship = {this.saveInternship} ref = "mainInterface"/> @@ -112,7 +128,9 @@ var MainInterface = React.createClass({ var faculty = this.refs.faculty.grabFacultyData(); var term = this.refs.term.grabCourseAndTerm(); var type = this.refs.type.grabTypeData(form); + var host = this.refs.host.buildHostData(form); + console.log(host); var internship = {student: student, status: status, @@ -140,7 +158,7 @@ var MainInterface = React.createClass({
- +
@@ -190,7 +208,7 @@ var MainInterface = React.createClass({
- +
@@ -198,9 +216,16 @@ var MainInterface = React.createClass({
- + {internData.agency.map(function (agency) { + return ( + + ); + })} +
@@ -221,6 +246,20 @@ var MainInterface = React.createClass({ } }); +var SaveInternshipButton = React.createClass({ + render: function() { + var button = null; + if(this.props.submitted) { + button = ; + } else { + button = ; + } + return ( + button + ); + } +}); + var StudentInformation = React.createClass({ grabStudentData: function() { @@ -484,7 +523,7 @@ var FacultyInterface = React.createClass({ this.getFacultyData(); }, getFacultyData: function() { - if (this.props.deptNumber !== '') + if (this.props.deptNumber !== '' && this.props.facultyID != null) { this.setState({facultyID: this.props.facultyID, showDetails: true}, this.props.getFacultyData(this.props.deptNumber)); } else { @@ -504,6 +543,7 @@ var FacultyInterface = React.createClass({ render: function() { if (this.props.departmentData == null){ + return (
) } var facultyDetail = null; @@ -514,6 +554,7 @@ var FacultyInterface = React.createClass({ //FIX DEPT NAME if(facultyData != null){ + //console.log("Made it") facultyDetail = facultyData.map(function (faculty) { if(facultyID == faculty.id) return ( var HostInterface = React.createClass({ - buildHostData: function() { - + buildHostData: function(form) { + var location = this.refs.location.grabLocationData(); + var compensation = this.refs.compensation.grabCompensationData(form); + var contract = this.refs.contract.grabContractData(); + var hostDetails = this.refs.hDetails.grabHostData(); + var superDetails = this.refs.sDetails.grabSupervisorData(); + + var hostData = {location: location, + compensation: compensation, + contract: contract, + hostDetails: hostDetails, + superDetails: superDetails}; + + return hostData; }, render: function() { var hostData = this.props.hostData; @@ -871,15 +927,18 @@ var HostInterface = React.createClass({
- + - + intern = {intern} + ref = "compensation" /> +
- + states = {this.props.states} + domestic = {intern.domestic} + ref = "hDetails" /> +
@@ -890,10 +949,27 @@ var HostInterface = React.createClass({ var Location = React.createClass({ grabLocationData: function() { + var locationData = { + loc_address: this.refs.locAddress.value, + loc_city: this.refs.locCity.value, + loc_zip: this.refs.locZip.value, + loc_start: this.refs.locStart.value, + loc_end: this.refs.locEnd.value + }; + return locationData; }, render: function() { - var intern = this.props.intern; + var hostData = this.props.hostData; + var domestic = this.props.domestic; + + if(domestic){ + var locState = "State"; + var zip = "Zip"; + } else { + var locState = "Country"; + var zip = "Postal Code"; + } return(
@@ -901,41 +977,48 @@ var Location = React.createClass({
-

{intern.international}

+

{hostData.international}

- +
-
+
-
+
- -

STATE

+ +

{hostData.loc_state}

+ {!domestic ?
+ +

{hostData.loc_province}

+
+ : null} + +
- -
+ +
-
+
-
+
@@ -946,27 +1029,53 @@ var Location = React.createClass({ var Compensation = React.createClass({ - grabCompensationData: function() { + getInitialState: function() { + return { + paid: false, + stipend: false + }; + }, + componentWillMount: function() { + var intern = this.props.intern; + if(intern.paid == true){ + this.setState({paid: true}); + } + if(intern.stipend == true){ + this.setState({stipend: true}); + } + }, + grabCompensationData: function(form) { + var sOption = "r" + this.props.hostData.id; + console.log(form.elements.r23) + var compensationData = { + paid: form.elements.sOption.checked, + //stipend: form.elements.sOption.checked, + pay_rate: this.refs.payRate.value, + avg_hours_week: this.refs.hoursPerWeek.value + }; + + return compensationData; }, render: function() { var hostData = this.props.hostData; var intern = this.props.intern; var allow = intern.stipend; var rButtons; - - if(intern.paid == 0){ +var rName = "r" + hostData.id; + if(this.state.paid == false){ rButtons =
- - + +
} else { rButtons =
- - + +
} - + var stipendBox = "stipendOption"; + //console.log(stipendBox); return(
@@ -977,8 +1086,8 @@ var Compensation = React.createClass({ {rButtons}
- { allow ? - : + { this.state.stipend ? + : }
@@ -986,12 +1095,12 @@ var Compensation = React.createClass({
-
+
-
+
From b800b8ee73cb482f6a262090e7d41fd748bf71d5 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Tue, 28 Jun 2016 11:04:33 -0400 Subject: [PATCH 24/32] Allowed internships to have multiple hosts though saving does not work. --- class/Command/EditInternshipRest.php | 33 +++++++++++++++-- .../editInternshipView/InternshipView.jsx | 36 +++++++++++-------- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 74011838..89787f4e 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -107,9 +107,11 @@ public function get() // Load the documents $docs = $intern->getDocuments(); - if($docs === null) { - $docs = array(); // if no docs, setup an empty array - } + // if($docs === null) { + // $docs = array(); // if no docs, setup an empty array + // } else { + $docs = $this->setupDocumentList($docs, $intern->getId()); + //} $expType = Internship::getTypesAssoc(); $subjects = array("-1" => "Select subject...") + Subject::getSubjects(); @@ -186,5 +188,30 @@ public function getStudentData($student, $intern) } return $data; } + + private function setupDocumentList($docs, $id) + { + $data = array(); + + // Document list + if (!is_null($docs)) { + foreach ($docs as $doc) { + $data['docs'][] = array('DOWNLOAD' => $doc->getDownloadLink('blah'), + 'DELETE' => $doc->getDeleteLink()); + } + } + + // Document upload button + $folder = new \Intern\InternFolder(\Intern\InternDocument::getFolderId()); + $data['UPLOAD_DOC'] = $folder->documentUpload($id); + + return $data; + } + + private function setupChangeHistory() + { + $historyView = new ChangeHistoryView($this->intern); + $this->tpl['CHANGE_LOG'] = $historyView->show(); + } } diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 7ba5e5b0..5af52cd2 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -1,3 +1,5 @@ +// !! internshipId is hardcoded as a global variable !! + var EditInternshipInterface = React.createClass({ getInitialState: function() { @@ -147,7 +149,7 @@ var MainInterface = React.createClass({ var stateData = this.props.stateData; var facultyData = this.props.facultyData; var departmentData = this.props.departmentData; - + var deleteURL = "index.php?module=intern&action=DeleteInternship&internship_id=" + internshipId; return(

@@ -162,7 +164,7 @@ var MainInterface = React.createClass({

@@ -1046,36 +1048,40 @@ var Compensation = React.createClass({ } }, grabCompensationData: function(form) { - var sOption = "r" + this.props.hostData.id; - console.log(form.elements.r23) + var compensationData = { - paid: form.elements.sOption.checked, - //stipend: form.elements.sOption.checked, + paid: this.state.paid, + stipend: this.state.stipend, pay_rate: this.refs.payRate.value, avg_hours_week: this.refs.hoursPerWeek.value }; return compensationData; }, + changePaid: function(e) { + this.setState({paid: e.currentTarget.value}); + }, + changeStipend: function(e) { + this.setState({stipend: e.currentTarget.checked}); + }, render: function() { var hostData = this.props.hostData; var intern = this.props.intern; var allow = intern.stipend; var rButtons; -var rName = "r" + hostData.id; + var rName = this.props.hostData.id; if(this.state.paid == false){ rButtons =
- - + +
} else { rButtons =
- - + +
} - var stipendBox = "stipendOption"; - //console.log(stipendBox); + return(
@@ -1086,8 +1092,8 @@ var rName = "r" + hostData.id; {rButtons}
- { this.state.stipend ? - : + { this.state.stipend ? + : }
From 03fa4d708c9c7b88cc70497b17234fad46b6d34b Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Tue, 28 Jun 2016 12:30:36 -0400 Subject: [PATCH 25/32] Fixed student UI errors in the form (formatting). --- class/Command/EditInternshipRest.php | 1 + javascript/editInternshipView/InternshipView.jsx | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 89787f4e..20b352e1 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -130,6 +130,7 @@ public function formatIntern($intern) } $intern->campus = $intern->getCampusFormatted(); + $intern->level = $intern->getLevelFormatted(); $intern->level = $intern->getLevelFormatted(); return $intern; diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 5af52cd2..668ccda5 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -394,12 +394,20 @@ var StudentInformation = React.createClass({
-

{student.grad_date}

+

+ {student.grad_date == null ? Not Available + : student.grad_date + } +

-

{student.enrolled_credit_hours}

+

+ {student.enrolled_credit_hours == null ? Not Available + : student.enrolled_credit_hours + } +

); From 92abe5e540b524e037bb0ba3d0806c34d799a46a Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Wed, 6 Jul 2016 11:37:29 -0400 Subject: [PATCH 26/32] Cleaned up ui bugs and made Change History and Notes functional. --- class/ChangeHistoryView.php | 25 ++++--- class/Command/EditInternshipRest.php | 10 ++- .../editInternshipView/InternshipView.jsx | 74 +++++++++++++++---- 3 files changed, 80 insertions(+), 29 deletions(-) diff --git a/class/ChangeHistoryView.php b/class/ChangeHistoryView.php index e9f4c5d4..23bb6ef1 100644 --- a/class/ChangeHistoryView.php +++ b/class/ChangeHistoryView.php @@ -15,34 +15,39 @@ public function show() { $tpl = array(); - $tpl['CHANGELOG_REPEAT'] = array(); - $changes = ChangeHistoryFactory::getChangesForInternship($this->internship); if(is_null($changes)){ return ""; } + // Needed for key value in react -> ChangeFields class + // untill something better can be thought of. + $id = 0; + foreach($changes as $change){ $changeFields = array(); + $changeFields['id'] = $id++; - $changeFields['RELATIVE_DATE'] = $change->getRelativeDate(); - $changeFields['EXACT_DATE'] = $change->getFormattedDate(); - $changeFields['USERNAME'] = $change->getUsername(); + $changeFields['relative_date'] = $change->getRelativeDate(); + $changeFields['exact_date'] = $change->getFormattedDate(); + $changeFields['username'] = $change->getUsername(); if($change->getFromStateFriendlyname() != $change->getToStateFriendlyName()){ - $changeFields['FROM_STATE'] = $change->getFromStateFriendlyName(); - $changeFields['TO_STATE'] = $change->getToStateFriendlyName(); + $changeFields['from_state'] = $change->getFromStateFriendlyName(); + $changeFields['to_state'] = $change->getToStateFriendlyName(); } $note = $change->getNote(); if(!is_null($note)){ - $changeFields['NOTE'] = $note; + $changeFields['note'] = $note; + } else { + $changeFields['note'] = ''; } - $tpl['changelog_repeat'][] = $changeFields; + $tpl[] = $changeFields; } - return \PHPWS_Template::process($tpl, 'intern', 'changeHistory.tpl'); + return $tpl; } } diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 20b352e1..67706026 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -113,10 +113,12 @@ public function get() $docs = $this->setupDocumentList($docs, $intern->getId()); //} + $notes = $this->setupChangeHistory($intern); + $expType = Internship::getTypesAssoc(); $subjects = array("-1" => "Select subject...") + Subject::getSubjects(); - $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agencies, "docs" => $docs, "experience_type" => $expType, "subjects" => $subjects); + $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agencies, "docs" => $docs, "notes" => $notes, "experience_type" => $expType, "subjects" => $subjects); return $content; } @@ -209,10 +211,10 @@ private function setupDocumentList($docs, $id) return $data; } - private function setupChangeHistory() + private function setupChangeHistory($intern) { - $historyView = new ChangeHistoryView($this->intern); - $this->tpl['CHANGE_LOG'] = $historyView->show(); + $historyView = new \Intern\ChangeHistoryView($intern); + return $historyView->show(); } } diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 668ccda5..0423abdb 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -241,7 +241,7 @@ var MainInterface = React.createClass({
- +
); @@ -395,7 +395,7 @@ var StudentInformation = React.createClass({

- {student.grad_date == null ? Not Available + {student.grad_date == null ? Not Available : student.grad_date }

@@ -404,7 +404,7 @@ var StudentInformation = React.createClass({

- {student.enrolled_credit_hours == null ? Not Available + {student.enrolled_credit_hours == null ? Not Available : student.enrolled_credit_hours }

@@ -561,7 +561,7 @@ var FacultyInterface = React.createClass({ var facultyID = (this.state.facultyID != null) ? this.state.facultyID :this.props.facultyID; var dept = this.props.departmentData; var deptNum = this.props.deptNumber; - +console.log(deptNum); //FIX DEPT NAME if(facultyData != null){ //console.log("Made it") @@ -655,7 +655,7 @@ var FacultyDetail = React.createClass({ this.props.hideDetailInfo(); }, render: function() { - var name = this.props.fname + " " + this.props.lname + " - " + this.props.dept; + var name = this.props.fname + " " + this.props.lname + " - " + this.props.deptname; // Format Faculty Email @@ -779,12 +779,12 @@ var CourseAndTerm = React.createClass({
-
+
-
+
@@ -877,14 +877,28 @@ var NoteBox = React.createClass({ }, render: function() { return( +
-
- NOTES -
-
- -
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ ); } }); @@ -894,14 +908,44 @@ var ChangeLog = React.createClass({ return(
-
CHANGE_LOG
+

Change History

+ {this.props.noteData.map(function (notes) { + return ( + + ); + }.bind(this))}
); } }); - +var ChangeFields = React.createClass({ + render: function() { + return( +
+
+

+ {this.props.exactDate}Changed {this.props.relativeData} ago by {this.props.username} +

+ {this.props.fromState != undefined ? +
    +
  • Status changed from {this.props.fromState} to {this.props.toState} +
  • +
+ : null} +
{this.props.note}
+
+
+ ); + } +}); From 5a39b37c927f59d5e76a35e4dbc5b19cef889423 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Wed, 6 Jul 2016 12:22:27 -0400 Subject: [PATCH 27/32] Fixed rebasing issues and bugs. --- class/ChangeHistoryView.php | 2 +- class/Command/EditInternshipRest.php | 5 +++-- class/Department.php | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/class/ChangeHistoryView.php b/class/ChangeHistoryView.php index 23bb6ef1..48a66730 100644 --- a/class/ChangeHistoryView.php +++ b/class/ChangeHistoryView.php @@ -50,4 +50,4 @@ public function show() return $tpl; } -} +} \ No newline at end of file diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 67706026..6256210b 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -6,7 +6,7 @@ use \Intern\AgencyFactory; use \Intern\InternshipAgencyFactory; use \Intern\InternshipView; -use \Intern\StudentProviderFactory; +use \Intern\StudentFactory; use \Intern\Internship; use \Intern\Subject; @@ -60,7 +60,8 @@ public function get() // Load a fresh copy of the student data from the web service try { - $student = StudentProviderFactory::getProvider()->getStudent($intern->getBannerId(), $intern->getTerm()); + $student = StudentFactory::getStudent($intern->getBannerId(), $intern->getTerm()); + } catch(\Intern\Exception\StudentNotFoundException $e) { $studentId = $intern->getBannerId(); $student = null; diff --git a/class/Department.php b/class/Department.php index 2db5bbd6..ce6231e9 100644 --- a/class/Department.php +++ b/class/Department.php @@ -33,7 +33,8 @@ public function getCSV() public function getId(){ return $this->id; - + } + /** * @Override Editable::getEditAction */ From ebfaa0ed42c8a14f299b43bbfa43f375748fc5c1 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Fri, 8 Jul 2016 09:31:33 -0400 Subject: [PATCH 28/32] Fixed type definitions using a modal and started contract component. --- class/Command/EditInternshipRest.php | 6 +- class/InternFolder.php | 7 ++- .../editInternshipView/InternshipView.jsx | 61 +++++++++++++++++-- 3 files changed, 65 insertions(+), 9 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 184e2344..3c13c610 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -113,7 +113,7 @@ public function get() // if($docs === null) { // $docs = array(); // if no docs, setup an empty array // } else { - $docs = $this->setupDocumentList($docs, $intern->getId()); + $doc = $this->setupDocumentList($docs, $intern->getId()); //} $notes = $this->setupChangeHistory($intern); @@ -121,7 +121,7 @@ public function get() $expType = Internship::getTypesAssoc(); $subjects = array("-1" => "Select subject...") + Subject::getSubjects(); - $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agencies, "docs" => $docs, "notes" => $notes, "experience_type" => $expType, "subjects" => $subjects); + $content = array("intern" => $intern, "student" => $studentData, "wfState" => $wfState, "agency" => $agencies, "docs" => $doc, "notes" => $notes, "experience_type" => $expType, "subjects" => $subjects); return $content; } @@ -209,7 +209,7 @@ private function setupDocumentList($docs, $id) // Document upload button $folder = new \Intern\InternFolder(\Intern\InternDocument::getFolderId()); - $data['UPLOAD_DOC'] = $folder->documentUpload($id); + $data = $folder->documentUpload($id); return $data; } diff --git a/class/InternFolder.php b/class/InternFolder.php index 4588c32e..d495ddcf 100644 --- a/class/InternFolder.php +++ b/class/InternFolder.php @@ -34,7 +34,10 @@ public function documentUpload($internshipId) $label = dgettext('filecabinet', 'Add document'); - javascript('open_window'); - return ''; + + return array('label'=> $label, 'address'=> $link->getAddress()); + + // javascript('open_window'); + // return ''; } } diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 0423abdb..4178208e 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -223,6 +223,7 @@ var MainInterface = React.createClass({ ); @@ -835,6 +836,15 @@ var CourseAndTerm = React.createClass({ var TypeInterface = React.createClass({ + getInitialState: function() { + return {showModal: false}; + }, + closeModal: function() { + this.setState({ showModal: false }); + }, + openModal: function() { + this.setState({ showModal: true }); + }, grabTypeData: function(form) { var type = { type: form.elements.typeOption.value} @@ -861,7 +871,8 @@ var TypeInterface = React.createClass({ })}
@@ -870,6 +881,39 @@ var TypeInterface = React.createClass({ } }); +var TypeModalForm = React.createClass({ + render: function() { + return ( + + +

Internship Type Definitions

+
+ +
+
+
+

Student Teaching

+

A course requiring students to instruct or teach at an entity external to the institution, generally as part of the culminating curriculum of a teacher education or certificate program.

+ +

Practicum

+

A course requiring students to participate in an approved project or proposal that practically applies previously studied theory of the field or discipline under the supervision of an expert or qualified representative of the field or discipline.

+ +

Clinical

+

A course requiring medical- or healthcare-focused experiential work where students test, observe, experiment, or practice a field or discipline in a hands-on or simulated environment.

+ +

Internship

+

A course requiring students to participate in a partnership, professional employment, work experience or cooperative education with any entity external to the institution, generally under the supervision of an employee of the external entity.

+
+
+
+
+ + Close + +
+ ); + } +}); var NoteBox = React.createClass({ grabNoteData: function() { @@ -893,7 +937,7 @@ var NoteBox = React.createClass({
- +
@@ -973,6 +1017,7 @@ var HostInterface = React.createClass({ render: function() { var hostData = this.props.hostData; var intern = this.props.intern; + var docs = this.props.docs; return(
@@ -985,7 +1030,7 @@ var HostInterface = React.createClass({ - +
{this.props.title}
+ {change != undefined ?
  • DOWNLOAD  DELETE
+ : null + } +
+
+
-
UPLOAD_DOC
+ +
From bb30bdc7ce865900431ed2305bf01df98b5f251b Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Tue, 16 Aug 2016 11:34:09 -0400 Subject: [PATCH 29/32] Saves a package of data to be used for saving. Still working on react-dropzone. --- class/Command/EditInternshipRest.php | 6 + class/Internship.php | 2 + .../editInternshipView/InternshipView.jsx | 118 ++++++++++++++---- package.json | 3 +- templates/editInternshipView.tpl | 2 + 5 files changed, 107 insertions(+), 24 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 3c13c610..5f2a88ad 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -34,7 +34,13 @@ public function execute() public function post() { + $req = \Server::getCurrentRequest(); + $postarray = json_decode($req->getRawData(), true); + echo("
");
+        var_dump($postarray);
+        echo("
"); + exit; } public function delete() diff --git a/class/Internship.php b/class/Internship.php index 24785258..e39291f2 100644 --- a/class/Internship.php +++ b/class/Internship.php @@ -515,6 +515,8 @@ public function getFullName() public function getStartDate($formatted=false) { if (!$this->start_date) { + var_dump("made it"); + exit; return null; } if ($formatted) { diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 4178208e..9f1a6c28 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -1,6 +1,5 @@ // !! internshipId is hardcoded as a global variable !! - var EditInternshipInterface = React.createClass({ getInitialState: function() { return { @@ -23,17 +22,37 @@ var EditInternshipInterface = React.createClass({ this.setState({submitted: true}, function(){ // After disabling submit buttons, use callback to validate the data - if(!false){ + if(!true){ // If the data doesn't validate, wait a second before re-enabling the submit button // This makes sure the user sees the "Creating..." spinner, instead of it re-rendering // so fast that they don't think it did anything setTimeout(function(){ thisComponent.setState({submitted: false}); - thisComponent.refs.mainInterface.buildInternshipData(form); + // thisComponent.refs.mainInterface.buildInternshipData(form); }, 1000); return; } + + setTimeout(function(){ + thisComponent.setState({submitted: false}); + var data = thisComponent.refs.mainInterface.buildInternshipData(form); + console.log(data); + $.ajax({ + url: 'index.php?module=intern&action=editInternshipRest&internshipId='+internshipId, + type: 'POST', + processData: false, + dataType: 'json', + data: JSON.stringify(data), + success: function() { + console.log("success!"); + }.bind(this), + error: function(xhr, status, err) { + alert("Failed to save intern data.") + console.error(this.props.url, status, err.toString()); + }.bind(this) + }); + }, 1000); }); }, getInternData: function(){ @@ -132,15 +151,16 @@ var MainInterface = React.createClass({ var type = this.refs.type.grabTypeData(form); var host = this.refs.host.buildHostData(form); - console.log(host); - var internship = {student: student, status: status, faculty: faculty, term: term, type: type}; - console.log(internship); + + var internData = {internship: internship, + host: host}; + return internData; //Host Information //var status = this.refs.student.grabStudentData(); }, @@ -239,6 +259,7 @@ var MainInterface = React.createClass({
+
@@ -991,7 +1012,21 @@ var ChangeFields = React.createClass({ } }); +var DropzoneDemo = React.createClass({ + onDrop: function (files) { + console.log('Received files: ', files); + }, + render: function () { + return ( +
+ +
Try dropping some files here, or click to select files to upload.
+
+
+ ); + } +}); @@ -1037,7 +1072,10 @@ var HostInterface = React.createClass({ states = {this.props.states} domestic = {intern.domestic} ref = "hDetails" /> - +
@@ -1245,7 +1283,16 @@ var Contracts = React.createClass({ var HostDetails = React.createClass({ grabHostData: function() { + var hostData = { + name: this.refs.name.value, + phone: this.refs.phone.value, + address: this.refs.address.value, + city: this.refs.city.value, + state: this.refs.state.value, + zip: this.refs.zip.value + } + return hostData; }, render: function() { var hostData = this.props.hostData; @@ -1267,33 +1314,33 @@ var HostDetails = React.createClass({ Host Details
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1303,37 +1350,62 @@ var HostDetails = React.createClass({ var SupervisorInfo = React.createClass({ grabSupervisorData: function() { + var superData = { + fname: this.refs.fname.value, + lname: this.refs.lname.value, + title: this.refs.title.value, + email: this.refs.email.value, + fax: this.refs.fax.value, + phone: this.refs.phone.value, + address: this.refs.address.value, + city: this.refs.city.value, + state: this.refs.state.value, + zip: this.refs.zip.value + } + return superData; }, render: function() { var hostData = this.props.hostData; + var stateData = ''; + + if(this.props.states != null){ + stateData = this.props.states.map(function (state) { + return ( + + ); + }.bind(this)); + } return(
Supervisor Information
-
+
-
+
-
+
-
+
-
+
@@ -1342,28 +1414,28 @@ var SupervisorInfo = React.createClass({
-
+
-
+
-
+
-
+
-
+
diff --git a/package.json b/package.json index f71742da..ae2c0aec 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "bower": "^1.4.2", "classnames": "~2.2.0", "react": "~0.14.0", - "react-dom": "~0.14.0" + "react-dom": "~0.14.0", + "react-dropzone": "~3.5.3" }, "devDependencies": { "grunt": "~0.4.5", diff --git a/templates/editInternshipView.tpl b/templates/editInternshipView.tpl index c389e587..4b3dd256 100644 --- a/templates/editInternshipView.tpl +++ b/templates/editInternshipView.tpl @@ -17,6 +17,8 @@ var internshipId = {INTERN_ID}; + + From ca3a333b1be7acde08365539341ee9e5d3837d27 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Fri, 7 Oct 2016 14:38:23 -0400 Subject: [PATCH 30/32] Added missing fields to aid in saving. --- class/Command/EditInternshipRest.php | 335 +++++++++++++++++- .../editInternshipView/InternshipView.jsx | 6 +- 2 files changed, 338 insertions(+), 3 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index 5f2a88ad..a65e9772 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -37,10 +37,343 @@ public function post() $req = \Server::getCurrentRequest(); $postarray = json_decode($req->getRawData(), true); + + // id, internId, agencyId, loc_start, loc_end, loc_address, loc_city, loc_zip, loc_province, loc_country +echo("
");
+var_dump($postarray);
+echo("
"); +exit; + $studentPost = $postarray["internship"]["student"]; + $faculty = $postarray['internship']['faculty']; + $status = $postarray['internship']['status']; + $term = $postarray['internship']['term']; + $type = $postarray['internship']['type']; + + \PHPWS_DB::begin(); + + /******************************** + * Load the existing internship * + */ + try { + $i = \Intern\InternshipFactory::getInternshipById($studentPost['id']); + } catch (\Exception $e) { + // Rollback and re-throw the exception so that admins gets an email + \PHPWS_DB::rollback(); + throw $e; + } + +/* + // Check that the form token matched before we save anything + if($i->form_token == $_REQUEST['form_token']) { + // Generate a new form token + $i->form_token = uniqid(); + } else { + // Form token doesn't match, so show a nice error message + $this->rerouteWithError('index.php?module=intern&action=ShowInternship', 'Some else has modified this internship while you were working. In order to not overwrite their changes, your changes were not saved.'); + } +*/ + + + // Load the student object + try { + $student = ExternalDataProviderFactory::getProvider()->getStudent($i->getBannerId(), $i->getTerm()); + } catch (StudentNotFoundException $e){ + $student = null; + + $this->rerouteWithError('index.php?module=intern&action=ShowInternship', "We couldn't find a matching student in Banner. Your changes were saved, but this student probably needs to contact the Registrar's Office to re-enroll."); + \NQ::close(); + } + + // Student Information Field + $i->first_name = $_REQUEST['student_first_name']; + $i->middle_name = $_REQUEST['student_middle_name']; + $i->last_name = $_REQUEST['student_last_name']; + + $i->setFirstNameMetaphone($_REQUEST['student_first_name']); + $i->setMiddleNameMetaphone($_REQUEST['student_middle_name']); + $i->setLastNameMetaphone($_REQUEST['student_last_name']); + + $i->phone = $_REQUEST['student_phone']; + $i->email = $_REQUEST['student_email']; + + $i->student_address = $_REQUEST['student_address']; + $i->student_city = $_REQUEST['student_city']; + if($_REQUEST['student_state'] != '-1'){ + $i->student_state = $_REQUEST['student_state']; + }else{ + $i->student_state = ""; + } + $i->student_zip = $_REQUEST['student_zip']; + + // Student major handling, if more than one major + // Make sure we have a student object, since it could be null if the Banner lookup failed + if(isset($student) && $student != null) { + $majors = $student->getMajors(); + } else { + $majors = array(); + } + + if(sizeof($majors) > 1) { + + if(!isset($_POST['major_code'])){ + // Student has multiple majors, but user didn't choose one, so just take the first one + $i->major_code = $majors[0]->getCode(); + $i->major_description = $majors[0]->getDescription(); + }else{ + // User choose a major, so loop over the set of majors until we find the matching major code + $code = $_POST['major_code']; + foreach($majors as $m){ + if($m->getCode() == $code){ + $major = $m; + break; + } + } + + $i->major_code = $major->getCode(); + $i->major_description = $major->getDescription(); + } + } else if(sizeof($majors) == 1){ + // Student has exactly one major + $i->major_code = $majors[0]->getCode(); + $i->major_description = $majors[0]->getDescription(); + + } + + + /************************ + * Faculty Advisor Field * + *************************/ + $i->faculty_id = $faculty['faculty_id'] > 0 ? $faculty['faculty_id'] : null; + $i->department_id = $studentPost['department']; + + // Term & Course Information Field + // TERM START AND END DATE + $i->start_date = !empty($term['termStart']) ? strtotime($term['termStart']) : 0; + $i->end_date = !empty($term['termEnd']) ? strtotime($term['termEnd']) : 0; + + // Course info + $i->course_no = !isset($_POST['course_no']) ? null : strip_tags($_POST['course_no']); + $i->course_sect = !isset($_POST['course_sect']) ? null : strip_tags($_POST['course_sect']); + $i->course_title = !isset($_POST['course_title']) ? null : strip_tags($_POST['course_title']); + +//Ensure this is the correct creditHours field.. + $i->credits = (int) $term['creditHours']; + + // Compensation Field + $avg_hours_week = (int) $_REQUEST['avg_hours_week']; + $i->avg_hours_week = $avg_hours_week ? $avg_hours_week : null; + $i->paid = $_REQUEST['payment'] == 'paid'; + $i->stipend = isset($_REQUEST['stipend']) && $i->paid; + $i->pay_rate = $_REQUEST['pay_rate']; + + if (\Current_User::isDeity()) { + $i->term = $_REQUEST['term']; + } + + // Internship experience type + if(isset($_REQUEST['experience_type'])){ + $i->setExperienceType($_REQUEST['experience_type']); + } + + if($i->isInternational()){ + // Set province + $i->loc_province = $_POST['loc_province']; + } + + // Address, city, zip are always set (no matter domestic or international) + $i->loc_address = strip_tags($_POST['loc_address']); + $i->loc_city = strip_tags($_POST['loc_city']); + $i->loc_zip = strip_tags($_POST['loc_zip']); + + if(isset($_POST['course_subj']) && $_POST['course_subj'] != '-1'){ + $i->course_subj = strip_tags($_POST['course_subj']); + }else{ + $i->course_subj = null; + } + + + // Corequisite Course Info +/* UNSURE ABOUT THIS BLOCK + if (isset($_POST['corequisite_course_num'])) { + $i->corequisite_number = $_POST['corequisite_course_num']; + } + + if (isset($_POST['corequisite_course_sect'])) { + $i->corequisite_section = $_POST['corequisite_course_sect']; + } +*/ + + + + /************ + * OIED Certification + */ + // Check if this has changed from non-certified->certified so we can log it later + if($i->oied_certified == 0 && $_POST['oied_certified_hidden'] == 'true'){ + // note the change for later + $oiedCertified = true; + }else{ + $oiedCertified = false; + } + + if($_POST['oied_certified_hidden'] == 'true'){ + $i->oied_certified = 1; + }else if($_POST['oied_certified_hidden'] == 'false'){ + $i->oied_certified = 0; + }else{ + $i->oied_certified = 0; + } + + /************ + * Background and Drug checks + */ + // Check if this has changed from no to yes for sending email + if($i->background_check == 0 && $_REQUEST['background_code'] == '1'){ + // note the change for later + $backgroundCheck = true; + }else{ + $backgroundCheck = false; + } + + if($_REQUEST['background_code'] == '1'){ + $i->background_check = 1; + }else if($_REQUEST['background_code'] == '0'){ + $i->background_check = 0; + } + + if($i->drug_check == 0 && $_REQUEST['drug_code'] == '1'){ + // note the change for later + $drugCheck = true; + }else{ + $drugCheck = false; + } + + if($_REQUEST['drug_code'] == '1'){ + $i->drug_check = 1; + }else if($_REQUEST['drug_code'] == '0'){ + $i->drug_check = 0; + } + + // If we don't have a state and this is a new internship, + // the set an initial state + if($i->id == 0 && is_null($i->state)){ + $state = WorkflowStateFactory::getState('CreationState'); + $i->setState($state); // Set this initial value + } + + try { + $i->save(); + } catch (\Exception $e) { + // Rollback and re-throw the exception so that admins gets an email + \PHPWS_DB::rollback(); + throw $e; + } + + // Update agency + try { + $agency = AgencyFactory::getAgencyById($_REQUEST['agency_id']); + } catch (\Exception $e) { + // Rollback and re-throw the exception so that admins gets an email + \PHPWS_DB::rollback(); + throw $e; + } + + // Agency Info + $agency->name = $_REQUEST['agency_name']; + $agency->address = $_REQUEST['agency_address']; + $agency->city = $_REQUEST['agency_city']; + $agency->zip = $_REQUEST['agency_zip']; + $agency->phone = $_REQUEST['agency_phone']; + + if($i->isDomestic()){ + $agency->state = $_REQUEST['agency_state'] == '-1' ? null : $_REQUEST['agency_state']; + } else { + $agency->province = $_REQUEST['agency_province']; + $agency->country = $_REQUEST['agency_country']== '-1' ? null : $_REQUEST['agency_country']; + } + + // Agency Supervisor Info + $agency->supervisor_first_name = $_REQUEST['agency_sup_first_name']; + $agency->supervisor_last_name = $_REQUEST['agency_sup_last_name']; + $agency->supervisor_title = $_REQUEST['agency_sup_title']; + $agency->supervisor_phone = $_REQUEST['agency_sup_phone']; + $agency->supervisor_email = $_REQUEST['agency_sup_email']; + $agency->supervisor_fax = $_REQUEST['agency_sup_fax']; + $agency->supervisor_address = $_REQUEST['agency_sup_address']; + $agency->supervisor_city = $_REQUEST['agency_sup_city']; + $agency->supervisor_zip = $_REQUEST['agency_sup_zip']; + if($i->isDomestic()){ + $agency->supervisor_state = $_REQUEST['agency_sup_state']; + } else { + $agency->supervisor_province = $_REQUEST['agency_sup_province']; + $agency->supervisor_country = $_REQUEST['agency_sup_country'] == '-1' ? null : $_REQUEST['agency_sup_country']; + } + $agency->address_same_flag = isset($_REQUEST['copy_address']) ? 't' : 'f'; + + try { + DatabaseStorage::save($agency); + } catch (\Exception $e) { + // Rollback and re-throw the exception so that admins gets an email + \PHPWS_DB::rollback(); + throw $e; + } + + /*************************** + * State/Workflow Handling * + ***************************/ + $t = \Intern\WorkflowTransitionFactory::getTransitionByName($_POST['workflow_action']); + $workflow = new \Intern\WorkflowController($i, $t); + try { + $workflow->doTransition(isset($_POST['notes'])?$_POST['notes']:null); + } catch (\Intern\Exception\MissingDataException $e) { + \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, $e->getMessage()); + \NQ::close(); + return \PHPWS_Core::reroute('index.php?module=intern&action=ShowInternship&internship_id=' . $i->id); + } + + // Create a ChangeHisotry for the OIED certification. + if($oiedCertified){ + $currState = WorkflowStateFactory::getState($i->getStateName()); + $ch = new ChangeHistory($i, \Current_User::getUserObj(), time(), $currState, $currState, 'Certified by OIED'); + $ch->save(); + + // Notify the faculty member that OIED has certified the internship + if ($i->getFaculty() != null) { + \Intern\Email::sendOIEDCertifiedNotice($i, $agency); + } + } + + // If the background check or drug check status changed to true (computed earlier), then send a notification + if($backgroundCheck || $drugCheck) { + \Intern\Email::sendBackgroundCheckEmail($i, $agency, $backgroundCheck, $drugCheck); + } + + \PHPWS_DB::commit(); + + $workflow->doNotification(isset($_POST['notes'])?$_POST['notes']:null); + + //var_dump($_POST['generateContract']);exit; + + // If the user clicked the 'Generate Contract' button, then redirect to the PDF view + if(isset($_POST['generateContract']) && $_POST['generateContract'] == 'true'){ + //return \PHPWS_Core::reroute('index.php?module=intern&action=pdf&internship_id=' . $i->id); + echo json_encode($i); + exit; + } else { + // Otherwise, redirect to the internship edit view + + // Show message if user edited internship + \NQ::simple('intern', \Intern\UI\NotifyUI::SUCCESS, 'Saved internship for ' . $i->getFullName()); + \NQ::close(); + + return \PHPWS_Core::reroute('index.php?module=intern&action=ShowInternship&internship_id=' . $i->id); + } + + echo("
");
         var_dump($postarray);
         echo("
"); - exit; + exit; } public function delete() diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 9f1a6c28..55780caa 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -287,7 +287,8 @@ var SaveInternshipButton = React.createClass({ var StudentInformation = React.createClass({ grabStudentData: function() { - var student = { fname: this.refs.fname.value, + var student = { id: this.props.intern.banner, + fname: this.refs.fname.value, lname: this.refs.lname.value, mname: this.refs.mname.value, email: this.refs.email.value, @@ -295,7 +296,8 @@ var StudentInformation = React.createClass({ city: this.refs.city.value, state: this.refs.state.value, zip: this.refs.zip.value, - phone: this.refs.phone.value,} + phone: this.refs.phone.value, + department: this.props.intern.department_id} return student; }, From 21d1d40a2cf8a9281ebbf621ec56c453f44dfd74 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Thu, 26 Jan 2017 09:59:07 -0500 Subject: [PATCH 31/32] Fixed internship view to use webpack. --- class/Command/EditInternshipRest.php | 23 +- class/Command/ShowInternship.php | 29 +- .../editInternshipView/InternshipView.jsx | 253 ++++++++++-------- .../emergencyContact/EmgContactList.jsx | 10 +- templates/editInternshipView.tpl | 24 +- webpack.config.dev.js | 3 +- webpack.config.prod.js | 3 +- 7 files changed, 179 insertions(+), 166 deletions(-) diff --git a/class/Command/EditInternshipRest.php b/class/Command/EditInternshipRest.php index a65e9772..0df40d06 100644 --- a/class/Command/EditInternshipRest.php +++ b/class/Command/EditInternshipRest.php @@ -39,10 +39,10 @@ public function post() // id, internId, agencyId, loc_start, loc_end, loc_address, loc_city, loc_zip, loc_province, loc_country -echo("
");
-var_dump($postarray);
-echo("
"); -exit; +// echo("
");
+// var_dump($postarray);
+// echo("
"); +// exit; $studentPost = $postarray["internship"]["student"]; $faculty = $postarray['internship']['faculty']; $status = $postarray['internship']['status']; @@ -145,7 +145,7 @@ public function post() *************************/ $i->faculty_id = $faculty['faculty_id'] > 0 ? $faculty['faculty_id'] : null; $i->department_id = $studentPost['department']; - + // Term & Course Information Field // TERM START AND END DATE $i->start_date = !empty($term['termStart']) ? strtotime($term['termStart']) : 0; @@ -156,7 +156,7 @@ public function post() $i->course_sect = !isset($_POST['course_sect']) ? null : strip_tags($_POST['course_sect']); $i->course_title = !isset($_POST['course_title']) ? null : strip_tags($_POST['course_title']); -//Ensure this is the correct creditHours field.. +//Ensure this is the correct creditHours field.. $i->credits = (int) $term['creditHours']; // Compensation Field @@ -373,7 +373,7 @@ public function post() echo("
");
         var_dump($postarray);
         echo("
"); - exit; + exit; } public function delete() @@ -401,14 +401,14 @@ public function get() try { $student = StudentFactory::getStudent($intern->getBannerId(), $intern->getTerm()); - + } catch(\Intern\Exception\StudentNotFoundException $e) { $studentId = $intern->getBannerId(); $student = null; \NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, "We couldn't find a student with an ID of {$studentId} in Banner. This probably means this person is not an active student."); } - + // Format intern data $intern = $this->formatIntern($intern); @@ -435,7 +435,7 @@ public function get() $wfState = $workflow; $agencies = InternshipAgencyFactory::getHostInfoById($intern->getId()); - + // foreach($agencies as $a){ // // Load the agency // var_dump(AgencyFactory::getAgencyById($a['agency_id'])); @@ -456,7 +456,7 @@ public function get() //} $notes = $this->setupChangeHistory($intern); - + $expType = Internship::getTypesAssoc(); $subjects = array("-1" => "Select subject...") + Subject::getSubjects(); @@ -559,4 +559,3 @@ private function setupChangeHistory($intern) return $historyView->show(); } } - diff --git a/class/Command/ShowInternship.php b/class/Command/ShowInternship.php index 4709ffe5..db596ed7 100644 --- a/class/Command/ShowInternship.php +++ b/class/Command/ShowInternship.php @@ -32,19 +32,38 @@ public function execute() \PHPWS_Core::reroute('index.php'); } - + // Load the Internship + try{ + $intern = InternshipFactory::getInternshipById($_REQUEST['internship_id']); + }catch(\Intern\Exception\InternshipNotFoundException $e){ + \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); + return; + } + if($intern === false) { + \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'Could not locate an internship with the given ID.'); + //TODO redirect to the search interface + return; + } + // Load a fresh copy of the student data from the web service + try { + $student = ExternalDataProviderFactory::getProvider()->getStudent($intern->getBannerId(), $intern->getTerm()); + } catch(\Intern\Exception\StudentNotFoundException $e) { + $studentId = $intern->getBannerId(); + $student = null; + \NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, "We couldn't find a student with an ID of {$studentId} in Banner. This probably means this person is not an active student."); + } $tpl = array(); - //javascriptMod('intern', 'editInternshipView'); - - javascript('jquery'); + + $tpl['vendor_bundle'] = \Intern\AssetResolver::resolveJsPath('assets.json', 'vendor'); + $tpl['entry_bundle'] = \Intern\AssetResolver::resolveJsPath('assets.json', 'internshipView'); $tpl['INTERN_ID'] = $_REQUEST['internship_id']; return \PHPWS_Template::process($tpl, 'intern', 'editInternshipView.tpl'); /* - + // Load the term info for this internship $termProvider = TermProviderFactory::getProvider(); diff --git a/javascript/editInternshipView/InternshipView.jsx b/javascript/editInternshipView/InternshipView.jsx index 55780caa..8cadf637 100644 --- a/javascript/editInternshipView/InternshipView.jsx +++ b/javascript/editInternshipView/InternshipView.jsx @@ -1,4 +1,15 @@ -// !! internshipId is hardcoded as a global variable !! +//Needed to turn off spacing rule for the file +/* eslint react/jsx-equals-spacing: 0 */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import $ from 'jquery'; +import {Button, Modal} from 'react-bootstrap'; +import classNames from 'classnames'; +import EmergencyContactList from '../emergencyContact/EmgContactList.jsx'; + +// this.props.internshipId is an internshipId taken from the phpfile. +// Used to save the internship. var EditInternshipInterface = React.createClass({ getInitialState: function() { @@ -39,14 +50,14 @@ var EditInternshipInterface = React.createClass({ var data = thisComponent.refs.mainInterface.buildInternshipData(form); console.log(data); $.ajax({ - url: 'index.php?module=intern&action=editInternshipRest&internshipId='+internshipId, + url: 'index.php?module=intern&action=editInternshipRest&internshipId=' + this.props.internshipId, type: 'POST', processData: false, dataType: 'json', data: JSON.stringify(data), success: function() { console.log("success!"); - }.bind(this), + }, error: function(xhr, status, err) { alert("Failed to save intern data.") console.error(this.props.url, status, err.toString()); @@ -58,7 +69,7 @@ var EditInternshipInterface = React.createClass({ getInternData: function(){ // Grabs the internship data $.ajax({ - url: 'index.php?module=intern&action=editInternshipRest&internshipId='+internshipId, + url: 'index.php?module=intern&action=editInternshipRest&internshipId=' + this.props.internshipId, type: 'GET', dataType: 'json', success: function(data) { @@ -94,7 +105,7 @@ var EditInternshipInterface = React.createClass({ type: 'GET', dataType: 'json', success: function(data) { - if(data != '') + if(data !== '') { data.unshift({first_name: "None", last_name: "", id: "-1"}); this.setState({facultyData: data}); @@ -125,14 +136,15 @@ var EditInternshipInterface = React.createClass({ }, render: function() { if(this.state.internData != null){ - return + return }else{ return(

Loading Internship... @@ -169,7 +181,10 @@ var MainInterface = React.createClass({ var stateData = this.props.stateData; var facultyData = this.props.facultyData; var departmentData = this.props.departmentData; - var deleteURL = "index.php?module=intern&action=DeleteInternship&internship_id=" + internshipId; + + console.log(internData.agency); + + //var deleteURL = "index.php?module=intern&action=DeleteInternship&internship_id=" + internshipId; return(

@@ -184,7 +199,7 @@ var MainInterface = React.createClass({

@@ -192,14 +207,14 @@ var MainInterface = React.createClass({
- +
- +
@@ -207,7 +222,7 @@ var MainInterface = React.createClass({ intern = {internData.intern} ref = "status" /> -
- +
@@ -248,7 +263,7 @@ var MainInterface = React.createClass({ ref = "host" /> ); })} - +
@@ -288,7 +303,7 @@ var StudentInformation = React.createClass({ grabStudentData: function() { var student = { id: this.props.intern.banner, - fname: this.refs.fname.value, + fname: this.refs.fname.value, lname: this.refs.lname.value, mname: this.refs.mname.value, email: this.refs.email.value, @@ -315,9 +330,9 @@ var StudentInformation = React.createClass({ active={state.active} stuState={intern.student_state} /> ); - }.bind(this)); + }); } - + return (
Student @@ -401,7 +416,7 @@ var StudentInformation = React.createClass({
- + {student.majors_repeat.map(function (major) { return ( ); })} - +
@@ -440,7 +455,7 @@ var StudentInformation = React.createClass({ var StateDropDown = React.createClass({ render: function() { - if (this.props.active == 1 && this.props.stuState == this.props.sAbbr){ + if (this.props.active === 1 && this.props.stuState === this.props.sAbbr){ return }else { return @@ -450,7 +465,7 @@ var StateDropDown = React.createClass({ var MajorSelector = React.createClass({ render: function() { - var setActive = (this.props.active == 'active') ? true : false; + var setActive = (this.props.active === 'active') ? true : false; var activeButton = classNames({ 'btn' : true, @@ -458,16 +473,17 @@ var MajorSelector = React.createClass({ 'active' : setActive }); - if (this.props.checked == 'checked'){ - var majorSelect = + var majorSelect = null; + if (this.props.checked === 'checked'){ + majorSelect = }else{ - var majorSelect = + majorSelect = } - return ( + return ( majorSelect ); } @@ -476,22 +492,22 @@ var MajorSelector = React.createClass({ var EmgContactList = React.createClass({ render: function() { - return ( + return (
Emergency Contacts
- +
-
+ ); } }); var InternStatus = React.createClass({ grabStatusData: function(form) { - var status = { status: form.elements.workflowOption.value, + var status = { status: form.elements.workflowOption.value, oied: form.elements.oiedCert.checked} return status; @@ -505,7 +521,7 @@ var InternStatus = React.createClass({ NOT DONE!!! * ****************/ - return ( + return (
Status

@@ -518,7 +534,7 @@ var InternStatus = React.createClass({

{Object.keys(workflowAction).map(function(key) { - if(key == "Intern\\WorkflowTransition\\LeaveTransition"){ + if(key === "Intern\\WorkflowTransition\\LeaveTransition"){ return(
) @@ -528,7 +544,7 @@ var InternStatus = React.createClass({
) } })} - +
@@ -590,16 +606,16 @@ console.log(deptNum); if(facultyData != null){ //console.log("Made it") facultyDetail = facultyData.map(function (faculty) { - if(facultyID == faculty.id) - return ( Faculty Advisor - {(this.state.showDetails) ? facultyDetail - : + ddFaculty = } else { - var ddFaculty = {Object.keys(facultyData).map(function(key) { return ; })} @@ -656,8 +673,8 @@ var FacultyDropDown = React.createClass({
- + {Object.keys(departments).map(function(key) { return ; })} @@ -685,7 +702,7 @@ var FacultyDetail = React.createClass({ // Format Faculty Email var emailInfo = "mailto:" + this.props.username + "@appstate.edu"; var email = {this.props.username + "@appstate.edu"} - + // Format Faculty Phone var phone = ''; if(this.props.phone !== ''){ @@ -816,12 +833,12 @@ var CourseAndTerm = React.createClass({
@@ -882,7 +899,7 @@ var TypeInterface = React.createClass({
{Object.keys(expType).map(function(key) { - if(key === "internship"){ + if(key === "internship"){ return(
) @@ -907,11 +924,11 @@ var TypeInterface = React.createClass({ var TypeModalForm = React.createClass({ render: function() { return ( - - -

Internship Type Definitions

-
- + + +

Internship Type Definitions

+
+
@@ -929,11 +946,11 @@ var TypeModalForm = React.createClass({
-
- - Close - -
+ + + + + ); } }); @@ -948,7 +965,7 @@ var NoteBox = React.createClass({
- +
@@ -963,7 +980,7 @@ var NoteBox = React.createClass({
- +
); @@ -986,7 +1003,7 @@ var ChangeLog = React.createClass({ relativeData={notes.relative_date} note ={notes.note} /> ); - }.bind(this))} + })}
); @@ -1001,34 +1018,34 @@ var ChangeFields = React.createClass({

{this.props.exactDate}Changed {this.props.relativeData} ago by {this.props.username}

- {this.props.fromState != undefined ? + {this.props.fromState !== undefined ?
  • Status changed from {this.props.fromState} to {this.props.toState}
: null}
{this.props.note}
-
+
); } }); -var DropzoneDemo = React.createClass({ - onDrop: function (files) { - console.log('Received files: ', files); - }, - - render: function () { - return ( -
- -
Try dropping some files here, or click to select files to upload.
-
-
- ); - } -}); +// var DropzoneDemo = React.createClass({ +// onDrop: function (files) { +// console.log('Received files: ', files); +// }, +// +// render: function () { +// return ( +//
+// +//
Try dropping some files here, or click to select files to upload.
+//
+//
+// ); +// } +// }); @@ -1063,19 +1080,19 @@ var HostInterface = React.createClass({
- + - +
-
@@ -1101,13 +1118,14 @@ var Location = React.createClass({ render: function() { var hostData = this.props.hostData; var domestic = this.props.domestic; - + var locState = ""; + var zip = ""; if(domestic){ - var locState = "State"; - var zip = "Zip"; + locState = "State"; + zip = "Zip"; } else { - var locState = "Country"; - var zip = "Postal Code"; + locState = "Country"; + zip = "Postal Code"; } return(
@@ -1176,11 +1194,11 @@ var Compensation = React.createClass({ }, componentWillMount: function() { var intern = this.props.intern; - if(intern.paid == true){ + if(intern.paid === true){ this.setState({paid: true}); } - if(intern.stipend == true){ + if(intern.stipend === true){ this.setState({stipend: true}); } }, @@ -1202,12 +1220,13 @@ var Compensation = React.createClass({ this.setState({stipend: e.currentTarget.checked}); }, render: function() { - var hostData = this.props.hostData; + //var hostData = this.props.hostData; var intern = this.props.intern; - var allow = intern.stipend; + //var allow = intern.stipend; var rButtons; var rName = this.props.hostData.id; - if(this.state.paid == false){ + + if(this.state.paid === false){ rButtons =
@@ -1235,7 +1254,7 @@ var Compensation = React.createClass({
- +
@@ -1257,14 +1276,14 @@ var Contracts = React.createClass({ }, render: function() { - change = undefined; + var change = undefined; return(
{this.props.title}
- {change != undefined ? + {change !== undefined ?
  • DOWNLOAD  DELETE
@@ -1275,7 +1294,7 @@ var Contracts = React.createClass({
- +
@@ -1285,8 +1304,8 @@ var Contracts = React.createClass({ var HostDetails = React.createClass({ grabHostData: function() { - var hostData = { - name: this.refs.name.value, + var hostData = { + name: this.refs.name.value, phone: this.refs.phone.value, address: this.refs.address.value, city: this.refs.city.value, @@ -1308,7 +1327,7 @@ var HostDetails = React.createClass({ stateName={state.full_name} active={hostData.state} /> ); - }.bind(this)); + }); } return(
@@ -1352,14 +1371,14 @@ var HostDetails = React.createClass({ var SupervisorInfo = React.createClass({ grabSupervisorData: function() { - var superData = { - fname: this.refs.fname.value, + var superData = { + fname: this.refs.fname.value, lname: this.refs.lname.value, title: this.refs.title.value, email: this.refs.email.value, fax: this.refs.fax.value, phone: this.refs.phone.value, - address: this.refs.address.value, + address: this.refs.address.value, city: this.refs.city.value, state: this.refs.state.value, zip: this.refs.zip.value @@ -1379,7 +1398,7 @@ var SupervisorInfo = React.createClass({ stateName={state.full_name} active={hostData.state} /> ); - }.bind(this)); + }); } return(
@@ -1446,6 +1465,6 @@ var SupervisorInfo = React.createClass({ }); ReactDOM.render( - , - document.getElementById('editInternshipInterface') -); \ No newline at end of file + , + document.getElementById('content') +); diff --git a/javascript/emergencyContact/EmgContactList.jsx b/javascript/emergencyContact/EmgContactList.jsx index c6f16e44..fdddac47 100644 --- a/javascript/emergencyContact/EmgContactList.jsx +++ b/javascript/emergencyContact/EmgContactList.jsx @@ -1,5 +1,4 @@ import React from 'react'; -import ReactDOM from 'react-dom'; import $ from 'jquery'; import {Button, Modal} from 'react-bootstrap'; @@ -232,12 +231,5 @@ var EmergencyContactList = React.createClass({ ); } }); -<<<<<<< HEAD - -ReactDOM.render( - , - document.getElementById('emergency-contact-list') -); -======= ->>>>>>> origin/reactEditInternship +export default EmergencyContactList; diff --git a/templates/editInternshipView.tpl b/templates/editInternshipView.tpl index 4b3dd256..9fc48cf4 100644 --- a/templates/editInternshipView.tpl +++ b/templates/editInternshipView.tpl @@ -1,26 +1,8 @@ -
+
- - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/webpack.config.dev.js b/webpack.config.dev.js index 9fe2010e..8140226b 100644 --- a/webpack.config.dev.js +++ b/webpack.config.dev.js @@ -14,13 +14,14 @@ module.exports = { editAdmin: JS_DIR + '/editAdmin/editAdmin.jsx', editDepartment: JS_DIR + '/editDepartment/deptEditor.jsx', stateList: JS_DIR + '/stateList/StateList.jsx', - emergencyContact: JS_DIR + '/emergencyContact/EmgContactList.jsx', + //emergencyContact: JS_DIR + '/emergencyContact/EmgContactList.jsx', facultyEdit: JS_DIR + '/facultyEdit/FacultyEdit.jsx', editMajor: JS_DIR + '/editMajor/editMajor.jsx', editGrad: JS_DIR + '/editGrad/editGrad.jsx', affiliationDepartments: JS_DIR + '/affiliationAgreement/AffiliationDepartments.jsx', affiliationLocation: JS_DIR + '/affiliationAgreement/AffiliationLocation.jsx', affiliationTerminate: JS_DIR + '/affiliationAgreement/AffiliationTerminate.jsx', + internshipView: JS_DIR + '/editInternshipView/InternshipView.jsx', vendor: ['jquery', 'react', 'react-dom', 'react-bootstrap'] }, output: { diff --git a/webpack.config.prod.js b/webpack.config.prod.js index 6bb7b5ad..09cf4b4c 100644 --- a/webpack.config.prod.js +++ b/webpack.config.prod.js @@ -17,13 +17,14 @@ module.exports = { editAdmin: JS_DIR + '/editAdmin/editAdmin.jsx', editDepartment: JS_DIR + '/editDepartment/deptEditor.jsx', stateList: JS_DIR + '/stateList/StateList.jsx', - emergencyContact: JS_DIR + '/emergencyContact/EmgContactList.jsx', + //emergencyContact: JS_DIR + '/emergencyContact/EmgContactList.jsx', facultyEdit: JS_DIR + '/facultyEdit/FacultyEdit.jsx', editMajor: JS_DIR + '/editMajor/editMajor.jsx', editGrad: JS_DIR + '/editGrad/editGrad.jsx', affiliationDepartments: JS_DIR + '/affiliationAgreement/AffiliationDepartments.jsx', affiliationLocation: JS_DIR + '/affiliationAgreement/AffiliationLocation.jsx', affiliationTerminate: JS_DIR + '/affiliationAgreement/AffiliationTerminate.jsx', + internshipView: JS_DIR + '/editInternshipView/InternshipView.jsx', vendor: ['jquery', 'react', 'react-dom', 'react-bootstrap'] }, output: { From a9ef4487d87ed66e9a69468213e83cf5f6854f69 Mon Sep 17 00:00:00 2001 From: Eric Cambel Date: Wed, 19 Apr 2017 12:21:51 -0400 Subject: [PATCH 32/32] Fixed bugs preventing edit intern view from showing. --- boost/update.php | 12 ++++++------ class/InternFolder.php | 2 +- class/State.php | 4 ++-- class/SubselectDatabase.php | 8 ++++---- class/SubselectPager.php | 4 ++-- class/WorkflowTransitionFactory.php | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/boost/update.php b/boost/update.php index 4b60536a..6437ef0e 100644 --- a/boost/update.php +++ b/boost/update.php @@ -44,7 +44,7 @@ function intern_update(&$content, $currentVersion) case version_compare($currentVersion, '0.0.16', '<') : internRunDbMigration('update_0_0_16.sql'); case version_compare($currentVersion, '0.0.17', '<') : - PHPWS_Core::initModClass('users', 'Permission.php'); + \PHPWS_Core::initModClass('users', 'Permission.php'); Users_Permission::registerPermissions('intern', $content); case version_compare($currentVersion, '0.0.18', '<') : internRunDbMigration('update_0_0_18.sql'); @@ -61,7 +61,7 @@ function intern_update(&$content, $currentVersion) case version_compare($currentVersion, '0.0.24', '<') : internRunDbMigration('update_0_0_24.sql'); case version_compare($currentVersion, '0.0.25', '<') : - PHPWS_Core::initModClass('users', 'Permission.php'); + \PHPWS_Core::initModClass('users', 'Permission.php'); Users_Permission::registerPermissions('intern', $content); case version_compare($currentVersion, '0.0.26', '<') : internRunDbMigration('update_0_0_26.sql'); @@ -77,15 +77,15 @@ function intern_update(&$content, $currentVersion) internRunDbMigration('update_0_0_31.sql'); case version_compare($currentVersion, '0.0.32', '<') : internRunDbMigration('update_0_0_32.sql'); - PHPWS_Core::initModClass('users', 'Permission.php'); + \PHPWS_Core::initModClass('users', 'Permission.php'); Users_Permission::registerPermissions('intern', $content); case version_compare($currentVersion, '0.0.33', '<') : - PHPWS_Core::initModClass('users', 'Permission.php'); + \PHPWS_Core::initModClass('users', 'Permission.php'); Users_Permission::registerPermissions('intern', $content); case version_compare($currentVersion, '0.0.35', '<') : internRunDbMigration('update_0_0_35.sql'); case version_compare($currentVersion, '0.0.36', '<') : - PHPWS_Core::initModClass('users', 'Permission.php'); + \PHPWS_Core::initModClass('users', 'Permission.php'); Users_Permission::registerPermissions('intern', $content); case version_compare($currentVersion, '0.0.37', '<') : internRunDbMigration('update_0_0_37.sql'); @@ -112,7 +112,7 @@ function intern_update(&$content, $currentVersion) case version_compare($currentVersion, '0.1.10', '<') : internRunDbMigration('update_00.01.10.sql'); case version_compare($currentVersion, '0.1.15', '<') : - PHPWS_Core::initModClass('users', 'Permission.php'); + \PHPWS_Core::initModClass('users', 'Permission.php'); Users_Permission::registerPermissions('intern', $content); } diff --git a/class/InternFolder.php b/class/InternFolder.php index d495ddcf..1fbee825 100644 --- a/class/InternFolder.php +++ b/class/InternFolder.php @@ -3,7 +3,7 @@ namespace Intern; use PHPWS_Link; -use PHPWS_Core; +use \PHPWS_Core; /** * Intern_Folder diff --git a/class/State.php b/class/State.php index 26338606..9e1574a5 100644 --- a/class/State.php +++ b/class/State.php @@ -43,7 +43,7 @@ public static function getAllowedStates() if (empty($states)) { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'The list of allowed US states for internship locations has not been configured. Please use the administrative options to add allowed states.'); \NQ::close(); - PHPWS_Core::goBack(); + \PHPWS_Core::goBack(); } return $states; @@ -66,7 +66,7 @@ public static function getStates() if (empty($result)) { \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'The list of allowed US states for internship locations has not been configured. Please use the administrative options to add allowed states.'); \NQ::close(); - PHPWS_Core::goBack(); + \PHPWS_Core::goBack(); } $resultState = array(); diff --git a/class/SubselectDatabase.php b/class/SubselectDatabase.php index 46562683..9dd89bb7 100644 --- a/class/SubselectDatabase.php +++ b/class/SubselectDatabase.php @@ -2136,7 +2136,7 @@ public function requireClasses() if (!is_array($files)) { continue; } - PHPWS_Core::initModClass($files[0], $files[1]); + \PHPWS_Core::initModClass($files[0], $files[1]); } $this->load_class = null; } @@ -2173,7 +2173,7 @@ public function loadObject($object, $require_where = true) return false; } - return PHPWS_Core::plugObject($object, $variables); + return \PHPWS_Core::plugObject($object, $variables); } // END FUNC loadObject @@ -2235,11 +2235,11 @@ public function getObjects($class_name) if (isset($itemResult[0]) && is_array($itemResult[0])) { foreach ($itemResult as $key => $sub) { $genClass = new $class_name; - PHPWS_Core::plugObject($genClass, $sub, $args); + \PHPWS_Core::plugObject($genClass, $sub, $args); $items[$indexby][] = $genClass; } } else { - PHPWS_Core::plugObject($genClass, $itemResult, $args); + \PHPWS_Core::plugObject($genClass, $itemResult, $args); $items[$indexby] = $genClass; } } diff --git a/class/SubselectPager.php b/class/SubselectPager.php index dc649f54..486fb752 100644 --- a/class/SubselectPager.php +++ b/class/SubselectPager.php @@ -1266,7 +1266,7 @@ function createReport() $result = call_user_func($this->report_row, $foo); } else { if (is_object($foo)) { - $result = PHPWS_Core::stripObjValues($foo); + $result = \PHPWS_Core::stripObjValues($foo); } else { $result = & $foo; } @@ -1309,7 +1309,7 @@ public function plugPageTags(&$template) public function saveLastView() { - $_SESSION['DBPager_Last_View'][$this->table] = PHPWS_Core::getCurrentUrl(); + $_SESSION['DBPager_Last_View'][$this->table] = \PHPWS_Core::getCurrentUrl(); } public static function getLastView($table) diff --git a/class/WorkflowTransitionFactory.php b/class/WorkflowTransitionFactory.php index 994bb688..59d3b9d7 100644 --- a/class/WorkflowTransitionFactory.php +++ b/class/WorkflowTransitionFactory.php @@ -65,7 +65,7 @@ public static function getAllTransitions() // Look for directories that don't start with '.' if(!is_dir($dir . '/' . $f) && substr($f, 0, 1) != '.'){ // Include each one - PHPWS_Core::initModClass('intern', self::$dir . '/' . $f); + \PHPWS_Core::initModClass('intern', self::$dir . '/' . $f); $className = preg_replace('/\.php/', '', $f); $className = '\Intern\WorkflowTransition\\' . $className;