Skip to content

Commit c3aeba3

Browse files
cci: make section archive signing configurable
1 parent 621f913 commit c3aeba3

5 files changed

Lines changed: 61 additions & 23 deletions

File tree

i18n/core/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
"deputy.session.section.close": "Archive section",
2626
"deputy.session.section.closeComments": "Archiving comments",
27-
"deputy.session.section.closeHelp": "Your signature will automatically be included.",
27+
"deputy.session.section.closeCommentsSign": "Include my signature",
2828
"deputy.session.section.closeError": "Some revisions remain unassessed. You must mark these revisions as assessed before archiving this section.",
2929
"deputy.session.section.closeWarn": "You have unsaved changes. Close the section without saving?",
3030

i18n/settings/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
"deputy.setting.user.cci.signingBehavior.alwaysTraceLastOnly": "Always leave a trace, but sign the last row modified",
7171
"deputy.setting.user.cci.signingBehavior.lastOnly": "Only sign the last row modified (prevents assessor recognition)",
7272
"deputy.setting.user.cci.signingBehavior.never": "Never sign rows (prevents assessor recognition)",
73+
"deputy.setting.user.cci.signSectionArchive.name": "Sign by default when archiving CCI sections",
74+
"deputy.setting.user.cci.signSectionArchive.description": "If enabled, Deputy will enable the \"include my signature\" checkbox by default when archiving a CCI section.",
7375
"deputy.setting.user.cci.openOldOnContinue.name": "Open old versions on continue",
7476
"deputy.setting.user.cci.openOldOnContinue.description": "If enabled, all previously-open sections of a given case page will also be opened alongside the section where the \"continue CCI session\" link was clicked.",
7577

src/config/UserConfiguration.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ export default class UserConfiguration extends ConfigurationBase {
141141
ContributionSurveyRowSigningBehavior.Always
142142
)
143143
),
144+
signSectionArchive: new Setting<boolean, boolean>( {
145+
defaultValue: true,
146+
displayOptions: {
147+
type: 'checkbox'
148+
}
149+
} ),
144150
openOldOnContinue: new Setting<boolean, boolean>( {
145151
defaultValue: false,
146152
displayOptions: {

src/css/deputy.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ p.dp-messageWidget-message {
154154
padding: 8px;
155155
}
156156

157+
.dp-cs-section-closing {
158+
margin: 1em 1.75em;
159+
}
160+
157161
.dp-cs-section-progress {
158162
margin-top: 8px;
159163
max-height: 0;

src/ui/root/DeputyContributionSurveySection.tsx

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default class DeputyContributionSurveySection implements DeputyUIElement
4848
rowElements: ( HTMLElement | DeputyContributionSurveyRow )[];
4949
closingCheckbox: OO.ui.CheckboxInputWidget;
5050
closingComments: OO.ui.TextInputWidget;
51+
closingCommentsSign: OO.ui.CheckboxInputWidget;
5152
closeButton: OO.ui.ButtonWidget;
5253
reviewButton: OO.ui.ButtonWidget;
5354
saveButton: OO.ui.ButtonWidget;
@@ -160,15 +161,24 @@ export default class DeputyContributionSurveySection implements DeputyUIElement
160161
}
161162

162163
if ( this.closed ) {
163-
final.splice( 1, 0, msgEval(
164-
window.deputy.wikiConfig.cci.collapseTop.get(),
165-
( ( this.comments ?? '' ) + ' ~~~~' ).trim()
166-
).plain() );
164+
if ( this._section.originallyClosed ) {
165+
// TODO: Fix when not broken
166+
} else {
167+
let closingComments = ( this.comments ?? '' ).trim();
168+
if ( this.closingCommentsSign.isSelected() ) {
169+
closingComments += ' ~~~~';
170+
}
171+
172+
final.splice( 1, 0, msgEval(
173+
window.deputy.wikiConfig.cci.collapseTop.get(),
174+
closingComments
175+
).plain() );
167176

168-
if ( final[ final.length - 1 ].trim().length === 0 ) {
169-
final.pop();
177+
if ( final[ final.length - 1 ].trim().length === 0 ) {
178+
final.pop();
179+
}
180+
final.push( window.deputy.wikiConfig.cci.collapseBottom.get() );
170181
}
171-
final.push( window.deputy.wikiConfig.cci.collapseBottom.get() );
172182
}
173183

174184
return final.join( '\n' );
@@ -456,14 +466,17 @@ export default class DeputyContributionSurveySection implements DeputyUIElement
456466
}
457467

458468
/**
459-
* Toggles the closing comments input box. This will disable the input box AND
460-
* hide the element from view.
469+
* Toggles the closing comments input box and signature checkbox.
470+
* This will disable the input box AND hide the element from view.
461471
*
462472
* @param show
463473
*/
464-
toggleClosingComments( show: boolean ) {
474+
toggleClosingElements( show: boolean ) {
465475
this.closingComments.setDisabled( !show );
466476
this.closingComments.toggle( show );
477+
478+
this.closingCommentsSign.setDisabled( !show );
479+
this.closingCommentsSign.toggle( show );
467480
}
468481

469482
/**
@@ -477,6 +490,7 @@ export default class DeputyContributionSurveySection implements DeputyUIElement
477490
this.saveButton?.setDisabled( disabled );
478491
this.closingCheckbox?.setDisabled( disabled );
479492
this.closingComments?.setDisabled( disabled );
493+
this.closingCommentsSign?.setDisabled( disabled );
480494
this.rows?.forEach( ( row ) => row.setDisabled( disabled ) );
481495

482496
this.disabled = disabled;
@@ -557,6 +571,10 @@ export default class DeputyContributionSurveySection implements DeputyUIElement
557571
placeholder: mw.msg( 'deputy.session.section.closeComments' ),
558572
disabled: true
559573
} );
574+
this.closingCommentsSign = new OO.ui.CheckboxInputWidget( {
575+
selected: window.deputy.config.cci.signSectionArchive.get(),
576+
disabled: true
577+
} );
560578
this.closeButton = new OO.ui.ButtonWidget( {
561579
label: mw.msg( 'deputy.session.section.stop' )
562580
} );
@@ -674,6 +692,8 @@ export default class DeputyContributionSurveySection implements DeputyUIElement
674692
this.setDisabled( false );
675693
} );
676694

695+
// Section closing (archive/ctop) elements
696+
677697
const closingWarning = DeputyMessageWidget( {
678698
classes: [ 'dp-cs-section-unfinishedWarning' ],
679699
type: 'error',
@@ -688,23 +708,30 @@ export default class DeputyContributionSurveySection implements DeputyUIElement
688708

689709
const closingCommentsField = new OO.ui.FieldLayout( this.closingComments, {
690710
align: 'top',
691-
label: 'Closing comments',
711+
label: mw.msg( 'deputy.session.section.closeComments' ),
692712
invisibleLabel: true,
693-
help: mw.msg( 'deputy.session.section.closeHelp' ),
694713
helpInline: true,
695714
classes: [ 'dp-cs-section-closingCommentsField' ]
696715
} );
697-
// Hide by default.
698-
closingCommentsField.toggle( false );
699-
closingCommentsField.on( 'change', ( v: string ) => {
700-
this.comments = v;
716+
717+
const closingCommentsSignField = new OO.ui.FieldLayout( this.closingCommentsSign, {
718+
align: 'inline',
719+
label: mw.msg( 'deputy.session.section.closeCommentsSign' )
701720
} );
702721

703-
this.toggleClosingComments( false );
722+
const closingFields = <div
723+
class="dp-cs-section-closing"
724+
style={{ display: 'none' }}
725+
>
726+
{ unwrapWidget( closingCommentsField ) }
727+
{ unwrapWidget( closingCommentsSignField ) }
728+
</div>;
729+
730+
this.toggleClosingElements( false );
704731
this.closingCheckbox.on( 'change', ( v: boolean ) => {
705732
this.closed = v;
706-
closingCommentsField.toggle( v );
707-
this.toggleClosingComments( v );
733+
closingFields.style.display = v ? '' : 'none';
734+
this.toggleClosingElements( v );
708735

709736
if ( v ) {
710737
updateClosingWarning();
@@ -734,15 +761,14 @@ export default class DeputyContributionSurveySection implements DeputyUIElement
734761
<div style={{
735762
flex: '1',
736763
display: 'flex',
737-
flexDirection: 'column',
738-
justifyContent: 'center'
764+
flexDirection: 'column'
739765
}}>
740766
{ unwrapWidget( new OO.ui.FieldLayout( this.closingCheckbox, {
741767
align: 'inline',
742768
label: mw.msg( 'deputy.session.section.close' )
743769
} ) ) }
744770
{ unwrapWidget( closingWarning ) }
745-
{ unwrapWidget( closingCommentsField ) }
771+
{ closingFields }
746772
</div>
747773
<div style={{ display: 'flex', alignItems: 'end' }}>
748774
{ unwrapWidget( this.closeButton ) }

0 commit comments

Comments
 (0)