From bbd9bbbb222f91cb39c9ad1599b703e827d4063c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aliz=C3=A9e=20Bellerose?= Date: Thu, 23 May 2019 10:36:45 -0400 Subject: [PATCH 1/9] update --- jsx/DataTable.js | 3 ++- jsx/Form.js | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/jsx/DataTable.js b/jsx/DataTable.js index 75222f07da4..4c04bd20575 100644 --- a/jsx/DataTable.js +++ b/jsx/DataTable.js @@ -298,7 +298,8 @@ class DataTable extends Component { let match = false; for (let i = 0; i < filterData.length; i += 1) { searchKey = filterData[i].toLowerCase(); - searchString = data.toLowerCase(); + searchString = typeof data === 'string' || data instanceof String ? + data.toLowerCase() : ''; match = (searchString.indexOf(searchKey) > -1); if (match) { diff --git a/jsx/Form.js b/jsx/Form.js index a0d7201e2af..ad6a3234aa4 100644 --- a/jsx/Form.js +++ b/jsx/Form.js @@ -1408,12 +1408,19 @@ LinkElement.defaultProps = { * React wrapper for a element. */ class CheckboxElement extends React.Component { - constructor() { - super(); + constructor(props) { + super(props); + this.state = { + id: this.props.id, + name: this.props.name, + checked: this.props.value, + label: this.props.label, + }; this.handleChange = this.handleChange.bind(this); } handleChange(e) { + this.setState({checked: e.target.checked}); this.props.onUserInput(this.props.name, e.target.checked); } @@ -1423,7 +1430,6 @@ class CheckboxElement extends React.Component { let errorMessage = null; let requiredHTML = null; let elementClass = 'checkbox-inline col-sm-offset-3'; - let label = null; // Add required asterix if (required) { @@ -1438,18 +1444,18 @@ class CheckboxElement extends React.Component { return (
-
From da00506c8e866ef9a1558edd60e2f6e9bcf70124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aliz=C3=A9e=20Bellerose?= Date: Thu, 23 May 2019 12:49:49 -0400 Subject: [PATCH 2/9] update --- modules/issue_tracker/ajax/EditIssue.php | 16 +++++++++------- modules/issue_tracker/jsx/IssueForm.js | 15 ++++++++++----- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/issue_tracker/ajax/EditIssue.php b/modules/issue_tracker/ajax/EditIssue.php index 99c62fb369e..c81d2beb9d9 100644 --- a/modules/issue_tracker/ajax/EditIssue.php +++ b/modules/issue_tracker/ajax/EditIssue.php @@ -33,7 +33,8 @@ if ($_SERVER['REQUEST_METHOD'] === "GET") { echo json_encode(getIssueFields()); } else if ($_SERVER['REQUEST_METHOD'] === "POST") { - echo json_encode(editIssue()); + $send = editIssue(); + echo json_encode($send); } else { header("HTTP/1.1 403 Forbidden"); exit; @@ -70,8 +71,8 @@ function editIssue() ); foreach ($fields as $field) { - $value = $_POST[$field]; - if ($_POST[$field] === "null") { + $value = isset($_POST[$field]) ? $_POST[$field] : null; + if (isset($_POST[$field]) && $_POST[$field] === "null") { $value = null; } if (isset($field)) { @@ -103,6 +104,7 @@ function editIssue() } else { $issueValues['reporter'] = $user->getData('UserID'); $issueValues['dateCreated'] = date('Y-m-d H:i:s'); + $db->insert('issues', $issueValues); $issueID = $db->getLastInsertId(); } @@ -502,18 +504,18 @@ function emailUser($issueID, $changed_assignee) if (isset($changed_assignee)) { $issueChangeEmailsAssignee = $db->pselect( - "SELECT u.Email as Email, u.First_name as firstname " . + "SELECT u.Email as Email, u.First_name as First_name " . "FROM users u WHERE u.UserID=:assignee - AND u.UserID<>:currentUser", + OR u.UserID=:currentUser", array( 'assignee' => $changed_assignee, 'currentUser' => $user->getUserName(), ) ); - $msg_data['firstname'] = $issueChangeEmailsAssignee[0]['firstname']; + $msg_data['firstname'] = $issueChangeEmailsAssignee[0]['First_name']; Email::send( - $issueChangeEmailsAssignee[0]['Email'], + $issueChangeEmailsAssignee[0]['Email'] ?? '', 'issue_assigned.tpl', $msg_data ); diff --git a/modules/issue_tracker/jsx/IssueForm.js b/modules/issue_tracker/jsx/IssueForm.js index a5564d5f014..120cb9ebf81 100644 --- a/modules/issue_tracker/jsx/IssueForm.js +++ b/modules/issue_tracker/jsx/IssueForm.js @@ -18,7 +18,10 @@ class IssueForm extends Component { this.state = { Data: [], - formData: {}, + formData: { + othersWatching: [], + }, + site: '', submissionResult: null, errorMessage: null, isLoaded: false, @@ -74,7 +77,6 @@ class IssueForm extends Component { let dateCreated; let submitButtonValue; let commentLabel; - let isWatching = this.state.issueData.watching; if (this.state.isNewIssue) { headerText = 'Create New Issue'; @@ -180,7 +182,8 @@ class IssueForm extends Component { options={this.state.Data.sites} onUserInput={this.setFormData} disabled={!hasEditPermission} - value={this.state.formData.centerID} + value={this.state.site} + multiple={false} required={true} /> Date: Thu, 23 May 2019 13:13:47 -0400 Subject: [PATCH 3/9] update --- jsx/DataTable.js | 2 +- jsx/Filter.js | 1 - modules/issue_tracker/jsx/IssueForm.js | 1 - .../issue_tracker/jsx/issueTrackerIndex.js | 2 + package-lock.json | 79 ++++++++++++------- 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/jsx/DataTable.js b/jsx/DataTable.js index 4c04bd20575..51999129a3f 100644 --- a/jsx/DataTable.js +++ b/jsx/DataTable.js @@ -42,7 +42,7 @@ class DataTable extends Component { setSortColumn(column) { if (this.state.sort.column === column) { - this.props.toggleSortOrder(); + this.toggleSortOrder(); } else { this.updateSortColumn(column); } diff --git a/jsx/Filter.js b/jsx/Filter.js index 02d60989735..ce918bcf45d 100644 --- a/jsx/Filter.js +++ b/jsx/Filter.js @@ -52,7 +52,6 @@ class Filter extends Component { } filter[name] = {value, exactMatch}; } - this.props.updateFilter(filter); history.replaceState(filter, '', `?${searchParams.toString()}`); } diff --git a/modules/issue_tracker/jsx/IssueForm.js b/modules/issue_tracker/jsx/IssueForm.js index 120cb9ebf81..00b4c67a5b9 100644 --- a/modules/issue_tracker/jsx/IssueForm.js +++ b/modules/issue_tracker/jsx/IssueForm.js @@ -276,7 +276,6 @@ class IssueForm extends Component { $.ajax(this.props.DataURL, { dataType: 'json', success: function(data) { - data.issueData.centerID[''] = ''; this.setState({ Data: data, isLoaded: true, diff --git a/modules/issue_tracker/jsx/issueTrackerIndex.js b/modules/issue_tracker/jsx/issueTrackerIndex.js index 71d855fd425..38798fc3d61 100644 --- a/modules/issue_tracker/jsx/issueTrackerIndex.js +++ b/modules/issue_tracker/jsx/issueTrackerIndex.js @@ -221,6 +221,8 @@ class IssueTrackerIndex extends Component { {label: 'New Issue', action: addIssue}, ]; + console.log(fields); + return ( Date: Thu, 23 May 2019 14:20:17 -0400 Subject: [PATCH 4/9] fixes --- modules/issue_tracker/jsx/IssueForm.js | 7 +++++++ modules/issue_tracker/jsx/issueTrackerIndex.js | 3 ++- modules/issue_tracker/php/issue_tracker.class.inc | 3 +++ modules/issue_tracker/php/issuerowprovisioner.class.inc | 1 - 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/issue_tracker/jsx/IssueForm.js b/modules/issue_tracker/jsx/IssueForm.js index 00b4c67a5b9..e9adff2a94a 100644 --- a/modules/issue_tracker/jsx/IssueForm.js +++ b/modules/issue_tracker/jsx/IssueForm.js @@ -276,6 +276,13 @@ class IssueForm extends Component { $.ajax(this.props.DataURL, { dataType: 'json', success: function(data) { + console.log(data); + if (data.issueData + && data.issueData.centerID + && !Array.isArray(data.issueData.centerID) + ) { + this.setState({site: data.issueData.centerID}); + } this.setState({ Data: data, isLoaded: true, diff --git a/modules/issue_tracker/jsx/issueTrackerIndex.js b/modules/issue_tracker/jsx/issueTrackerIndex.js index 38798fc3d61..738013246e6 100644 --- a/modules/issue_tracker/jsx/issueTrackerIndex.js +++ b/modules/issue_tracker/jsx/issueTrackerIndex.js @@ -140,6 +140,7 @@ class IssueTrackerIndex extends Component { * queried columns in _setupVariables() in media.class.inc */ const options = this.state.data.fieldOptions; + console.log(options); const fields = [ {label: 'Issue ID', show: true, filter: { name: 'issueID', @@ -221,7 +222,7 @@ class IssueTrackerIndex extends Component { {label: 'New Issue', action: addIssue}, ]; - console.log(fields); + console.log(this.state.data.data); return ( withDataFrom($this->getDataProvisioner()); + + $check = $table->toJSON($user); + $arr = array_map( function ($row) { return array_values($row); diff --git a/modules/issue_tracker/php/issuerowprovisioner.class.inc b/modules/issue_tracker/php/issuerowprovisioner.class.inc index ec8e924ba73..43763ab0cde 100644 --- a/modules/issue_tracker/php/issuerowprovisioner.class.inc +++ b/modules/issue_tracker/php/issuerowprovisioner.class.inc @@ -83,7 +83,6 @@ class IssueRowProvisioner extends \LORIS\Data\Provisioners\DBRowProvisioner public function getInstance($row) : \LORIS\Data\DataInstance { $cid = $row['centerId']; - unset($row['centerId']); return new IssueRow($row, $cid); } } From f380aa1a8abf9264d48379e399e745d0386a26b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aliz=C3=A9e=20Bellerose?= Date: Fri, 24 May 2019 10:41:40 -0400 Subject: [PATCH 5/9] cleanup --- jsx/Filter.js | 1 + modules/issue_tracker/ajax/EditIssue.php | 4 +--- modules/issue_tracker/jsx/IssueForm.js | 6 ++---- modules/issue_tracker/jsx/issueTrackerIndex.js | 3 --- modules/issue_tracker/php/issue_tracker.class.inc | 3 --- 5 files changed, 4 insertions(+), 13 deletions(-) diff --git a/jsx/Filter.js b/jsx/Filter.js index ce918bcf45d..02d60989735 100644 --- a/jsx/Filter.js +++ b/jsx/Filter.js @@ -52,6 +52,7 @@ class Filter extends Component { } filter[name] = {value, exactMatch}; } + this.props.updateFilter(filter); history.replaceState(filter, '', `?${searchParams.toString()}`); } diff --git a/modules/issue_tracker/ajax/EditIssue.php b/modules/issue_tracker/ajax/EditIssue.php index c81d2beb9d9..a5df5b636d7 100644 --- a/modules/issue_tracker/ajax/EditIssue.php +++ b/modules/issue_tracker/ajax/EditIssue.php @@ -33,8 +33,7 @@ if ($_SERVER['REQUEST_METHOD'] === "GET") { echo json_encode(getIssueFields()); } else if ($_SERVER['REQUEST_METHOD'] === "POST") { - $send = editIssue(); - echo json_encode($send); + echo json_encode(editIssue()); } else { header("HTTP/1.1 403 Forbidden"); exit; @@ -104,7 +103,6 @@ function editIssue() } else { $issueValues['reporter'] = $user->getData('UserID'); $issueValues['dateCreated'] = date('Y-m-d H:i:s'); - $db->insert('issues', $issueValues); $issueID = $db->getLastInsertId(); } diff --git a/modules/issue_tracker/jsx/IssueForm.js b/modules/issue_tracker/jsx/IssueForm.js index e9adff2a94a..e8695a7fdc9 100644 --- a/modules/issue_tracker/jsx/IssueForm.js +++ b/modules/issue_tracker/jsx/IssueForm.js @@ -18,9 +18,7 @@ class IssueForm extends Component { this.state = { Data: [], - formData: { - othersWatching: [], - }, + formData: {}, site: '', submissionResult: null, errorMessage: null, @@ -345,7 +343,7 @@ class IssueForm extends Component { }); }.bind(this), error: function(err) { - console.error(err.responseText); + console.error(err); this.setState({submissionResult: 'error'}); let msgType = 'error'; let message = 'Failed to submit issue :('; diff --git a/modules/issue_tracker/jsx/issueTrackerIndex.js b/modules/issue_tracker/jsx/issueTrackerIndex.js index 738013246e6..71d855fd425 100644 --- a/modules/issue_tracker/jsx/issueTrackerIndex.js +++ b/modules/issue_tracker/jsx/issueTrackerIndex.js @@ -140,7 +140,6 @@ class IssueTrackerIndex extends Component { * queried columns in _setupVariables() in media.class.inc */ const options = this.state.data.fieldOptions; - console.log(options); const fields = [ {label: 'Issue ID', show: true, filter: { name: 'issueID', @@ -222,8 +221,6 @@ class IssueTrackerIndex extends Component { {label: 'New Issue', action: addIssue}, ]; - console.log(this.state.data.data); - return ( withDataFrom($this->getDataProvisioner()); - - $check = $table->toJSON($user); - $arr = array_map( function ($row) { return array_values($row); From 93bb169e309d3db7cc6f3239693bd75c308a29b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aliz=C3=A9e=20Bellerose?= Date: Fri, 24 May 2019 12:07:14 -0400 Subject: [PATCH 6/9] update --- modules/issue_tracker/jsx/IssueForm.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/issue_tracker/jsx/IssueForm.js b/modules/issue_tracker/jsx/IssueForm.js index e8695a7fdc9..118b5c7cd3e 100644 --- a/modules/issue_tracker/jsx/IssueForm.js +++ b/modules/issue_tracker/jsx/IssueForm.js @@ -19,7 +19,7 @@ class IssueForm extends Component { this.state = { Data: [], formData: {}, - site: '', + site: null, submissionResult: null, errorMessage: null, isLoaded: false, @@ -176,11 +176,11 @@ class IssueForm extends Component { From eea011a8728534e3a84826bd3b4646b93d6ad0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aliz=C3=A9e=20Bellerose?= Date: Mon, 27 May 2019 13:35:25 -0400 Subject: [PATCH 7/9] update --- modules/issue_tracker/ajax/EditIssue.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/issue_tracker/ajax/EditIssue.php b/modules/issue_tracker/ajax/EditIssue.php index a5df5b636d7..dde573dde65 100644 --- a/modules/issue_tracker/ajax/EditIssue.php +++ b/modules/issue_tracker/ajax/EditIssue.php @@ -84,7 +84,7 @@ function editIssue() } } - $issueID = $_POST['issueID']; + $issueID = isset($_POST['issueID']) ? $_POST['issueID'] : null; $issueValues['lastUpdatedBy'] = $user->getData('UserID'); $validatedInput = validateInput($validateValues); @@ -107,8 +107,9 @@ function editIssue() $issueID = $db->getLastInsertId(); } + $comment = isset($_POST['comment']) ? $_POST['comment'] : null; updateHistory($historyValues, $issueID); - updateComments($_POST['comment'], $issueID); + updateComments($comment, $issueID); // Adding new assignee to watching if (isset($issueValues['assignee'])) { @@ -120,13 +121,14 @@ function editIssue() } // Adding editor to the watching table unless they don't want to be added. - if ($_POST['watching'] == 'Yes') { + $watching = isset($_POST['watching']) ? $_POST['watching'] : null; + if ($watching == 'Yes') { $nowWatching = array( 'userID' => $user->getData('UserID'), 'issueID' => $issueID, ); $db->replace('issues_watching', $nowWatching); - } else if ($_POST['watching'] == "No") { + } else if ($watching == "No") { $db->delete( 'issues_watching', array( From 85b36b70f913b886a1b333d40e41a95de8073161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aliz=C3=A9e=20Bellerose?= Date: Wed, 29 May 2019 11:14:47 -0400 Subject: [PATCH 8/9] update --- modules/issue_tracker/jsx/IssueForm.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/issue_tracker/jsx/IssueForm.js b/modules/issue_tracker/jsx/IssueForm.js index 118b5c7cd3e..cb4e9f0e76f 100644 --- a/modules/issue_tracker/jsx/IssueForm.js +++ b/modules/issue_tracker/jsx/IssueForm.js @@ -274,7 +274,6 @@ class IssueForm extends Component { $.ajax(this.props.DataURL, { dataType: 'json', success: function(data) { - console.log(data); if (data.issueData && data.issueData.centerID && !Array.isArray(data.issueData.centerID) From 54cfa7e6623e22410bd09436f2427db6e73bddff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aliz=C3=A9e=20Bellerose?= Date: Thu, 30 May 2019 14:42:46 -0400 Subject: [PATCH 9/9] fix bug found by zaliqa --- modules/issue_tracker/php/issue.class.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/issue_tracker/php/issue.class.inc b/modules/issue_tracker/php/issue.class.inc index 610c86f0288..31145b963e3 100644 --- a/modules/issue_tracker/php/issue.class.inc +++ b/modules/issue_tracker/php/issue.class.inc @@ -132,7 +132,7 @@ class Issue extends \NDB_Form public function handle(ServerRequestInterface $request) : ResponseInterface { $this->issueID = $request->getQueryParams()['issueID']; - if (empty($this->issueID)) { + if (empty($this->issueID) && $this->issueID !== '0') { // Should probably be a bad request, but we don't have a 400.tpl // template. return new \Loris\Http\Error($request, 404, "Issue not found");