diff --git a/includes/ProgressTableProcessor.php b/includes/ProgressTableProcessor.php index 57021b6..7188502 100644 --- a/includes/ProgressTableProcessor.php +++ b/includes/ProgressTableProcessor.php @@ -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 */ @@ -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'] ); @@ -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 ); + } } } @@ -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) @@ -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 ); + } } /** diff --git a/resources/index.less b/resources/index.less index 294a48f..f4ab3d1 100644 --- a/resources/index.less +++ b/resources/index.less @@ -1,5 +1,9 @@ @import "mediawiki.skin.variables.less"; +:root { + --tpt-checked-background: @color-success; +} + .progress-tracking-table .header_icon { display: flex; margin: 0; @@ -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; +}