Skip to content

Commit 3d552a7

Browse files
cci: force completion before archiving
1 parent 7a3ac05 commit 3d552a7

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

i18n/core/en.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
"deputy.session.section.close": "Archive section",
2626
"deputy.session.section.closeComments": "Archiving comments",
2727
"deputy.session.section.closeHelp": "Your signature will automatically be included.",
28-
"deputy.session.section.closeWarning": "Some revisions remain unassessed. You may want to mark these revisions as assessed before archiving this section.",
28+
"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

3131
"deputy.session.section.stop": "Stop session",
3232
"deputy.session.section.saved": "Section saved",
3333
"deputy.session.section.failed": "Failed to save section",
3434
"deputy.session.section.missingSection": "The target section is missing from the case page.",
35+
"deputy.session.section.sectionIncomplete": "The target section still has unreviewed rows.",
3536
"deputy.session.section.conflict.title": "Edit conflict",
3637
"deputy.session.section.conflict.help": "Someone else edited the page before you. Deputy will restart to load the new case content. Your changes will be preserved.",
3738

@@ -64,6 +65,7 @@
6465
"deputy.session.row.checked.talk": "talk",
6566
"deputy.session.row.checked.contribs": "contribs",
6667

68+
"deputy.session.revision.assessed": "Mark as assessed",
6769
"deputy.session.revision.cur": "cur",
6870
"deputy.session.revision.prev": "prev",
6971
"deputy.session.revision.cur.tooltip": "Difference with latest revision",

src/ui/root/DeputyContributionSurveySection.tsx

+16-11
Original file line numberDiff line numberDiff line change
@@ -416,14 +416,10 @@ export default class DeputyContributionSurveySection implements DeputyUIElement
416416
*/
417417
async save( sectionId: number ): Promise<any | false> {
418418
if ( sectionId == null ) {
419-
mw.notify(
420-
mw.msg( 'deputy.session.section.missingSection' ),
421-
{
422-
autoHide: false,
423-
title: mw.msg( 'deputy.session.section.failed' ),
424-
type: 'error'
425-
}
426-
);
419+
throw new Error( mw.msg( 'deputy.session.section.missingSection' ) );
420+
}
421+
if ( this.closed && this.rows.some( r => !r.completed ) ) {
422+
throw new Error( mw.msg( 'deputy.session.section.sectionIncomplete' ) );
427423
}
428424

429425
return MwApi.action.postWithEditToken( {
@@ -586,6 +582,12 @@ export default class DeputyContributionSurveySection implements DeputyUIElement
586582
}
587583
}
588584
}, ( error ) => {
585+
OO.ui.alert(
586+
error.message,
587+
{
588+
title: mw.msg( 'deputy.session.section.failed' )
589+
}
590+
);
589591
console.error( error );
590592
saveContainer.classList.remove( 'active' );
591593
this.setDisabled( false );
@@ -597,12 +599,14 @@ export default class DeputyContributionSurveySection implements DeputyUIElement
597599

598600
const closingWarning = DeputyMessageWidget( {
599601
classes: [ 'dp-cs-section-unfinishedWarning' ],
600-
type: 'warning',
601-
label: mw.msg( 'deputy.session.section.closeWarning' )
602+
type: 'error',
603+
label: mw.msg( 'deputy.session.section.closeError' )
602604
} );
603605
closingWarning.toggle( false );
604606
const updateClosingWarning = ( () => {
605-
closingWarning.toggle( this.rows.some( ( row ) => !row.completed ) );
607+
const incomplete = this.rows.some( ( row ) => !row.completed );
608+
this.saveButton.setDisabled( incomplete );
609+
closingWarning.toggle( incomplete );
606610
} );
607611

608612
const closingCommentsField = new OO.ui.FieldLayout( this.closingComments, {
@@ -632,6 +636,7 @@ export default class DeputyContributionSurveySection implements DeputyUIElement
632636
} );
633637
} else {
634638
closingWarning.toggle( false );
639+
this.saveButton.setDisabled( false );
635640
this.rows.forEach( ( row ) => {
636641
row.removeEventListener( 'update', updateClosingWarning );
637642
} );

0 commit comments

Comments
 (0)