Dominic.sauer has submitted this change and it was merged. 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, 84 insertions(+), 73 deletions(-) Approvals: Dominic.sauer: Verified; Looks good to me, approved diff --git a/WikibaseQuality.php b/WikibaseQuality.php index 64d565c..d7f350c 100755 --- a/WikibaseQuality.php +++ b/WikibaseQuality.php @@ -31,30 +31,31 @@ $GLOBALS['wgSpecialPages']['Violations'] = array( 'WikibaseQuality\SpecialPageFactory', 'newSpecialViolationsPage' ); // Define modules - $remoteExtPathParts = explode( - DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR, __DIR__, 2 - ); + $remoteExtPathParts = explode( + DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR, __DIR__, 2 + ); $GLOBALS['wgResourceModules']['SpecialViolationsPage'] = array ( 'styles' => '/modules/ext.WikibaseQuality.SpecialViolationsPage.css', - 'scripts' => '/modules/ext.WikibaseQuality.SpecialViolationsPage.js', - 'dependencies' => array( 'jquery.confirmable' ), + 'scripts' => '/modules/ext.WikibaseQuality.SpecialViolationsPage.js', + 'dependencies' => array( 'jquery.confirmable' ), 'localBasePath' => __DIR__, 'remoteExtPath' => $remoteExtPathParts[1], - 'messages' => array( - 'wbq-violations-status-violation', - 'wbq-violations-status-exception', - 'wbq-violations-mark-as-violation', - 'wbq-violations-mark-as-exception' - ) + 'messages' => array( + 'wbq-violations-status-violation', + 'wbq-violations-status-exception', + 'wbq-violations-mark-as-violation', + 'wbq-violations-mark-as-exception', + 'wbq-violations-permission-denied' + ) ); - $GLOBALS['wgResourceModules']['ext.WikibaseQuality.UiScript'] = array( - 'scripts' => 'modules/ext.WikibaseQuality.UiScript.js', - 'styles' => 'modules/ext.WikibaseQuality.UiScript.css', - 'dependencies' => array( 'jquery.confirmable' ), - 'localBasePath' => __DIR__, - 'remoteExtPath' => $remoteExtPathParts[1] - ); + $GLOBALS['wgResourceModules']['ext.WikibaseQuality.UiScript'] = array( + 'scripts' => 'modules/ext.WikibaseQuality.UiScript.js', + 'styles' => 'modules/ext.WikibaseQuality.UiScript.css', + 'dependencies' => array( 'jquery.confirmable' ), + 'localBasePath' => __DIR__, + 'remoteExtPath' => $remoteExtPathParts[1] + ); // Register hooks for QUnit Tests $GLOBALS['wgHooks']['ResourceLoaderTestModules'][] = function( array &$testModules, \ResourceLoader &$resourceLoader ) { diff --git a/i18n/en.json b/i18n/en.json index dda2e06..ed4eeb2 100755 --- a/i18n/en.json +++ b/i18n/en.json @@ -1,54 +1,55 @@ { - "@metadata": { - "authors": "BP2014N1" - }, - "wbq-desc": "Base extension for wikibase quality extensions that manages found incorrect data", - "specialpages-group-wikibasequality": "Wikibase Quality", + "@metadata": { + "authors": "BP2014N1" + }, + "wbq-desc": "Base extension for wikibase quality extensions that manages found incorrect data", + "specialpages-group-wikibasequality": "Wikibase Quality", - "wbq-violations-description": "List of data quality issues", - "wbq-violations-explanations-general": "This special page lists all data quality issues that were detected in Wikidata. Such issues may be violations against defined constraints or mismatches with other external databases. ", - "wbq-violations-explanations-exceptions": "If a statement is incorrectly labeled as a data quality issue, it can be marked as exception by privileged users. Those exceptions are not shown in the list per default. Existing exceptions can also be reverted and set as issue again. ", - "wbq-violatons-filter-headline": "Filter issues", - "wbq-violations-entity-id-label": "Entity ID:", - "wbq-violations-entity-id-placeholder": "Qxx/Pxx", - "wbq-violations-property-id-label": "Property ID:", - "wbq-violations-property-id-placeholder": "Pxx", - "wbq-violations-group-label": "Group:", - "wbq-violations-type-label": "Type:", - "wbq-violations-form-select-all": "(all)", - "wbq-violations-exceptions-checkbox-label": "Show exceptions", - "wbq-violations-submit-button-label": "Show Violations", - "wbq-violations-invalid-entity-id": "Given entity ID is not a valid.", - "wbq-violations-not-existent-entity": "Entity with given ID does not exist.", - "wbq-violations-invalid-property-id": "Given property ID is not valid.", - "wbq-violations-not-existent-property": "Property with given ID does not exist.", - "wbq-violations-table-header-entity": "Entity", - "wbq-violations-table-header-claim": "Claim", - "wbq-violations-table-header-constraint-type": "Type", - "wbq-violations-table-header-updated-at": "Last updated", - "wbq-violations-table-header-status": "Status", - "wbq-violations-table-header-additional-info": "Additional information", - "wbq-violations-status-violation": "Violation", - "wbq-violations-status-unverified": "Unverified", - "wbq-violations-status-exception": "Exception", - "wbq-violations-mark-as-exception": "Mark as exception", - "wbq-violations-mark-as-violation": "Mark as violation", - "wbq-violations-next-page": "Next page >>", - "wbq-violations-prev-page": "<< Previous page", + "wbq-violations-description": "List of data quality issues", + "wbq-violations-explanations-general": "This special page lists all data quality issues that were detected in Wikidata. Such issues may be violations against defined constraints or mismatches with other external databases. ", + "wbq-violations-explanations-exceptions": "If a statement is incorrectly labeled as a data quality issue, it can be marked as exception by privileged users. Those exceptions are not shown in the list per default. Existing exceptions can also be reverted and set as issue again. ", + "wbq-violatons-filter-headline": "Filter issues", + "wbq-violations-entity-id-label": "Entity ID:", + "wbq-violations-entity-id-placeholder": "Qxx/Pxx", + "wbq-violations-property-id-label": "Property ID:", + "wbq-violations-property-id-placeholder": "Pxx", + "wbq-violations-group-label": "Group:", + "wbq-violations-type-label": "Type:", + "wbq-violations-form-select-all": "(all)", + "wbq-violations-exceptions-checkbox-label": "Show exceptions", + "wbq-violations-submit-button-label": "Show Violations", + "wbq-violations-invalid-entity-id": "Given entity ID is not a valid.", + "wbq-violations-not-existent-entity": "Entity with given ID does not exist.", + "wbq-violations-invalid-property-id": "Given property ID is not valid.", + "wbq-violations-not-existent-property": "Property with given ID does not exist.", + "wbq-violations-table-header-entity": "Entity", + "wbq-violations-table-header-claim": "Claim", + "wbq-violations-table-header-constraint-type": "Type", + "wbq-violations-table-header-updated-at": "Last updated", + "wbq-violations-table-header-status": "Status", + "wbq-violations-table-header-additional-info": "Additional information", + "wbq-violations-status-violation": "Violation", + "wbq-violations-status-unverified": "Unverified", + "wbq-violations-status-exception": "Exception", + "wbq-violations-mark-as-exception": "Mark as exception", + "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.", - "apihelp-wbqgetviolationmessages-example": "Get messages for data violations of item Q76. ", + "apihelp-wbqgetviolationmessages-description": "Gets messages for data violations on claims.", + "apihelp-wbqgetviolationmessages-param-entityid": "ID of an entity, whose data violations should be listed.", + "apihelp-wbqgetviolationmessages-example": "Get messages for data violations of item Q76. ", - "apihelp-wbqmodifyviolation-description": "Modifies a specific data violations. Keep in mind, that only users with specific rights can modify violations. ", - "apihelp-wbqmodifyviolation-param-claimguid": "The claim guid of the data violation, that should be modified. Together with constraintid this identifies the violation.", - "apihelp-wbqmodifyviolation-param-constraintid": "The constraint id of the data violation, that should be modified. Together with claimguid this identifies the violation.", - "apihelp-wbqmodifyviolation-param-status": "The new status, that should be set for this violation.", - "apihelp-wbqmodifyviolation-examples-exception": "Change status of the violation identified by constraint id and claim GUID to exception.", - "apihelp-wbqmodifyviolation-examples-violation": "Change status of the violation identified by constraint id and claim GUID to violation.", + "apihelp-wbqmodifyviolation-description": "Modifies a specific data violations. Keep in mind, that only users with specific rights can modify violations. ", + "apihelp-wbqmodifyviolation-param-claimguid": "The claim guid of the data violation, that should be modified. Together with constraintid this identifies the violation.", + "apihelp-wbqmodifyviolation-param-constraintid": "The constraint id of the data violation, that should be modified. Together with claimguid this identifies the violation.", + "apihelp-wbqmodifyviolation-param-status": "The new status, that should be set for this violation.", + "apihelp-wbqmodifyviolation-examples-exception": "Change status of the violation identified by constraint id and claim GUID to exception.", + "apihelp-wbqmodifyviolation-examples-violation": "Change status of the violation identified by constraint id and claim GUID to violation.", - "apihelp-wbqgetviolationtypes-description": "Returns a list of all supported violation types.", - "apihelp-wbqgetviolationtypes-param-groupid": "Optional parameter, that restricts the violation types to the ones associated with given group.", - "apihelp-wdqgetviolationtypes-examples-1": "Returns all supported violation types without restrictions.", - "apihelp-wdqgetviolationtypes-examples-2": "Returns all supported violation type that are associated with the group \"wbqc\". " + "apihelp-wbqgetviolationtypes-description": "Returns a list of all supported violation types.", + "apihelp-wbqgetviolationtypes-param-groupid": "Optional parameter, that restricts the violation types to the ones associated with given group.", + "apihelp-wdqgetviolationtypes-examples-1": "Returns all supported violation types without restrictions.", + "apihelp-wdqgetviolationtypes-examples-2": "Returns all supported violation type that are associated with the group \"wbqc\". " } diff --git a/i18n/qqq.json b/i18n/qqq.json index 85de388..63bbd92 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: merged Gerrit-Change-Id: I0ae873d4003b846d8446b1eda9261ebc851fe48c Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/WikidataQuality Gerrit-Branch: master Gerrit-Owner: Soeren.oldag <soeren_ol...@freenet.de> Gerrit-Reviewer: Dominic.sauer <dominic.sa...@yahoo.de> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: Tamslo <tamaraslosa...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits