Skip to content

Commit

Permalink
Merge remote-tracking branch 'aces/24.1-release' into 2418To25
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave MacFarlane committed Oct 2, 2024
2 parents 9177127 + 729ce8a commit 6f56031
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 5 deletions.
67 changes: 65 additions & 2 deletions jsx/StaticDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,63 @@ class StaticDataTable extends Component {
});
}

/**
* Get if the current sorting column has mixed types in its values.
*
* @return {bool} true if mixed types, else false.
*/
hasMixedTypes() {
// TODO: data column type check should probably be done once at init,
// meaning when receiving data, to find which columns have mixed types.
let typeFound = null;

// not the default column
if (this.state.SortColumn === -1) {
return false;
}

// Only checks string or number types, others are considered undefined.
// Break out of this loop once we encounter two mixed types:
// number and string inside the sorted column.
for (const row of this.props.Data) {
// cell value
let val = row[this.state.SortColumn];

// if null or undefined, go to the next iteration
if (val == null) {
continue;
}

// check number
if (!isNaN(val) && typeof val !== 'object') {
// if string is found, mix of types, break
if (typeFound === 'string') {
return true;
}
// register number only if not already in
if (typeFound == null) {
typeFound = 'number';
}

// avoid string section
continue;
}

// check string
if (typeof val === 'string' || val instanceof String) {
// if number is found, mix of types, break
if (typeFound === 'number') {
return true;
}
// register string only if not already in
if (typeFound == null) {
typeFound = 'string';
}
}
}
return false;
}

/**
* Sort the rows according to the sort configuration
*
Expand All @@ -298,6 +355,10 @@ class StaticDataTable extends Component {
getSortedRows() {
const index = [];

// is the current sorted column with mixed type?
const isMixedType = this.hasMixedTypes();

//
for (let i = 0; i < this.props.Data.length; i += 1) {
let val = this.props.Data[i][this.state.SortColumn] || undefined;
// If SortColumn is equal to default No. column, set value to be
Expand All @@ -311,10 +372,12 @@ class StaticDataTable extends Component {
if (val === '.') {
// hack to handle non-existent items in DQT
val = null;
} else if (isNumber) {
} else if (isNumber && !isMixedType) {
// perform type conversion (from string to int/float)
val = Number(val);
} else if (isString) {
} else if (isString || isMixedType) {
// in case of mixed types, force values to string.
val = String(val);
// if string with text convert to lowercase
val = val.toLowerCase();
} else {
Expand Down
2 changes: 1 addition & 1 deletion modules/issue_tracker/php/edit.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Edit extends \NDB_Page implements ETagCalculator
$inactive_users_expanded = $db->pselect(
"SELECT DISTINCT u.Real_name, u.UserID FROM users u
LEFT JOIN user_psc_rel upr ON (upr.UserID=u.ID)
WHERE FIND_IN_SET(upr.CenterID,:CenterID) OR (upr.CenterID=:DCC)
WHERE (FIND_IN_SET(upr.CenterID,:CenterID) OR (upr.CenterID=:DCC))
AND Active='N'",
[
'CenterID' => $CenterID,
Expand Down
4 changes: 2 additions & 2 deletions tools/detect_duplicated_commentids.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
]
);
if (($session_info!=null) && (!empty($session_info))) {
$sessionid = $session_info['ID'];
$visit_label = $session_info['Visit_label'];
$sessionid = $session_info[0]['ID'];
$visit_label = $session_info[0]['Visit_label'];
if ($sessionid !=null) {
$commentid = getCommentIDs(
$instrument,
Expand Down

0 comments on commit 6f56031

Please sign in to comment.