Jonas Kress (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/370452 )

Change subject: [DNM] My result browser template
......................................................................

[DNM] My result browser template

Change-Id: I0d30be7341b4bf0329ee4e2dc204c79400308113
---
M index.html
M wikibase/queryService/ui/ResultView.js
A wikibase/queryService/ui/resultBrowser/MyResultBrowser.js
3 files changed, 59 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/52/370452/1

diff --git a/index.html b/index.html
index dd55f21..f1b6f00 100644
--- a/index.html
+++ b/index.html
@@ -354,6 +354,7 @@
        <script 
src="wikibase/queryService/ui/resultBrowser/GraphResultBrowser.js"></script>
        <script 
src="wikibase/queryService/ui/resultBrowser/GraphResultBrowserNodeBrowser.js"></script>
        <script 
src="wikibase/queryService/ui/resultBrowser/PolestarResultBrowser.js"></script>
+       <script 
src="wikibase/queryService/ui/resultBrowser/MyResultBrowser.js"></script>
        <script src="wikibase/queryService/api/Sparql.js"></script>
        <script src="wikibase/queryService/api/QuerySamples.js"></script>
        <script src="wikibase/queryService/api/Wikibase.js"></script>
diff --git a/wikibase/queryService/ui/ResultView.js 
b/wikibase/queryService/ui/ResultView.js
index f54a3de..28b497e 100644
--- a/wikibase/queryService/ui/ResultView.js
+++ b/wikibase/queryService/ui/ResultView.js
@@ -74,6 +74,13 @@
         * @private
         */
        SELF.prototype._resultBrowsers = {
+               MyTest: {
+                       icon: 'glyphicon-th-list',
+                       label: 'MyTest',
+                       class: 'MyResultBrowser',
+                       object: null,
+                       $element: null
+               },
                Table: {
                        icon: 'glyphicon-th-list',
                        label: 'Table',
diff --git a/wikibase/queryService/ui/resultBrowser/MyResultBrowser.js 
b/wikibase/queryService/ui/resultBrowser/MyResultBrowser.js
new file mode 100644
index 0000000..7e2c78a
--- /dev/null
+++ b/wikibase/queryService/ui/resultBrowser/MyResultBrowser.js
@@ -0,0 +1,51 @@
+var wikibase = wikibase || {};
+wikibase.queryService = wikibase.queryService || {};
+wikibase.queryService.ui = wikibase.queryService.ui || {};
+wikibase.queryService.ui.resultBrowser = 
wikibase.queryService.ui.resultBrowser || {};
+
+wikibase.queryService.ui.resultBrowser.MyResultBrowser = ( function( $ ) {
+       'use strict';
+
+       /**
+        * A test result
+        *
+        * @class wikibase.queryService.ui.resultBrowser.MyResultBrowser
+        * @license GNU GPL v2+
+        *
+        * @author Jonas Kress
+        * @constructor
+        */
+       function SELF() {
+       }
+
+       SELF.prototype = new 
wikibase.queryService.ui.resultBrowser.AbstractResultBrowser();
+
+       /**
+        * Draw browser to the given element
+        * @param {jQuery} $element to draw at
+        **/
+       SELF.prototype.draw = function( $element ) {
+               var self = this;
+
+               this._iterateResult( function( field, key, row ) {
+                       var content = field.value;
+
+//                     content = self._getFormatter().formatRow( row ); //auto 
format values
+
+                       /*
+                       if (self._getFormatter().isEntity( field ) ) {  //We 
could detect some types here
+                               content = $( '<div>SPARQL DATA:</div>' );
+                               //We could do some SPARQL here
+                               self.getSparqlApi().query( 'SELECT * {  <'+ 
field.value +'> wdt:P18 ?i }' ).done( function( data ){
+                                       content.append( 
data.results.bindings[0].i.value );
+                               } );
+                       }
+                        */
+
+                       $element.append( content, '<br/>' );
+               } );
+
+       };
+
+       return SELF;
+}( jQuery ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0d30be7341b4bf0329ee4e2dc204c79400308113
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

Reply via email to