From: Jayprakash12345 <0freerunning@gmail.com> Date: Sat, 26 May 2018 19:25:24 +0000 (+0530) Subject: Convert file delete to use OOUI X-Git-Tag: 1.34.0-rc.0~4599^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=65a8e68ec07d7eed10d868f4338f29cbbcefa992;p=lhc%2Fweb%2Fwiklou.git Convert file delete to use OOUI Also make a few changes for consistency with normal delete form: * Add `autofocus` attribute on the "Other/additional reason" text field * Remove bold styling from "Suppress …" checkbox label * Remove `class="wpReasonDropDown"` from the "Reason" dropdown * Remove `id="wpDeleteSuppressRow"` from the "Suppress …" form row Bug: T173997 Change-Id: Ia5a0412c959c6149b01afe7fc6cbf5e8591673ac --- diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 898005ecc9..eb0052c7e4 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -79,7 +79,7 @@ class FileDeleteForm { $this->oldimage = $wgRequest->getText( 'oldimage', false ); $token = $wgRequest->getText( 'wpEditToken' ); # Flag to hide all contents of the archived revisions - $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' ); + $suppress = $wgRequest->getCheck( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' ); if ( $this->oldimage ) { $this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( @@ -249,101 +249,140 @@ class FileDeleteForm { $conf = RequestContext::getMain()->getConfig(); $oldCommentSchema = $conf->get( 'CommentTableSchemaMigrationStage' ) === MIGRATION_OLD; - if ( $wgUser->isAllowed( 'suppressrevision' ) ) { - $suppress = "
' . $link . '
'; - } - $wgOut->addHTML( $form ); + $fields[] = new OOUI\FieldLayout( + new OOUI\ButtonInputWidget( [ + 'name' => 'mw-filedelete-submit', + 'inputId' => 'mw-filedelete-submit', + 'tabIndex' => 4, + 'value' => $wgOut->msg( 'filedelete-submit' )->text(), + 'label' => $wgOut->msg( 'filedelete-submit' )->text(), + 'flags' => [ 'primary', 'destructive' ], + 'type' => 'submit', + ] ), + [ + 'align' => 'top', + ] + ); + + $fieldset = new OOUI\FieldsetLayout( [ + 'label' => $wgOut->msg( 'filedelete-legend' )->text(), + 'items' => $fields, + ] ); + + $form = new OOUI\FormLayout( [ + 'method' => 'post', + 'action' => $this->getAction(), + 'id' => 'mw-img-deleteconfirm', + ] ); + $form->appendContent( + $fieldset, + new OOUI\HtmlSnippet( + Html::hidden( 'wpEditToken', $wgUser->getEditToken( $this->oldimage ) ) + ) + ); + + $wgOut->addHTML( + new OOUI\PanelLayout( [ + 'classes' => [ 'deletepage-wrapper' ], + 'expanded' => false, + 'padded' => true, + 'framed' => true, + 'content' => $form, + ] ) + ); + + if ( $wgUser->isAllowed( 'editinterface' ) ) { + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); + $link = $linkRenderer->makeKnownLink( + $wgOut->msg( 'filedelete-reason-dropdown' )->inContentLanguage()->getTitle(), + wfMessage( 'filedelete-edit-reasonlist' )->text(), + [], + [ 'action' => 'edit' ] + ); + $wgOut->addHTML( '' . $link . '
' ); + } } /** diff --git a/resources/Resources.php b/resources/Resources.php index 4e0a452776..56dfaf9527 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1435,6 +1435,7 @@ return [ 'mediawiki.action.delete.file' => [ 'scripts' => 'resources/src/mediawiki.action/mediawiki.action.delete.file.js', 'dependencies' => [ + 'oojs-ui-core', 'jquery.lengthLimit', ], 'messages' => [ diff --git a/resources/src/mediawiki.action/mediawiki.action.delete.file.js b/resources/src/mediawiki.action/mediawiki.action.delete.file.js index 7dcdc81552..c282d6ac81 100644 --- a/resources/src/mediawiki.action/mediawiki.action.delete.file.js +++ b/resources/src/mediawiki.action/mediawiki.action.delete.file.js @@ -6,11 +6,11 @@ var colonSeparator = mw.message( 'colon-separator' ).text(), summaryCodePointLimit = mw.config.get( 'wgCommentCodePointLimit' ), summaryByteLimit = mw.config.get( 'wgCommentByteLimit' ), - $wpDeleteReasonList = $( '#wpDeleteReasonList' ), - $wpReason = $( '#wpReason' ), + reasonList = OO.ui.infuse( $( '#wpDeleteReasonList' ).closest( '.oo-ui-widget' ) ), + reason = OO.ui.infuse( $( '#wpReason' ).closest( '.oo-ui-widget' ) ), filterFn = function ( input ) { // Should be built the same as in SpecialRevisionDelete::submit() - var comment = $wpDeleteReasonList.val(); + var comment = reasonList.getValue(); if ( comment === 'other' ) { comment = input; } else if ( input !== '' ) { @@ -22,9 +22,9 @@ // Limit to bytes or UTF-8 codepoints, depending on MediaWiki's configuration if ( summaryCodePointLimit ) { - $wpReason.codePointLimit( summaryCodePointLimit, filterFn ); + reason.$input.codePointLimit( summaryCodePointLimit, filterFn ); } else if ( summaryByteLimit ) { - $wpReason.byteLimit( summaryByteLimit, filterFn ); + reason.$input.byteLimit( summaryByteLimit, filterFn ); } } );