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
25 changes: 23 additions & 2 deletions includes/ProgressTableProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ class ProgressTableProcessor {
private ?string $errorMessage = null;

/**
* Whether the checkbox row should go on the left (first column) or the right
* (last column). Accepted values are "last" or anything else which will default to first
* (hence the 'first' here actually does nothing)
* @TODO: maybe we need to automatically decide this from rtl lang also
* @var string
*/
private string $checkboxLocation = 'first';
* Row indexes that should not contain checkboxes if exclude-row-indexes is set
* @var array
*/
Expand Down Expand Up @@ -110,6 +117,11 @@ public function __construct( string $wikitext, array $args, Parser $parser, PPFr
return;
}

if ( isset( $this->args['location'] ) ) {
// maybe don't need htmlspecialchars here but paranoia
$this->checkboxLocation = htmlspecialchars( $this->args['location'] );
}

if ( isset( $this->args['exclude-row-indexes'] ) ) {
$val = trim( $this->args['exclude-row-indexes'] );

Expand Down Expand Up @@ -317,7 +329,11 @@ private function addProgressHeader(): void {

$progressHeader->appendChild( $headerDiv );

$headerRow->insertBefore( $progressHeader, $headerRow->firstChild );
if ( $this->checkboxLocation === 'last' ) {
$headerRow->appendChild( $progressHeader );
} else {
$headerRow->insertBefore( $progressHeader, $headerRow->firstChild );
}
}
}

Expand Down Expand Up @@ -378,6 +394,7 @@ private function addCheckboxCellToRow( DOMElement $row, int $rowIndex ): void {
$checkBoxInput->setAttribute( 'class', 'cdx-checkbox__input' );
$checkBoxInput->setAttribute( 'data-row-id', $rowId );
$checkBoxInput->setAttribute( 'id', $rowId );

// disable the checkbox by default, when the JS runs, it will remove the disabled attribute.
// this is to ensure that no checkbox is selected before the JS initialises (or in the case of an unregistered
// user, the checkbox will remain disabled)
Expand Down Expand Up @@ -418,7 +435,11 @@ private function addCheckboxCellToRow( DOMElement $row, int $rowIndex ): void {
$cell->setAttribute( 'data-sort-value', 0 );
$cell->appendChild( $checkboxDiv );

$row->insertBefore( $cell, $row->firstChild );
if ( $this->checkboxLocation === 'last' ) {
$row->appendChild( $cell );
} else {
$row->insertBefore( $cell, $row->firstChild );
}
}

/**
Expand Down
17 changes: 17 additions & 0 deletions resources/index.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@import "mediawiki.skin.variables.less";

:root {
--tpt-checked-background: @color-success;
}

.progress-tracking-table .header_icon {
display: flex;
margin: 0;
Expand All @@ -8,3 +12,16 @@
.ext-tableProgressTracking-icon-check {
.cdx-mixin-css-icon( @cdx-icon-check );
}

td.progress-tracker-checkbox-cell:has(input[type="checkbox"]:checked) {
background: var(--tpt-checked-background);
}

// Center checkboxes
// https://dev.miraheze.org/wiki/User:Splatched/TPTTweaks.js
.progress-tracker-checkbox-cell .cdx-checkbox {
margin-left: auto;
margin-right: auto;
width: max-content;
display: flex;
}
Loading