From 8120dac27ba2583f7cdf7100f2685b424935b775 Mon Sep 17 00:00:00 2001 From: Alex Monk Date: Sun, 26 Oct 2014 15:22:09 +0000 Subject: [PATCH] Move autoValue logic from ui.MWParameterPage to dm.MWParameterModel Also add missing MWParameterModel#getDefaultValue Bug: 72404 Change-Id: I4bb117d419f3845f44e321f848e95bb246a24e24 --- .../ve-mw/dm/models/ve.dm.MWParameterModel.js | 23 +++++++++++++++++-- .../ve-mw/ui/pages/ve.ui.MWParameterPage.js | 6 +---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/modules/ve-mw/dm/models/ve.dm.MWParameterModel.js b/modules/ve-mw/dm/models/ve.dm.MWParameterModel.js index 270a0ee813..00aeb0eeef 100644 --- a/modules/ve-mw/dm/models/ve.dm.MWParameterModel.js +++ b/modules/ve-mw/dm/models/ve.dm.MWParameterModel.js @@ -110,10 +110,29 @@ ve.dm.MWParameterModel.prototype.getOriginalName = function () { /** * Get parameter value. * - * @returns {string} Parameter value + * @returns {string} Parameter value, or automatic value if there is none stored. + * Otherwise an empty string. */ ve.dm.MWParameterModel.prototype.getValue = function () { - return this.value; + return this.value || this.getAutoValue() || ''; +}; + +/** + * Get default parameter value. + * + * @returns {string} Default parameter value + */ +ve.dm.MWParameterModel.prototype.getDefaultValue = function () { + return this.template.getSpec().getParameterDefaultValue( this.name ); +}; + +/** + * Get automatic parameter value. + * + * @returns {string} Automatic parameter name. + */ +ve.dm.MWParameterModel.prototype.getAutoValue = function () { + return this.template.getSpec().getParameterAutoValue( this.name ); }; /** diff --git a/modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js b/modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js index 8aa5ae6df8..9b1ad5d636 100644 --- a/modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js +++ b/modules/ve-mw/ui/pages/ve.ui.MWParameterPage.js @@ -30,11 +30,7 @@ ve.ui.MWParameterPage = function VeUiMWParameterPage( parameter, name, config ) // Properties this.parameter = parameter; this.spec = parameter.getTemplate().getSpec(); - this.defaultValue = this.spec.getParameterDefaultValue( paramName ); - this.autoValue = this.spec.getParameterAutoValue( paramName ); - if ( this.autoValue && !this.parameter.getValue() ) { - this.parameter.setValue( this.autoValue ); - } + this.defaultValue = parameter.getDefaultValue(); this.$info = this.$( '
' ); this.$actions = this.$( '
' );