Merge "Better name for ambiguous "empty" concept in the model"

This commit is contained in:
jenkins-bot 2021-08-09 09:40:40 +00:00 committed by Gerrit Code Review
commit aa868059ee
4 changed files with 16 additions and 17 deletions

View file

@ -377,19 +377,18 @@ ve.dm.MWTemplateModel.prototype.serialize = function () {
/**
* @inheritdoc
*/
ve.dm.MWTemplateModel.prototype.isEmpty = function () {
ve.dm.MWTemplateModel.prototype.containsValuableData = function () {
var params = this.params;
return Object.keys( params ).every( function ( name ) {
// There is always an unnamed placeholder at the start
return Object.keys( params ).some( function ( name ) {
// Skip unnamed placeholders
if ( !name ) {
return true;
return false;
}
var param = params[ name ],
value = param.getValue();
// Check that the value has not been set, or is indistinguishable from
// the automatically-set value. See `MWParameterModel.getValue`
return value === '' || value === param.getAutoValue();
// The automatically set value isn't valueable, {@see ve.dm.MWParameterModel.getValue}
return value !== '' && value !== param.getAutoValue();
} );
};

View file

@ -58,6 +58,6 @@ ve.dm.MWTransclusionContentModel.prototype.serialize = function () {
/**
* @inheritdoc
*/
ve.dm.MWTransclusionContentModel.prototype.isEmpty = function () {
return this.wikitext === '';
ve.dm.MWTransclusionContentModel.prototype.containsValuableData = function () {
return this.wikitext !== '';
};

View file

@ -89,8 +89,8 @@ ve.dm.MWTransclusionPartModel.prototype.addPromptedParameters = function () {
};
/**
* @return {boolean} True if there is no user input
* @return {boolean} True if there is meaningful user input that was not e.g. auto-generated
*/
ve.dm.MWTransclusionPartModel.prototype.isEmpty = function () {
return true;
ve.dm.MWTransclusionPartModel.prototype.containsValuableData = function () {
return false;
};

View file

@ -369,7 +369,7 @@ ve.ui.MWTransclusionDialog.prototype.addPart = function ( part ) {
*/
ve.ui.MWTransclusionDialog.prototype.getActionProcess = function ( action ) {
if ( action === 'back' ) {
if ( this.isEmpty() ) {
if ( !this.containsValuableData() ) {
return this.getActionProcess( 'reset' );
}
return new OO.ui.Process( function () {
@ -473,11 +473,11 @@ ve.ui.MWTransclusionDialog.prototype.resetDialog = function () {
};
/**
* @return {boolean} False if any transclusion part contains non-default input
* @return {boolean} True if any transclusion part contains meaningful, non-default user input
*/
ve.ui.MWTransclusionDialog.prototype.isEmpty = function () {
return this.transclusionModel.getParts().every( function ( part ) {
return part.isEmpty();
ve.ui.MWTransclusionDialog.prototype.containsValuableData = function () {
return this.transclusionModel.getParts().some( function ( part ) {
return part.containsValuableData();
} );
};