Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[issue_tracker] Fixes some of the functionality of the module #4690

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions jsx/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down
22 changes: 14 additions & 8 deletions jsx/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -1408,12 +1408,19 @@ LinkElement.defaultProps = {
* React wrapper for a <input type="checkbox"> 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);
}

Expand All @@ -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) {
Expand All @@ -1438,18 +1444,18 @@ class CheckboxElement extends React.Component {

return (
<div className={elementClass}>
<label htmlFor={this.props.id}>
<label htmlFor={this.state.id}>
<input
type="checkbox"
name={this.props.name}
id={this.props.id}
checked={this.props.value}
name={this.state.name}
id={this.state.id}
checked={this.state.value}
required={required}
disabled={disabled}
onChange={this.handleChange}
/>
{errorMessage}
{this.props.label}
{this.state.label}
{requiredHTML}
</label>
</div>
Expand Down
22 changes: 12 additions & 10 deletions modules/issue_tracker/ajax/EditIssue.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,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)) {
Expand All @@ -84,7 +84,7 @@ function editIssue()
}
}

$issueID = $_POST['issueID'];
$issueID = isset($_POST['issueID']) ? $_POST['issueID'] : null;
$issueValues['lastUpdatedBy'] = $user->getData('UserID');

$validatedInput = validateInput($validateValues);
Expand All @@ -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'])) {
Expand All @@ -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(
Expand Down Expand Up @@ -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
);
Expand Down
16 changes: 12 additions & 4 deletions modules/issue_tracker/jsx/IssueForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class IssueForm extends Component {
this.state = {
Data: [],
formData: {},
site: null,
submissionResult: null,
errorMessage: null,
isLoaded: false,
Expand Down Expand Up @@ -74,7 +75,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';
Expand Down Expand Up @@ -176,11 +176,12 @@ class IssueForm extends Component {
<SelectElement
name='centerID'
label='Site'
emptyOption={true}
options={this.state.Data.sites}
onUserInput={this.setFormData}
disabled={!hasEditPermission}
value={this.state.formData.centerID}
value={this.state.site}
emptyOption={true}
multiple={false}
required={true}
/>
<SelectElement
Expand Down Expand Up @@ -242,7 +243,7 @@ class IssueForm extends Component {
emptyOption={false}
options={{No: 'No', Yes: 'Yes'}}
onUserInput={this.setFormData}
value={isWatching}
value={this.state.issueData.watching}
/>
<SelectElement
name='othersWatching'
Expand Down Expand Up @@ -273,6 +274,12 @@ class IssueForm extends Component {
$.ajax(this.props.DataURL, {
dataType: 'json',
success: function(data) {
if (data.issueData
&& data.issueData.centerID
&& !Array.isArray(data.issueData.centerID)
) {
this.setState({site: data.issueData.centerID});
}
this.setState({
Data: data,
isLoaded: true,
Expand Down Expand Up @@ -357,6 +364,7 @@ class IssueForm extends Component {

this.setState({
formData: formDataUpdate,
site: value,
});
}

Expand Down
2 changes: 1 addition & 1 deletion modules/issue_tracker/php/issue.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 0 additions & 1 deletion modules/issue_tracker/php/issuerowprovisioner.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Loading