Jonas Kress (WMDE) has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/362277 )
Change subject: Introduce restore query button ...................................................................... Introduce restore query button Allows restoring query from local storage when browser is closed or clear pressed by accident Change-Id: I81e140ea592be69870c6ef0f1f3e364000e73d83 --- M i18n/en.json M i18n/qqq.json M index.html M wikibase/queryService/ui/App.js M wikibase/queryService/ui/editor/Editor.js 5 files changed, 14 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui refs/changes/77/362277/1 diff --git a/i18n/en.json b/i18n/en.json index 7949809..81ae954 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -15,6 +15,7 @@ "wdqs-app-button-run-title": "Execute query (<CTRL> + <ENTER>)", "wdqs-app-button-clear": "Clear", "wdqs-app-button-clear-title": "Clear query", + "wdqs-app-button-restore-title": "Restore previous query", "wdqs-app-button-display": "Display", "wdqs-app-button-display-title": "Display result as table, image, ...", "wdqs-app-button-download": "Download", diff --git a/i18n/qqq.json b/i18n/qqq.json index 7bf5fd7..4690fe8 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -17,6 +17,7 @@ "wdqs-app-button-run-title": "Title for button to run SPARQL query", "wdqs-app-button-clear": "Button to clear SPARQL query editor\n{{Identical|Clear}}", "wdqs-app-button-clear-title": "Title for button to clear SPARQL query editor", + "wdqs-app-button-restore-title": "Title for button to restore SPARQL query in editor", "wdqs-app-button-display": "Button display result as table, image, ...\n{{Identical|Display}}", "wdqs-app-button-display-title": "Title for button display result as table, image, ...", "wdqs-app-button-download": "Button download result\n{{Identical|Download}}", diff --git a/index.html b/index.html index 3483c77..c657254 100644 --- a/index.html +++ b/index.html @@ -115,6 +115,10 @@ </a> </div> <div> + <a class="btn restore" data-toggle="tooltip" data-placement="top" data-i18n="[title]wdqs-app-button-restore-title"> <span class="fa fa-history" aria-hidden="true"></span> + </a> + </div> + <div> <a class="btn" id="clear-button" data-toggle="tooltip" data-placement="top" data-i18n="[title]wdqs-app-button-clear-title"> <span class="fa fa-trash-o" aria-hidden="true"></span> </a> </div> diff --git a/wikibase/queryService/ui/App.js b/wikibase/queryService/ui/App.js index 5089eb2..84a8d05 100644 --- a/wikibase/queryService/ui/App.js +++ b/wikibase/queryService/ui/App.js @@ -356,6 +356,11 @@ $( '.explorer-panel' ).hide(); } ); + $( '.restore' ).click( function( e ) { + e.preventDefault(); + self._editor.restoreValue(); + } ); + $( window ).on( 'popstate', $.proxy( this._initQuery, this ) ); this._initPopovers(); diff --git a/wikibase/queryService/ui/editor/Editor.js b/wikibase/queryService/ui/editor/Editor.js index 092956b..d35d2e5 100644 --- a/wikibase/queryService/ui/editor/Editor.js +++ b/wikibase/queryService/ui/editor/Editor.js @@ -92,7 +92,9 @@ this._editor = CodeMirror.fromTextArea( element, CODEMIRROR_DEFAULTS ); this._editor.on( 'change', function( editor, changeObj ) { - self.storeValue( self.getValue() ); + if ( self.getValue() !== '' ) { + self.storeValue( self.getValue() ); + } self.clearError(); if ( changeObj.text[0] === '?' || changeObj.text[0] === '#' ) { editor.showHint( { -- To view, visit https://gerrit.wikimedia.org/r/362277 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I81e140ea592be69870c6ef0f1f3e364000e73d83 Gerrit-PatchSet: 1 Gerrit-Project: wikidata/query/gui Gerrit-Branch: master Gerrit-Owner: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits