Soeren.oldag has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/218335

Change subject: Few fixes and error handling for JS.
......................................................................

Few fixes and error handling for JS.

Change-Id: I0ae873d4003b846d8446b1eda9261ebc851fe48c
---
M WikibaseQuality.php
M i18n/en.json
M i18n/qqq.json
M modules/ext.WikibaseQuality.SpecialViolationsPage.js
M modules/ext.WikibaseQuality.UiScript.js
5 files changed, 19 insertions(+), 8 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataQuality 
refs/changes/35/218335/1

diff --git a/WikibaseQuality.php b/WikibaseQuality.php
index 64d565c..ec03c87 100755
--- a/WikibaseQuality.php
+++ b/WikibaseQuality.php
@@ -44,7 +44,8 @@
             'wbq-violations-status-violation',
             'wbq-violations-status-exception',
             'wbq-violations-mark-as-violation',
-            'wbq-violations-mark-as-exception'
+            'wbq-violations-mark-as-exception',
+                       'wbq-violations-permission-denied'
         )
        );
 
diff --git a/i18n/en.json b/i18n/en.json
index dda2e06..5d25db0 100755
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -35,6 +35,7 @@
   "wbq-violations-mark-as-violation": "Mark as violation",
   "wbq-violations-next-page": "Next page >>",
   "wbq-violations-prev-page": "<< Previous page",
+  "wbq-violations-permission-denied": "You do not have the permission to 
change this violation!",
 
   "apihelp-wbqgetviolationmessages-description": "Gets messages for data 
violations on claims.",
   "apihelp-wbqgetviolationmessages-param-entityid": "ID of an entity, whose 
data violations should be listed.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 85de388..51efe04 100755
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -36,6 +36,7 @@
        "wbq-violations-mark-as-violation": "Message that is shown for marking 
a excepted violation as violation on violation special page.",
        "wbq-violations-next-page": "Message that is shown as link to next 
page.",
        "wbq-violations-prev-page": "Message that is shown as link to previous 
page.",
+    "wbq-violations-permission-denied": "Message that is shown, if the user 
wants to change a violation, but do not have the permissions for that.",
        "apihelp-wbqgetviolationmessages-description": 
"{{doc-apihelp-description|wbqgetviolationmessages}}",
        "apihelp-wbqgetviolationmessages-param-entityid": 
"{{doc-apihelp-param|wbqgetviolationmessages|entityid}}",
        "apihelp-wbqgetviolationmessages-example": 
"{{doc-apihelp-example|wbqgetviolationmessages}}",
diff --git a/modules/ext.WikibaseQuality.SpecialViolationsPage.js 
b/modules/ext.WikibaseQuality.SpecialViolationsPage.js
index 309ec98..a5ddaa1 100644
--- a/modules/ext.WikibaseQuality.SpecialViolationsPage.js
+++ b/modules/ext.WikibaseQuality.SpecialViolationsPage.js
@@ -29,10 +29,10 @@
                 var newStatus = oldStatus == 'violation' ? 'exception' : 
'violation';
                 var statusCell = $(this).closest('td');
 
-                api.get({
+                api.postWithToken('edit', {
                     action: 'wbqmodifyviolation',
-                    claimGuid: claimGuid,
-                    constraintId: constraintId,
+                    claimguid: claimGuid,
+                    constraintid: constraintId,
                     status: newStatus,
                     format: 'json'
                 }).done(function () {
@@ -43,15 +43,19 @@
                     }
                     else {
                         var statusSpan = 
statusCell.find('.wbq-violations-status').first();
-                        statusSpan.text(mw.message('wbq-violations-status-' + 
newStatus).text());
+                        statusSpan.text(mw.message('wbq-violations-status-' + 
newStatus).escaped());
 
                         var toggleStatusClones = 
statusCell.find('.wbq-violations-toggle-status');
                         toggleStatusClones.data('status', newStatus);
 
                         var toggleStatusLink = toggleStatusClones.first();
-                        
toggleStatusLink.text(mw.message('wbq-violations-mark-as-' + oldStatus).text());
+                        
toggleStatusLink.text(mw.message('wbq-violations-mark-as-' + 
oldStatus).escaped());
                         toggleStatusLink.data( 'jquery-confirmable-width', 
toggleStatusLink.width() );
                     }
+                }).fail( function (errorCode) {
+                    if(errorCode == 'permissiondenied') {
+                        
alert(mw.message('wbq-violations-permission-denied').text());
+                    }
                 });
             }
         });
diff --git a/modules/ext.WikibaseQuality.UiScript.js 
b/modules/ext.WikibaseQuality.UiScript.js
index 65ddf42..0d24026 100755
--- a/modules/ext.WikibaseQuality.UiScript.js
+++ b/modules/ext.WikibaseQuality.UiScript.js
@@ -77,10 +77,14 @@
     anchor.parent().find( '.wbq-mark-as-exception' ).confirmable( {
         handler: function ( e ) {
             e.preventDefault();
-            api.post( modify_exception_data ).done( function () {
+            api.postWithToken( 'edit', modify_exception_data ).done( function 
() {
                anchor.parent().find( '#wbq-violation-msg-' + 
claim_guid_index.replace('$', '\\$') ).remove();
                anchor.find( '#wbq-violation-img-' + 
claim_guid_index.replace('$', '\\$') ).remove();
-            } );
+            } ).fail( function (errorCode) {
+                if(errorCode == 'permissiondenied') {
+                    
alert(mw.message('wbq-violations-permission-denied').text());
+                }
+            });
         }
     } );
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ae873d4003b846d8446b1eda9261ebc851fe48c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikidataQuality
Gerrit-Branch: master
Gerrit-Owner: Soeren.oldag <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to