jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/332399 )

Change subject: Added confirmation dialog to delete action.
......................................................................


Added confirmation dialog to delete action.

+ renamed unclear 'reinstate' to 'unflag'

Bug: T155324
Change-Id: I5bd74d2c22266acd1724a7d53f94096972fc657d
---
M QuestionGameHome.body.php
M extension.json
M i18n/en.json
M i18n/qqq.json
M js/QuizGame.js
5 files changed, 93 insertions(+), 54 deletions(-)

Approvals:
  Jack Phoenix: Looks good to me, approved
  SamanthaNguyen: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/QuestionGameHome.body.php b/QuestionGameHome.body.php
index 88303f8..36096ea 100644
--- a/QuestionGameHome.body.php
+++ b/QuestionGameHome.body.php
@@ -368,7 +368,7 @@
                                $buttons .= "<a class=\"protect-by-id\" 
href=\"#\" data-quiz-id=\"{$row->q_id}\" data-key=\"{$key}\">" .
                                        $this->msg( 'quizgame-protect' 
)->text() . "</a>
                                                 - <a class=\"unflag-by-id\" 
href=\"#\" data-quiz-id=\"{$row->q_id}\" data-key=\"{$key}\">" .
-                                                $this->msg( 
'quizgame-reinstate' )->text() . '</a>';
+                                                $this->msg( 'quizgame-unflag' 
)->text() . '</a>';
                        } else {
                                $buttons .= "<a class=\"unprotect-by-id\" 
href=\"#\" data-quiz-id=\"{$row->q_id}\" data-key=\"{$key}\">" .
                                        $this->msg( 'quizgame-unprotect' 
)->text() . '</a>';
diff --git a/extension.json b/extension.json
index 9ecf76e..d9359ec 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
        "name": "QuizGame",
-       "version": "3.4",
+       "version": "3.5",
        "author": [
                "Aaron Wright",
                "Ashish Datta",
@@ -81,11 +81,14 @@
                                "quizgame-lightbox-correct-points", 
"quizgame-lightbox-incorrect-correct",
                                "quizgame-create-edit-picture", "quizgame-edit",
                                "quizgame-ajax-nonnumeric-answer", 
"quizgame-ajax-already-answered",
-                               "quizgame-ajax-invalid-id"
+                               "quizgame-ajax-invalid-id", 
"quizgame-delete-confirm", "quizgame-delete",
+                               "quizgame-cancel", "quizgame-unflag", 
"quizgame-unflag-confirm"
                        ],
                        "dependencies": [
                                "ext.socialprofile.flash",
-                               "ext.socialprofile.LightBox"
+                               "ext.socialprofile.LightBox",
+                               "oojs-ui-core",
+                               "oojs-ui-windows"
                        ],
                        "position": "bottom"
                },
diff --git a/i18n/en.json b/i18n/en.json
index c0e0fec..6ef59b9 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -8,8 +8,11 @@
        "quizgame-desc": "Adds an interactive [[Special:QuizGameHome|question 
game]]",
        "quizgame-edit": "Edit",
        "quizgame-delete": "Delete",
+       "quizgame-delete-confirm": "Are you sure you want to delete this quiz 
game?",
+       "quizgame-cancel": "Cancel",
        "quizgame-protect": "Protect",
-       "quizgame-reinstate": "Re-instate",
+       "quizgame-unflag": "Un-flag",
+       "quizgame-unflag-confirm": "Are you sure you want to un-flag this quiz 
game?",
        "quizgame-unprotect": "Unprotect",
        "quizgame-admin-panel-title": "Admin panel",
        "quizgame-admin-back": "< Back to never ending quiz",
@@ -117,7 +120,7 @@
        "quizgame-ajax-invalid-key": "You need a valid key to do that.",
        "quizgame-ajax-unprotected": "The question has been un-protected.",
        "quizgame-ajax-protected": "The question has been protected.",
-       "quizgame-ajax-unflagged": "The question has been re-instated.",
+       "quizgame-ajax-unflagged": "The question has been un-flagged.",
        "quizgame-ajax-flagged": "The question has been flagged.",
        "quizgame-ajax-deleted": "The question was deleted.",
        "quizgame-ajax-invalid-option": "Invalid AJAX option.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 0885b05..a8476b8 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -5,8 +5,11 @@
     "quizgame-desc": 
"{{desc|name=QuizGame|url=https://www.mediawiki.org/wiki/Extension:QuizGame}}";,
     "quizgame-edit": "Link title",
     "quizgame-delete": "Link title",
+    "quizgame-delete-confirm": "Confirmation message shown in the delete 
dialog.",
+    "quizgame-cancel": "Cancel button message shown in dialogs",
     "quizgame-protect": "Link title",
-    "quizgame-reinstate": "Link title; reinstating returns a flagged quiz into 
the pool of available quizzes, allowing users to play it again",
+    "quizgame-unflag": "Link title; un-flagging returns a flagged quiz into 
the pool of available quizzes, allowing users to play it again",
+    "quizgame-unflag-confirm": "Confirmation message shown in the un-flag 
dialog",
     "quizgame-unprotect": "Link title",
     "quizgame-admin-panel-title": "Link title",
     "quizgame-admin-back": "Link title on the admin panel; clicking on this 
link takes you back to the question game from the administrative functions",
@@ -107,14 +110,14 @@
     "quizgame-create-threshold-reason": "Error message informing the user why 
they cannot create a quiz question when <code>$wgCreateQuizThresholds</code> is 
set; used together with the {{msg-mw|quizgame-create-threshold-title}} message",
     "quizgame-points": "$1 is the amount of points; \"pts\" (in the original 
English message) is an abbreviation of \"points\"",
     "quizgame-time-ago": "$1 is either one of the following or a combination 
of them:\n* {{msg-mw|quizgame-time-days}}\n* {{msg-mw|quizgame-time-hours}}\n* 
{{msg-mw|quizgame-time-minutes}}\n* {{msg-mw|quizgame-time-minutes}}\n\nExample 
output: 4 hours 15 minutes ago",
-       "quizgame-time-days": "number of days, followed by 
{{msg-mw|quizgame-time-ago}}",
-       "quizgame-time-hours": "number of hours, followed by 
{{msg-mw|quizgame-time-ago}}",
-       "quizgame-time-minutes": "number of minutes, followed by 
{{msg-mw|quizgame-time-ago}}",
-       "quizgame-time-seconds": "number of seconds, followed by 
{{msg-mw|quizgame-time-ago}}",
+    "quizgame-time-days": "number of days, followed by 
{{msg-mw|quizgame-time-ago}}",
+    "quizgame-time-hours": "number of hours, followed by 
{{msg-mw|quizgame-time-ago}}",
+    "quizgame-time-minutes": "number of minutes, followed by 
{{msg-mw|quizgame-time-ago}}",
+    "quizgame-time-seconds": "number of seconds, followed by 
{{msg-mw|quizgame-time-ago}}",
     "quizgame-ajax-invalid-key": "Shown via JavaScript if a user tries to 
perform administrative actions without a valid key (key in this context is the 
same as \"token\")",
     "quizgame-ajax-unprotected": "Shown via JavaScript after a question has 
been unprotected",
     "quizgame-ajax-protected": "Shown via JavaScript after a question has been 
protected.",
-    "quizgame-ajax-unflagged": "Shown via JavaScript after a question has been 
reinstated; reinstating returns a flagged quiz into the pool of available 
quizzes, allowing users to play it again",
+    "quizgame-ajax-unflagged": "Shown via JavaScript after a question has been 
un-flagged; un-flagging returns a flagged quiz into the pool of available 
quizzes, allowing users to play it again",
     "quizgame-ajax-flagged": "Shown via JavaScript after a question has been 
flagged; flagging marks the question as needing administrative review and 
temporarily removes it from the pool of available questions",
     "quizgame-ajax-deleted": "Shown via JavaScript after successfully deleting 
a question",
     "quizgame-ajax-invalid-option": "Shown via JavaScript if the user somehow 
tries to access an action that is not recognized by the backend API module",
diff --git a/js/QuizGame.js b/js/QuizGame.js
index 5055584..e65a053 100644
--- a/js/QuizGame.js
+++ b/js/QuizGame.js
@@ -21,39 +21,59 @@
        next_level: 0, // has to have an initial value; introduced by Jack
 
        deleteById: function( id, key ) {
-               document.getElementById( 'items[' + id + ']' ).style.display = 
'none';
-               document.getElementById( 'items[' + id + ']' ).style.visibility 
= 'hidden';
+               var options = {
+                       actions: [
+                               { label: mw.msg( 'quizgame-cancel' ) },
+                               { label: mw.msg( 'quizgame-delete' ), action: 
'accept', flags: ['destructive'] }
+                       ]
+               }
+               OO.ui.confirm( mw.msg( 'quizgame-delete-confirm' ), options 
).done( function ( confirmed ) {
+                       if ( confirmed ) {
+                               document.getElementById( 'items[' + id + ']' 
).style.display = 'none';
+                               document.getElementById( 'items[' + id + ']' 
).style.visibility = 'hidden';
 
-               jQuery.getJSON(
-                       mw.util.wikiScript( 'api' ), {
-                               format: 'json',
-                               action: 'quizgame',
-                               quizaction: 'deleteItem',
-                               key: key,
-                               id: id
-                       },
-                       function( data ) {
-                               document.getElementById( 'ajax-messages' 
).innerHTML = data.quizgame.output;
+                               jQuery.getJSON(
+                                       mw.util.wikiScript( 'api' ), {
+                                               format: 'json',
+                                               action: 'quizgame',
+                                               quizaction: 'deleteItem',
+                                               key: key,
+                                               id: id
+                                       },
+                                       function( data ) {
+                                               document.getElementById( 
'ajax-messages' ).innerHTML = data.quizgame.output;
+                                       }
+                               );
                        }
-               );
+               });
        },
 
        unflagById: function( id, key ) {
-               document.getElementById( 'items[' + id + ']' ).style.display = 
'none';
-               document.getElementById( 'items[' + id + ']' ).style.visibility 
= 'hidden';
+               var options = {
+                       actions: [
+                               { label: mw.msg( 'quizgame-cancel' ) },
+                               { label: mw.msg( 'quizgame-unflag' ), action: 
'accept', flags: ['constructive'] }
+                       ]
+               }
+               OO.ui.confirm( mw.msg( 'quizgame-unflag-confirm' ), options 
).done( function ( confirmed ) {
+                       if ( confirmed ) {
+                               document.getElementById( 'items[' + id + ']' 
).style.display = 'none';
+                               document.getElementById( 'items[' + id + ']' 
).style.visibility = 'hidden';
 
-               jQuery.getJSON(
-                       mw.util.wikiScript( 'api' ), {
-                               format: 'json',
-                               action: 'quizgame',
-                               quizaction: 'unflagItem',
-                               key: key,
-                               id: id
-                       },
-                       function( data ) {
-                               document.getElementById( 'ajax-messages' 
).innerHTML = data.quizgame.output;
+                               jQuery.getJSON(
+                                       mw.util.wikiScript( 'api' ), {
+                                               format: 'json',
+                                               action: 'quizgame',
+                                               quizaction: 'unflagItem',
+                                               key: key,
+                                               id: id
+                                       },
+                                       function( data ) {
+                                               document.getElementById( 
'ajax-messages' ).innerHTML = data.quizgame.output;
+                                       }
+                               );
                        }
-               );
+               });
        },
 
        unprotectById: function( id, key ) {
@@ -166,22 +186,32 @@
        },
 
        deleteQuestion: function() {
-               var gameKey = document.getElementById( 'quizGameKey' ).value;
-               var gameId = document.getElementById( 'quizGameId' ).value;
-               jQuery.getJSON(
-                       mw.util.wikiScript( 'api' ), {
-                               format: 'json',
-                               action: 'quizgame',
-                               quizaction: 'deleteItem',
-                               key: gameKey,
-                               id: gameId
-                       },
-                       function( data ) {
-                               document.getElementById( 'ajax-messages' 
).innerHTML = data.quizgame.output + '<br />' + mw.msg( 'quizgame-js-reloading' 
);
-                               document.location = mw.config.get( 
'wgScriptPath' ) +
-                                       
'/index.php?title=Special:QuizGameHome&questionGameAction=launchGame';
+               var options = {
+                       actions: [
+                               { label: mw.msg( 'quizgame-cancel' ) },
+                               { label: mw.msg( 'quizgame-delete' ), action: 
'accept', flags: ['destructive'] }
+                       ]
+               }
+               OO.ui.confirm( mw.msg( 'quizgame-delete-confirm' ), options 
).done( function ( confirmed ) {
+                       if ( confirmed ) {
+                               var gameKey = document.getElementById( 
'quizGameKey' ).value;
+                               var gameId = document.getElementById( 
'quizGameId' ).value;
+                               jQuery.getJSON(
+                                       mw.util.wikiScript( 'api' ), {
+                                               format: 'json',
+                                               action: 'quizgame',
+                                               quizaction: 'deleteItem',
+                                               key: gameKey,
+                                               id: gameId
+                                       },
+                                       function( data ) {
+                                               document.getElementById( 
'ajax-messages' ).innerHTML = data.quizgame.output + '<br />' + mw.msg( 
'quizgame-js-reloading' );
+                                               document.location = 
mw.config.get( 'wgScriptPath' ) +
+                                               
'/index.php?title=Special:QuizGameHome&questionGameAction=launchGame';
+                                       }
+                               );
                        }
-               );
+               } );
        },
 
        showEditMenu: function() {
@@ -756,4 +786,4 @@
                        } );
                } );
        }
-} );
\ No newline at end of file
+} );

-- 
To view, visit https://gerrit.wikimedia.org/r/332399
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5bd74d2c22266acd1724a7d53f94096972fc657d
Gerrit-PatchSet: 12
Gerrit-Project: mediawiki/extensions/QuizGame
Gerrit-Branch: master
Gerrit-Owner: Filip <r...@protonmail.com>
Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net>
Gerrit-Reviewer: MtDu <justin.d...@gmail.com>
Gerrit-Reviewer: SamanthaNguyen <samanthanguyen1...@gmail.com>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to