Skip to content
Merged
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: 4 additions & 1 deletion includes/ProgressTableProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 );
Expand Down
11 changes: 11 additions & 0 deletions resources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
},

/**
Expand Down
Loading