From 6456374249567892acfa4d6a98eef60c9410a3f7 Mon Sep 17 00:00:00 2001 From: OriginalAuthority Date: Fri, 20 Mar 2026 01:00:48 +0000 Subject: [PATCH 1/2] Add ability to sort table rows --- includes/ProgressTableProcessor.php | 5 ++++- resources/index.js | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/includes/ProgressTableProcessor.php b/includes/ProgressTableProcessor.php index 96ee2a0..348117e 100644 --- a/includes/ProgressTableProcessor.php +++ b/includes/ProgressTableProcessor.php @@ -174,7 +174,7 @@ private function validateDataRowIds(): bool { foreach ( $dataRows as $row ) { $rowId = $this->extractDataRowId( $row ); if ( empty( $rowId ) ) { - $this->errorMessage = 'When unique-column-index is not provided, + $this->errorMessage = 'When unique-column-index is not provided, all data rows must have a data-row-id attribute.'; return false; } @@ -348,6 +348,9 @@ private function addCheckboxCellToRow( DOMElement $row, int $rowIndex ): void { $cell = $this->dom->createElement( 'td' ); $cell->setAttribute( 'class', self::CHECKBOX_CELL_CLASS ); + // set the initial sortable value to 0 (does nothing if the table isn't sortable) + // when the JS runs, it will change this to 1 for tracked cells + $cell->setAttribute( 'data-sort-value', 0 ); $cell->appendChild( $checkboxDiv ); $row->insertBefore( $cell, $row->firstChild ); diff --git a/resources/index.js b/resources/index.js index 82ac3ce..46eadc4 100644 --- a/resources/index.js +++ b/resources/index.js @@ -152,8 +152,19 @@ var ProgressTracker = { // remove the disable attribute from the checkbox so that it can be actioned // this happens irrespective of whether the checkbox is checked or not checkbox.disabled = false; + + // if this row is tracked, change the sortable value to 1 to allow sorting + // (even if the table isn't sortable) + let sortVal = isChecked ? 1 : 0; + let $cell = $( checkbox ).closest( 'td' ); + + if ($cell.length) { + $cell.attr( 'data-sort-value', sortVal ); + $cell.data( 'sortValue', sortVal ); + } } }.bind( this ) ); + $( table ).trigger('update'); }, /** From cd98eac629d8be7e045e806d89aa29599ca90160 Mon Sep 17 00:00:00 2001 From: OriginalAuthority Date: Fri, 20 Mar 2026 01:02:09 +0000 Subject: [PATCH 2/2] CI: lint to MW Standards --- resources/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/index.js b/resources/index.js index 46eadc4..7bdefd4 100644 --- a/resources/index.js +++ b/resources/index.js @@ -158,7 +158,7 @@ var ProgressTracker = { let sortVal = isChecked ? 1 : 0; let $cell = $( checkbox ).closest( 'td' ); - if ($cell.length) { + if ( $cell.length ) { $cell.attr( 'data-sort-value', sortVal ); $cell.data( 'sortValue', sortVal ); }