Jonas Kress (WMDE) has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/367044 )
Change subject: [WIP] Inline selectorBox as a replace for popover ...................................................................... [WIP] Inline selectorBox as a replace for popover Replaces links in Query Helper triples section with selectorBox from popover. TODO: -tooltip glitch -query template after select glitch Change-Id: I0bb08bcb3eb7f2adf8847fa02cbf3c7b2377bf62 --- M wikibase/queryService/ui/queryHelper/SelectorBox.js M wikibase/tests/QueryHelper.html M wikibase/tests/queryService/ui/queryHelper/QueryHelper.test.js 3 files changed, 26 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui refs/changes/44/367044/1 diff --git a/wikibase/queryService/ui/queryHelper/SelectorBox.js b/wikibase/queryService/ui/queryHelper/SelectorBox.js index 4c82bb6..f7e21bd 100644 --- a/wikibase/queryService/ui/queryHelper/SelectorBox.js +++ b/wikibase/queryService/ui/queryHelper/SelectorBox.js @@ -307,6 +307,11 @@ $toolbar = this._getToolbar( toolbar, $element ), $content = $( '<div>' ).append( $close, ' ', $select, ' ', $toolbar ); + if ( $element.children().length === 0 ) { + this._createSelectInline( $element, triple, listener ); + return; + } + $element.clickover( { placement: 'bottom', 'global_close': false, @@ -341,6 +346,25 @@ /** * @private */ + SELF.prototype._createSelectInline = function( $element, triple, listener ) { + var $select = this._getSelectBox( $element ); + + $element.replaceWith( $select ); + this._renderSelect2( $select, $element, triple ); + + $select.change( function( e ) { + if ( listener ) { + listener( $select.val(), $select.find( 'option:selected' ).text(), $( e.target ).data( 'options' ) ); + } + $element.click();// hide clickover + $select.html( '' ); + } ); + + }; + + /** + * @private + */ SELF.prototype._getSelectBox = function( $element ) { var id = $element.data( 'id' ); var label = $element.text(); diff --git a/wikibase/tests/QueryHelper.html b/wikibase/tests/QueryHelper.html index c7e08a9..f0879e4 100644 --- a/wikibase/tests/QueryHelper.html +++ b/wikibase/tests/QueryHelper.html @@ -19,6 +19,7 @@ <script src="../../node_modules/sinon/pkg/sinon.js"></script> <script src="../../node_modules/bootstrap-table/dist/bootstrap-table.js"></script> + <script src="../../node_modules/select2/dist/js/select2.js"></script> <script src="../../vendor/sparqljs/dist/sparqljs-browser-min.js"></script> <script src="../../vendor/bootstrapx-clickover/bootstrapx-clickover.js"></script> <!-- wikibase --> diff --git a/wikibase/tests/queryService/ui/queryHelper/QueryHelper.test.js b/wikibase/tests/queryService/ui/queryHelper/QueryHelper.test.js index facc092..b3908de 100644 --- a/wikibase/tests/queryService/ui/queryHelper/QueryHelper.test.js +++ b/wikibase/tests/queryService/ui/queryHelper/QueryHelper.test.js @@ -104,6 +104,7 @@ var $html = $( '<div>' ); qh.draw( $html ); $html.find( '.btn' ).remove(); + $html.find( '.select2' ).remove(); assert.equal( qh.getQuery().trim(), testCase.sparqlOut ); assert.equal( $html.text().trim(), testCase.text ); -- To view, visit https://gerrit.wikimedia.org/r/367044 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0bb08bcb3eb7f2adf8847fa02cbf3c7b2377bf62 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