Ferdbold has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/328468 )
Change subject: Preview node on graph dialog ...................................................................... Preview node on graph dialog Bug: T151127 Change-Id: Ia03568165e821f2617e6fc87f36d3b1d97e6c6aa --- M extension.json M modules/ve-graph/ve.dm.MWGraphNode.js A modules/ve-graph/ve.ui.MWGraphDialog.css M modules/ve-graph/ve.ui.MWGraphDialog.js 4 files changed, 60 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Graph refs/changes/68/328468/1 diff --git a/extension.json b/extension.json index 7384adc..018bf43 100644 --- a/extension.json +++ b/extension.json @@ -114,6 +114,7 @@ "modules/ve-graph/widgets/ve.ui.TableWidget.js" ], "styles": [ + "modules/ve-graph/ve.ui.MWGraphDialog.css", "modules/ve-graph/ve.ce.MWGraphNode.css", "modules/ve-graph/ve.ui.MWGraphIcons.css", "modules/ve-graph/widgets/ve.ui.RowWidget.css", diff --git a/modules/ve-graph/ve.dm.MWGraphNode.js b/modules/ve-graph/ve.dm.MWGraphNode.js index 20f07ae..1f92141 100644 --- a/modules/ve-graph/ve.dm.MWGraphNode.js +++ b/modules/ve-graph/ve.dm.MWGraphNode.js @@ -51,6 +51,8 @@ ve.dm.MWGraphNode.static.name = 'mwGraph'; +ve.dm.MWExtensionNode.static.tagName = 'div'; + ve.dm.MWGraphNode.static.extensionName = 'graph'; ve.dm.MWGraphNode.static.defaultSpec = { @@ -181,6 +183,19 @@ return result || ''; }; +/** + * @override + */ +ve.dm.MWGraphNode.static.toDomElements = function ( dataElement, doc, converter ) { + var element = ve.dm.MWExtensionNode.static.toDomElements.call( this, dataElement, doc, converter ), + spec = ve.dm.MWGraphNode.static.parseSpecString( dataElement.attributes.mw.body.extsrc ); + + // Render Vega asynchronously for preview element purposes + ve.ce.MWGraphNode.static.vegaParseSpec( spec, element[ 0 ] ); + + return element; +}; + /* Methods */ /** diff --git a/modules/ve-graph/ve.ui.MWGraphDialog.css b/modules/ve-graph/ve.ui.MWGraphDialog.css new file mode 100644 index 0000000..58ed897 --- /dev/null +++ b/modules/ve-graph/ve.ui.MWGraphDialog.css @@ -0,0 +1,7 @@ +.ve-ui-graphDialog-menuLayout-content { + overflow: auto; +} + +.ve-ui-mwGraphDialog-preview { + text-align: center; +} diff --git a/modules/ve-graph/ve.ui.MWGraphDialog.js b/modules/ve-graph/ve.ui.MWGraphDialog.js index cc05ab7..0be993d 100644 --- a/modules/ve-graph/ve.ui.MWGraphDialog.js +++ b/modules/ve-graph/ve.ui.MWGraphDialog.js @@ -8,7 +8,7 @@ * MediaWiki graph dialog. * * @class - * @extends ve.ui.MWExtensionDialog + * @extends ve.ui.MWExtensionPreviewDialog * * @constructor * @param {Object} [element] @@ -26,7 +26,7 @@ /* Inheritance */ -OO.inheritClass( ve.ui.MWGraphDialog, ve.ui.MWExtensionDialog ); +OO.inheritClass( ve.ui.MWGraphDialog, ve.ui.MWExtensionPreviewDialog ); /* Static properties */ @@ -35,6 +35,8 @@ ve.ui.MWGraphDialog.static.title = OO.ui.deferMsg( 'graph-ve-dialog-edit-title' ); ve.ui.MWGraphDialog.static.size = 'large'; + +ve.ui.MWGraphDialog.static.modelClasses = [ ve.dm.MWGraphNode ]; ve.ui.MWGraphDialog.static.actions = [ { @@ -55,8 +57,6 @@ modes: [ 'edit', 'insert' ] } ]; - -ve.ui.MWGraphDialog.static.modelClasses = [ ve.dm.MWGraphNode ]; /* Methods */ @@ -81,7 +81,17 @@ ve.ui.MWGraphDialog.super.prototype.initialize.call( this ); /* Root layout */ - this.rootLayout = new OO.ui.BookletLayout( { + this.rootLayout = new OO.ui.MenuLayout( { + menuPosition: 'bottom' + } ); + + /* Preview element */ + this.previewElement.$element.addClass( + 've-ui-mwGraphDialog-preview' + ); + + /* Menu layout */ + this.menuLayout = new OO.ui.BookletLayout( { classes: [ 've-ui-mwGraphDialog-panel-root' ], outlined: true } ); @@ -90,7 +100,7 @@ this.dataPage = new OO.ui.PageLayout( 'data' ); this.rawPage = new OO.ui.PageLayout( 'raw' ); - this.rootLayout.addPages( [ + this.menuLayout.addPages( [ this.generalPage, this.dataPage, this.rawPage ] ); @@ -213,7 +223,7 @@ this.rawPage.$element.append( jsonTextField.$element ); // Events - this.rootLayout.connect( this, { set: 'onRootLayoutSet' } ); + this.menuLayout.connect( this, { set: 'onMenuLayoutSet' } ); this.graphTypeDropdownInput.connect( this, { change: 'onGraphTypeInputChange' } ); this.sizeWidget.connect( this, { change: 'onSizeWidgetChange' } ); @@ -230,6 +240,13 @@ this.jsonTextInput.connect( this, { change: 'onSpecStringInputChange' } ); // Initialization + this.rootLayout.$menu + .append( this.menuLayout.$element ); + + this.rootLayout.$content + .addClass( 've-ui-graphDialog-menuLayout-content' ) + .append( this.previewElement.$element ); + this.$body.append( this.rootLayout.$element ); }; @@ -286,7 +303,6 @@ .first( function () { // Kill model this.graphModel.disconnect( this ); - this.graphModel = null; // Clear data page @@ -297,6 +313,16 @@ this.getFragment().getSurface().popStaging(); } }, this ); +}; + +/** + * @inheritdoc + */ +ve.ui.MWGraphDialog.prototype.updateMwData = function ( mwData ) { + ve.ui.MWGraphDialog.super.prototype.updateMwData.call( this, mwData ); + + // Get spec from dialog model + mwData.body.extsrc = this.graphModel.getSpecString(); }; /** @@ -479,11 +505,11 @@ }; /** - * Handle page set events on the root layout + * Handle page set events on the menu layout * * @param {OO.ui.PageLayout} page Set page */ -ve.ui.MWGraphDialog.prototype.onRootLayoutSet = function ( page ) { +ve.ui.MWGraphDialog.prototype.onMenuLayoutSet = function ( page ) { if ( page.getName() === 'raw' ) { // The raw data may have been changed while not visible, // so recalculate height now it is visible. @@ -586,6 +612,7 @@ dialog.actions.setAbilities( { done: ( dialog.mode === 'insert' ) || dialog.graphModel.hasBeenChanged() } ); + dialog.onChangeHandler.call(); }, function () { dialog.actions.setAbilities( { done: false } ); -- To view, visit https://gerrit.wikimedia.org/r/328468 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia03568165e821f2617e6fc87f36d3b1d97e6c6aa Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Graph Gerrit-Branch: master Gerrit-Owner: Ferdbold <fbol...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits