From 6cf13604aec40e2210c16ccdbeba850de9428d19 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 11 May 2017 15:11:45 +0100 Subject: [PATCH] Convert rest of Special:Undelete to OOUI Also fix the 'invert selection' button: * Don't use type=submit so it doesn't try to post if JS is disabled * Don't invert the wpUnsuppress checkbox, just checkboxes in revision lists. Bug: T113758 Change-Id: I84785a5ddcc3343d74b5b7addb4aa4817a469f33 --- includes/specials/SpecialUndelete.php | 159 ++++++++++-------- .../mediawiki.special.undelete.js | 5 +- 2 files changed, 95 insertions(+), 69 deletions(-) diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 8a59773df2..e6e9400cea 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -715,11 +715,11 @@ class SpecialUndelete extends SpecialPage { if ( $this->mAllowed ) { $action = $this->getPageTitle()->getLocalURL( [ 'action' => 'submit' ] ); # Start the form here - $top = Xml::openElement( - 'form', - [ 'method' => 'post', 'action' => $action, 'id' => 'undelete' ] - ); - $out->addHTML( $top ); + $form = new OOUI\FormLayout( [ + 'method' => 'post', + 'action' => $action, + 'id' => 'undelete', + ] ); } # Show relevant lines from the deletion log: @@ -734,68 +734,91 @@ class SpecialUndelete extends SpecialPage { } if ( $this->mAllowed && ( $haveRevisions || $haveFiles ) ) { - # Format the user-visible controls (comment field, submission button) - # in a nice little table + $out->enableOOUI(); + + $fields[] = new OOUI\Layout( [ + 'content' => new OOUI\HtmlSnippet( $this->msg( 'undeleteextrahelp' )->parseAsBlock() ) + ] ); + + $fields[] = new OOUI\FieldLayout( + new OOUI\TextInputWidget( [ + 'name' => 'wpComment', + 'inputId' => 'wpComment', + 'infusable' => true, + 'value' => $this->mComment, + 'autofocus' => true, + ] ), + [ + 'label' => $this->msg( 'undeletecomment' )->text(), + 'align' => 'top', + ] + ); + + $fields[] = new OOUI\FieldLayout( + new OOUI\Widget( [ + 'content' => new OOUI\HorizontalLayout( [ + 'items' => [ + new OOUI\ButtonInputWidget( [ + 'name' => 'restore', + 'inputId' => 'mw-undelete-submit', + 'value' => '1', + 'label' => $this->msg( 'undeletebtn' )->text(), + 'flags' => [ 'primary', 'progressive' ], + 'type' => 'submit', + ] ), + new OOUI\ButtonInputWidget( [ + 'name' => 'invert', + 'inputId' => 'mw-undelete-invert', + 'value' => '1', + 'label' => $this->msg( 'undeleteinvert' )->text() + ] ), + ] + ] ) + ] ) + ); + if ( $this->getUser()->isAllowed( 'suppressrevision' ) ) { - $unsuppressBox = - " -   - " . - Xml::checkLabel( $this->msg( 'revdelete-unsuppress' )->text(), - 'wpUnsuppress', 'mw-undelete-unsuppress', $this->mUnsuppress ) . - " - "; - } else { - $unsuppressBox = ''; + $fields[] = new OOUI\FieldLayout( + new OOUI\CheckboxInputWidget( [ + 'name' => 'wpUnsuppress', + 'inputId' => 'mw-undelete-unsuppress', + 'value' => '1', + ] ), + [ + 'label' => $this->msg( 'revdelete-unsuppress' )->text(), + 'align' => 'inline', + ] + ); } - $table = Xml::fieldset( $this->msg( 'undelete-fieldset-title' )->text() ) . - Xml::openElement( 'table', [ 'id' => 'mw-undelete-table' ] ) . - " - " . - $this->msg( 'undeleteextrahelp' )->parseAsBlock() . - " - - - " . - Xml::label( $this->msg( 'undeletecomment' )->text(), 'wpComment' ) . - " - " . - Xml::input( - 'wpComment', - 50, - $this->mComment, - [ 'id' => 'wpComment', 'autofocus' => '' ] - ) . - " - - -   - " . - Xml::submitButton( - $this->msg( 'undeletebtn' )->text(), - [ 'name' => 'restore', 'id' => 'mw-undelete-submit' ] - ) . ' ' . - Xml::submitButton( - $this->msg( 'undeleteinvert' )->text(), - [ 'name' => 'invert', 'id' => 'mw-undelete-invert' ] - ) . - " - " . - $unsuppressBox . - Xml::closeElement( 'table' ) . - Xml::closeElement( 'fieldset' ); - - $out->addHTML( $table ); + $fieldset = new OOUI\FieldsetLayout( [ + 'label' => $this->msg( 'undelete-fieldset-title' )->text(), + 'id' => 'mw-undelete-table', + 'items' => $fields, + ] ); + + $form->appendContent( + new OOUI\PanelLayout( [ + 'expanded' => false, + 'padded' => true, + 'framed' => true, + 'content' => $fieldset, + ] ), + new OOUI\HtmlSnippet( + Html::hidden( 'target', $this->mTarget ) . + Html::hidden( 'wpEditToken', $this->getUser()->getEditToken() ) + ) + ); } - $out->addHTML( Xml::element( 'h2', null, $this->msg( 'history' )->text() ) . "\n" ); + $history = ''; + $history .= Xml::element( 'h2', null, $this->msg( 'history' )->text() ) . "\n"; if ( $haveRevisions ) { # Show the page's stored (deleted) history if ( $this->getUser()->isAllowed( 'deleterevision' ) ) { - $out->addHTML( Html::element( + $history .= Html::element( 'button', [ 'name' => 'revdel', @@ -803,31 +826,31 @@ class SpecialUndelete extends SpecialPage { 'class' => 'deleterevision-log-submit mw-log-deleterevision-button' ], $this->msg( 'showhideselectedversions' )->text() - ) . "\n" ); + ) . "\n"; } - $out->addHTML( ''; } else { $out->addWikiMsg( 'nohistory' ); } if ( $haveFiles ) { - $out->addHTML( Xml::element( 'h2', null, $this->msg( 'filehist' )->text() ) . "\n" ); - $out->addHTML( ''; } if ( $this->mAllowed ) { @@ -835,9 +858,13 @@ class SpecialUndelete extends SpecialPage { $misc = Html::hidden( 'target', $this->mTarget ); $misc .= Html::hidden( 'wpEditToken', $this->getUser()->getEditToken() ); $misc .= Xml::closeElement( 'form' ); - $out->addHTML( $misc ); + $history .= $misc; } + $form->appendContent( new OOUI\HtmlSnippet( $history ) ); + + $out->addHTML( $form ); + return true; } diff --git a/resources/src/mediawiki.special/mediawiki.special.undelete.js b/resources/src/mediawiki.special/mediawiki.special.undelete.js index 2a153e8864..4629d57a21 100644 --- a/resources/src/mediawiki.special/mediawiki.special.undelete.js +++ b/resources/src/mediawiki.special/mediawiki.special.undelete.js @@ -2,10 +2,9 @@ * JavaScript for Special:Undelete */ jQuery( function ( $ ) { - $( '#mw-undelete-invert' ).click( function ( e ) { - $( '#undelete input[type="checkbox"]' ).prop( 'checked', function ( i, val ) { + $( '#mw-undelete-invert' ).click( function () { + $( '.mw-undelete-revlist input[type="checkbox"]' ).prop( 'checked', function ( i, val ) { return !val; } ); - e.preventDefault(); } ); } ); -- 2.20.1