Jonas Kress (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/293480
Change subject: ResultBrowser improvements ...................................................................... ResultBrowser improvements Fixed remove visitors Added tests Added code hints Change-Id: If35fc52bf9689ed2d0b1d4fb11175eebc4ee8407 --- M wikibase/queryService/ui/editor/hint/Sparql.js M wikibase/queryService/ui/resultBrowser/AbstractResultBrowser.js M wikibase/queryService/ui/resultBrowser/MultiDimensionResultBrowser.js M wikibase/tests/index.html M wikibase/tests/queryService/ui/resultBrowser/ResultBrowser.test.js 5 files changed, 33 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui refs/changes/80/293480/1 diff --git a/wikibase/queryService/ui/editor/hint/Sparql.js b/wikibase/queryService/ui/editor/hint/Sparql.js index 5fbfd47..8a744c2 100755 --- a/wikibase/queryService/ui/editor/hint/Sparql.js +++ b/wikibase/queryService/ui/editor/hint/Sparql.js @@ -17,7 +17,8 @@ '(SAMPLE() AS )', 'COUNT', '(COUNT() AS )', 'DESC', 'DESC()', 'ASC', 'ASC()', 'FILTER ()', 'FILTER NOT EXISTS', 'FILTER NOT EXISTS {\n\n}', 'UNION', 'UNION {\n\n}', 'BIND', 'BIND ()', 'GROUP_CONCAT', '(GROUP_CONCAT() as )', 'ORDER BY', - '#defaultView:Map', '#defaultView:ImageGrid' + '#defaultView:Map', '#defaultView:ImageGrid', '#defaultView:Map', '#defaultView:BubbleChart', + '#defaultView:TreeMap', '#defaultView:Timeline', '#defaultView:Dimensions', '#defaultView:Graph' ]; var SPARQL_PREDICATES = [ diff --git a/wikibase/queryService/ui/resultBrowser/AbstractResultBrowser.js b/wikibase/queryService/ui/resultBrowser/AbstractResultBrowser.js index 891af78..6d16b8e 100644 --- a/wikibase/queryService/ui/resultBrowser/AbstractResultBrowser.js +++ b/wikibase/queryService/ui/resultBrowser/AbstractResultBrowser.js @@ -120,6 +120,10 @@ SELF.prototype.processVisitors = function( data, columnKey ) { var self = this, removeVisitors = []; + if ( this._visitors.length === 0 ) { + return; + } + $.each( this._visitors, function( key, v ) { if ( v.visit && typeof v.visit === 'function' ) { if ( v.visit( data, columnKey ) === false ) { @@ -129,7 +133,7 @@ } ); $.each( removeVisitors, function( key, visitorIndex ) { - self._visitors.splice( removeVisitors, 1 ); + self._visitors.splice( visitorIndex, 1 ); } ); }; diff --git a/wikibase/queryService/ui/resultBrowser/MultiDimensionResultBrowser.js b/wikibase/queryService/ui/resultBrowser/MultiDimensionResultBrowser.js index 5f30893..528bce9 100644 --- a/wikibase/queryService/ui/resultBrowser/MultiDimensionResultBrowser.js +++ b/wikibase/queryService/ui/resultBrowser/MultiDimensionResultBrowser.js @@ -237,7 +237,18 @@ * @return {boolean} */ SELF.prototype.isDrawable = function() { - return true; + return this._drawable; + }; + + /** + * Receiving data from the visit + * + * @param {Object} data + * @return {boolean} false if there is no revisit needed + */ + SELF.prototype.visit = function( data ) { + this._drawable = true; + return false; }; return SELF; diff --git a/wikibase/tests/index.html b/wikibase/tests/index.html index 1381548..ab51fe9 100644 --- a/wikibase/tests/index.html +++ b/wikibase/tests/index.html @@ -41,6 +41,8 @@ <script src="../queryService/ui/resultBrowser/TableResultBrowser.js"></script> <script src="../queryService/ui/resultBrowser/TreeMapResultBrowser.js"></script> <script src="../queryService/ui/resultBrowser/TimelineResultBrowser.js"></script> + <script src="../queryService/ui/resultBrowser/MultiDimensionResultBrowser.js"></script> + <script src="../queryService/ui/resultBrowser/GraphResultBrowser.js"></script> <!-- Tests --> <script src="queryService/ui/editor/hint/Rdf.test.js"></script> <script src="queryService/ui/resultBrowser/ResultBrowser.test.js"></script> diff --git a/wikibase/tests/queryService/ui/resultBrowser/ResultBrowser.test.js b/wikibase/tests/queryService/ui/resultBrowser/ResultBrowser.test.js index b3e60f0..5481667 100644 --- a/wikibase/tests/queryService/ui/resultBrowser/ResultBrowser.test.js +++ b/wikibase/tests/queryService/ui/resultBrowser/ResultBrowser.test.js @@ -3,7 +3,7 @@ QUnit.module( 'wikibase.queryService.ui.resultBrowser' ); var resultBrowser = wb.queryService.ui.resultBrowser; - var browsers = [ 'TableResultBrowser', 'ImageResultBrowser', 'CoordinateResultBrowser', 'BubbleChartResultBrowser', 'TreeMapResultBrowser', 'TimelineResultBrowser' ]; + var browsers = [ 'TableResultBrowser', 'ImageResultBrowser', 'CoordinateResultBrowser', 'BubbleChartResultBrowser', 'TreeMapResultBrowser', 'TimelineResultBrowser', 'MultiDimensionResultBrowser', 'GraphResultBrowser' ]; var data = { @@ -13,7 +13,9 @@ CoordinateResultBrowser: {"head":{"vars":["label","coord","place","image"]},"results":{"bindings":[{"coord":{"datatype":"http://www.opengis.net/ont/geosparql#wktLiteral","type":"literal","value":"Point(41.4869-79.5953)"},"label":{"xml:lang":"en","type":"literal","value":"PitholeStoneArchBridge"}},{"coord":{"datatype":"http://www.opengis.net/ont/geosparql#wktLiteral","type":"literal","value":"Point(43.504611.7996)"},"label":{"xml:lang":"en","type":"literal","value":"PonteBuriano"}}]}}, BubbleChartResultBrowser: {"head":{"vars":["item","itemLabel","duration"]},"results":{"bindings":[{"item":{"type":"uri","value":"http://www.wikidata.org/entity/Q1440764"},"itemLabel":{"xml:lang":"en","type":"literal","value":"BattleofTimor"},"duration":{"datatype":"http://www.w3.org/2001/XMLSchema#double","type":"literal","value":"356.0"}},{"item":{"type":"uri","value":"http://www.wikidata.org/entity/Q383614"},"itemLabel":{"xml:lang":"en","type":"literal","value":"BattleofKohima"},"duration":{"datatype":"http://www.w3.org/2001/XMLSchema#double","type":"literal","value":"79.0"}}]}}, TreeMapResultBrowser: {"head":{"vars":["show","showLabel","season","seasonLabel","episode","episodeLabel"]},"results":{"bindings":[{"show":{"type":"uri","value":"http://www.wikidata.org/entity/Q886"},"season":{"type":"uri","value":"http://www.wikidata.org/entity/Q13131"},"episode":{"type":"uri","value":"http://www.wikidata.org/entity/Q48697"},"showLabel":{"xml:lang":"en","type":"literal","value":"TheSimpsons"},"seasonLabel":{"xml:lang":"en","type":"literal","value":"24thseasonofTheSimpsons"},"episodeLabel":{"xml:lang":"en","type":"literal","value":"AdventuresinBaby-Getting"}},{"show":{"type":"uri","value":"http://www.wikidata.org/entity/Q886"},"season":{"type":"uri","value":"http://www.wikidata.org/entity/Q13131"},"episode":{"type":"uri","value":"http://www.wikidata.org/entity/Q218073"},"showLabel":{"xml:lang":"en","type":"literal","value":"TheSimpsons"},"seasonLabel":{"xml:lang":"en","type":"literal","value":"24thseasonofTheSimpsons"},"episodeLabel":{"xml:lang":"en","type":"literal","value":"MoonshineRiver"}}]}}, - TimelineResultBrowser: { "head" : { "vars" : [ "_WikidataLabel", "_publication_date" ] }, "results" : { "bindings" : [ { "_publication_date" : { "datatype" : "http://www.w3.org/2001/XMLSchema#dateTime", "type" : "literal", "value" : "2014-10-01T00:00:00Z" }, "_WikidataLabel" : { "xml:lang" : "en", "type" : "literal", "value" : "Wikidata: A Free Collaborative Knowledgebase" } }, { "_publication_date" : { "datatype" : "http://www.w3.org/2001/XMLSchema#dateTime", "type" : "literal", "value" : "2015-01-01T00:00:00Z" }, "_WikidataLabel" : { "xml:lang" : "en", "type" : "literal", "value" : "Utilizing the Wikidata system to improve the quality of medical content in Wikipedia in diverse languages: a pilot study" } }, { "_publication_date" : { "datatype" : "http://www.w3.org/2001/XMLSchema#dateTime", "type" : "literal", "value" : "2015-11-16T00:00:00Z" }, "_WikidataLabel" : { "xml:lang" : "en", "type" : "literal", "value" : "Wikidata: A platform for data integration and dissemination for the life sciences and beyond" } } ] }} + TimelineResultBrowser: { "head" : { "vars" : [ "_WikidataLabel", "_publication_date" ] }, "results" : { "bindings" : [ { "_publication_date" : { "datatype" : "http://www.w3.org/2001/XMLSchema#dateTime", "type" : "literal", "value" : "2014-10-01T00:00:00Z" }, "_WikidataLabel" : { "xml:lang" : "en", "type" : "literal", "value" : "Wikidata: A Free Collaborative Knowledgebase" } }, { "_publication_date" : { "datatype" : "http://www.w3.org/2001/XMLSchema#dateTime", "type" : "literal", "value" : "2015-01-01T00:00:00Z" }, "_WikidataLabel" : { "xml:lang" : "en", "type" : "literal", "value" : "Utilizing the Wikidata system to improve the quality of medical content in Wikipedia in diverse languages: a pilot study" } }, { "_publication_date" : { "datatype" : "http://www.w3.org/2001/XMLSchema#dateTime", "type" : "literal", "value" : "2015-11-16T00:00:00Z" }, "_WikidataLabel" : { "xml:lang" : "en", "type" : "literal", "value" : "Wikidata: A platform for data integration and dissemination for the life sciences and beyond" } } ] }}, + MultiDimensionResultBrowser: { "head" : { "vars" : [ "item", "itemLabel" ] }, "results" : { "bindings" : [ { "item" : { "type" : "uri", "value" : "http://www.wikidata.org/entity/Q498787" }, "itemLabel" : { "xml:lang" : "en", "type" : "literal", "value" : "Muezza" } }, { "item" : { "type" : "uri", "value" : "http://www.wikidata.org/entity/Q677525" }, "itemLabel" : { "xml:lang" : "en", "type" : "literal", "value" : "Orangey" } } ] }}, + GraphResultBrowser: { "head" : { "vars" : [ "item", "itemLabel" ] }, "results" : { "bindings" : [ { "item" : { "type" : "uri", "value" : "http://www.wikidata.org/entity/Q498787" }, "itemLabel" : { "xml:lang" : "en", "type" : "literal", "value" : "Muezza" } }, { "item" : { "type" : "uri", "value" : "http://www.wikidata.org/entity/Q677525" }, "itemLabel" : { "xml:lang" : "en", "type" : "literal", "value" : "Orangey" } } ] }}, }; // var expected = { @@ -38,6 +40,14 @@ var b = new resultBrowser[ browser ](); var tb = new resultBrowser.TableResultBrowser(); tb.addVisitor( b ); + + $.each( browsers, function( i, ob ){ + if( ob === browser ){ + return; + } + tb.addVisitor( new resultBrowser[ ob ]() ); + } ); + tb.setResult( data[ browser ] ); tb.draw( $( '<div> ' ) ); -- To view, visit https://gerrit.wikimedia.org/r/293480 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If35fc52bf9689ed2d0b1d4fb11175eebc4ee8407 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