mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 16:44:51 +00:00
fc95029b34
Objectives: * Automatically add required parameters to templates that users create using the GUI, without touching existing templates loaded from data * Cleanup some confusing terminology and APIs Changes: ve.ui.MWParameterSearchWidget.js * Remove special logic for skipping aliases, which are no longer included in the list of names given by getParameterNames ve.ui.MWTransclusionDialog.js * Add origin arguments to constructors of transclusion parts * Re-use onAddParameter method during initial construction of parameter pages * Add required template parameters for user created template parts ve.dm.MWTransclusionPartModel.js * Add origin argument/property/getter for tracking where a part came from ve.dm.MWTransclusionContentModel.js, ve.dm.MWTransclusionPlaceholderModel.js, ve.dm.MWTemplateModel.js * Add origin argument pass through ve.dm.MWTranclusionModel.js * Add origin arguments to constructors of transclusion parts ve.dm.MWTemplateSpecModel.js * Rename origin to name - was a bad name to start with and will be even more confusing with the new part origin property * Add isParameterAlias method * Make getParameterNames only return primary names, excluding aliases ve.dm.MWTemplateModel.js * Update use of parameter origin, now called name Bug: 50747 Change-Id: Ib444f0f5a8168cd59ea52a6000ba5e42ccdc2a24
70 lines
1.5 KiB
JavaScript
70 lines
1.5 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel MWTransclusionPartModel class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* MediaWiki transclusion part model.
|
|
*
|
|
* @class
|
|
* @mixins ve.EventEmitter
|
|
*
|
|
* @constructor
|
|
* @param {ve.dm.MWTransclusionModel} transclusion Transclusion
|
|
* @param {string} [origin] Origin of part, e.g. 'data' or 'user'
|
|
*/
|
|
ve.dm.MWTransclusionPartModel = function VeDmMWTransclusionPartModel( transclusion, origin ) {
|
|
// Mixin constructors
|
|
ve.EventEmitter.call( this );
|
|
|
|
// Properties
|
|
this.transclusion = transclusion;
|
|
this.origin = origin;
|
|
this.id = 'part_' + this.transclusion.getUniquePartId();
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.mixinClass( ve.dm.MWTransclusionPartModel, ve.EventEmitter );
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Get transclusion part is in.
|
|
*
|
|
* @method
|
|
* @returns {ve.dm.MWTransclusionModel} Transclusion
|
|
*/
|
|
ve.dm.MWTransclusionPartModel.prototype.getTransclusion = function () {
|
|
return this.transclusion;
|
|
};
|
|
|
|
/**
|
|
* Get part origin.
|
|
*
|
|
* @returns {string} Origin
|
|
*/
|
|
ve.dm.MWTransclusionPartModel.prototype.getOrigin = function () {
|
|
return this.origin;
|
|
};
|
|
|
|
/**
|
|
* Get a unique part ID within the transclusion.
|
|
*
|
|
* @returns {string} Unique ID
|
|
*/
|
|
ve.dm.MWTransclusionPartModel.prototype.getId = function () {
|
|
return this.id;
|
|
};
|
|
|
|
/**
|
|
* Remove part from transclusion.
|
|
*
|
|
* @method
|
|
*/
|
|
ve.dm.MWTransclusionPartModel.prototype.remove = function () {
|
|
this.transclusion.removePart( this );
|
|
};
|