[WIP] Reject work

This commit is contained in:
Daniel Glus 2018-08-02 15:34:30 -04:00
parent a0ca7cb280
commit 57175f0f4d
4 changed files with 69 additions and 14 deletions

View File

@ -264,7 +264,7 @@
}
/*
Since we're hacking this dynamic suggestion feature into
Since we are hacking this dynamic suggestion feature into
jquery.chosen, we have to manually set the width of the input.
(see "Offer dynamic category suggestions" in submissions.js)
*/
@ -283,11 +283,11 @@
padding-top: 5px;
}
#declineTextareaPreviewTrigger {
#previewTrigger {
font-size: 80%;
}
#declineTextareaPreview {
#previewContainer {
border: thin dotted gray;
width: 50%;
margin: 0.5em auto;
@ -295,9 +295,16 @@
padding: 0 0.5em;
}
#declineTextareaPreview:empty {
#previewContainer:empty {
display: none;
}
#declineRejectWrapper{
font-size: 120%;
padding: 0;
border: 0;
margin: 0 0 .5em 0;
}
}
/* COMMENT */

View File

@ -1315,6 +1315,10 @@
* converting checkboxes to bools, providing textual values of select
* elements, ignoring placeholder elements, and more.
*
* For a radio button group, pass in the container element, which must
* be a fieldset with the appropriate "name" attribute. Its id will
* be used as the key in the data object.
*
* @param {jQuery} $selector elements to get values from
* @return {object} object of values, with the ids as keys
*/
@ -1327,6 +1331,8 @@
if ( element.type === 'checkbox' ) {
value = element.checked;
} else if ( element.type === 'fieldset' ) {
value = $element.find( ':checked' ).val();
} else {
value = $element.val();

View File

@ -1621,6 +1621,18 @@
max_selected_options: 2
} );
// Set up jquery.chosen for the reject reason
$afch.find( '#rejectReason' ).chosen( {
placeholder_text_single: 'Select a reject reason...',
search_contains: true,
inherit_select_classes: true,
max_selected_options: 2
} );
// rejectReason starts off hidden by default, which makes the _chosen div
// display at 0px wide for some reason. We must manually fix this.
$afch.find( '#rejectReason_chosen' ).css( 'width', '350px' );
// And now add the handlers for when a specific decline reason is selected
$afch.find( '#declineReason' ).change( function () {
var reason = $afch.find( '#declineReason' ).val(),
@ -1706,15 +1718,15 @@
$afch.find( '#declineTextarea' ).val( prevDeclineComment );
// If the user wants a preview, show it
if ( $( '#declineTextareaPreviewTrigger' ).text() == '(hide preview)' ) {
$( '#declineTextareaPreview' )
if ( $( '#previewTrigger' ).text() == '(hide preview)' ) {
$( '#previewContainer' )
.empty()
.append( $.createSpinner( {
size: 'large',
type: 'block'
} ).css( 'padding', '20px' ) );
AFCH.getReason( reason ).done( function ( html ) {
$( '#declineTextareaPreview' ).html( html );
$( '#previewContainer' ).html( html );
} );
}
@ -1725,10 +1737,10 @@
} ); // End change handler for the reason select box
// Attach the preview event listener
$afch.find( '#declineTextareaPreviewTrigger' ).click( function () {
$afch.find( '#previewTrigger' ).click( function () {
var reason = $afch.find( '#declineReason' ).val();
if ( this.textContent == '(preview)' && reason ) {
$( '#declineTextareaPreview' )
$( '#previewContainer' )
.empty()
.append( $.createSpinner( {
size: 'large',
@ -1736,17 +1748,26 @@
} ).css( 'padding', '20px' ) );
var reasonDeferreds = reason.map( AFCH.getReason );
$.when.apply( $, reasonDeferreds ).then( function ( a, b ) {
$( '#declineTextareaPreview' )
$( '#previewContainer' )
.html( Array.prototype.slice.call( arguments )
.join( '<hr />' ) );
} );
this.textContent = '(hide preview)';
} else {
$( '#declineTextareaPreview' ).empty();
$( '#previewContainer' ).empty();
this.textContent = '(preview)';
}
} );
} );
// Attach the decline vs reject radio button listener
$afch.find( 'input[type=radio][name=declineReject]' ).click( function () {
var declineOrReject = $afch.find( 'input[name=declineReject]:checked' ).val();
$afch.find( '#declineReasonWrapper' ).toggleClass( 'hidden', declineOrReject === 'reject' );
$afch.find( '#rejectReasonWrapper' ).toggleClass( 'hidden', declineOrReject === 'decline' );
$afch.find( '#declineInputWrapper' ).toggleClass( 'hidden', declineOrReject === 'reject' );
$afch.find( '#rejectInputWrapper' ).toggleClass( 'hidden', declineOrReject === 'decline' );
} );
} ); // End loadView callback
addFormSubmitHandler( handleDecline );
}

View File

@ -190,6 +190,14 @@
<div class="header">Declining...</div>
<div id="afchContent" class="content centered">
<fieldset id="declineRejectWrapper" class="radioContainer afch-input" name="declineReject">
<input type="radio" id="declineRejectDecline" name="declineReject" value="decline" checked />
<label for="declineRejectDecline"><b>Decline</b> (for later improvement &amp; resubmission)</label>
&emsp;
<input type="radio" id="declineRejectReject" name="declineReject" value="reject" />
<label for="declineRejectReject"><b>Reject</b> (unsuitable topic; no option to resubmit)</label>
</fieldset>
<div id="declineReasonWrapper">
<select id="declineReason" class="afch-input text-left" multiple="multiple">
<option value=""></option>
@ -239,8 +247,19 @@
<option value="mergeto">mergeto - Submission should be merged into an existing article</option>
</optgroup>
</select>
<a id="declineTextareaPreviewTrigger" class="link" role="button">(preview)</a>
<div id="declineTextareaPreview"></div>
</div>
<div id="rejectReasonWrapper" class="hidden">
<select id="rejectReason" class="afch-input text-left" multiple="multiple">
<option value=""></option>
<option value="n">n - Topic is not notable</option>
<option value="e">e - Topic is contrary to the purpose of Wikipedia</option>
</select>
</div>
<div id="previewWrapper">
<a id="previewTrigger" class="link" role="button">(preview)</a>
<div id="previewContainer"></div>
</div>
<div id="declineInputWrapper">
@ -282,6 +301,8 @@
</div>
</div>
<div id="rejectInputWrapper" class="hidden">asdf</div>
<div id="afchSubmitForm" data-running="Declining submission..." class="gradient-button button-centered decline hidden">Decline submission</div>
</div>