| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
ve.dm.MWParameterModel = function VeDmMWParameterModel( template, name, value ) { |
| 25 |
|
| 26 |
OO.EventEmitter.call( this ); |
| 27 |
|
| 28 |
|
| 29 |
this.template = template; |
| 30 |
this.originalName = name; |
| 31 |
this.name = typeof name === 'string' ? name.trim() : ''; |
| 32 |
this.value = value || ''; |
| 33 |
this.id = this.template.getId() + '/' + this.name; |
| 34 |
}; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
OO.mixinClass( ve.dm.MWParameterModel, OO.EventEmitter ); |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
ve.dm.MWParameterModel.prototype.isRequired = function () { |
| 54 |
return this.template.getSpec().isParameterRequired( this.name ); |
| 55 |
}; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
ve.dm.MWParameterModel.prototype.isSuggested = function () { |
| 61 |
return this.template.getSpec().isParameterSuggested( this.name ); |
| 62 |
}; |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
ve.dm.MWParameterModel.prototype.isDeprecated = function () { |
| 68 |
return this.template.getSpec().isParameterDeprecated( this.name ); |
| 69 |
}; |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
ve.dm.MWParameterModel.prototype.isDocumented = function () { |
| 75 |
return this.template.getSpec().isParameterDocumented( this.name ); |
| 76 |
}; |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
ve.dm.MWParameterModel.prototype.getTemplate = function () { |
| 84 |
return this.template; |
| 85 |
}; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
ve.dm.MWParameterModel.prototype.getId = function () { |
| 93 |
return this.id; |
| 94 |
}; |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
ve.dm.MWParameterModel.prototype.getName = function () { |
| 100 |
return this.name; |
| 101 |
}; |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
ve.dm.MWParameterModel.prototype.getOriginalName = function () { |
| 109 |
return this.originalName; |
| 110 |
}; |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
ve.dm.MWParameterModel.prototype.getValue = function () { |
| 117 |
return this.value || this.getAutoValue() || ''; |
| 118 |
}; |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
ve.dm.MWParameterModel.prototype.getSuggestedValues = function () { |
| 124 |
return this.template.getSpec().getParameterSuggestedValues( this.name ); |
| 125 |
}; |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
ve.dm.MWParameterModel.prototype.getDefaultValue = function () { |
| 131 |
return this.template.getSpec().getParameterDefaultValue( this.name ); |
| 132 |
}; |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
ve.dm.MWParameterModel.prototype.getExampleValue = function () { |
| 138 |
return this.template.getSpec().getParameterExampleValue( this.name ); |
| 139 |
}; |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
ve.dm.MWParameterModel.prototype.getAutoValue = function () { |
| 145 |
return this.template.getSpec().getParameterAutoValue( this.name ); |
| 146 |
}; |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
ve.dm.MWParameterModel.prototype.getType = function () { |
| 152 |
return this.template.getSpec().getParameterType( this.name ); |
| 153 |
}; |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
ve.dm.MWParameterModel.prototype.setValue = function ( value ) { |
| 160 |
if ( this.value !== value ) { |
| 161 |
this.value = value; |
| 162 |
this.emit( 'change' ); |
| 163 |
} |
| 164 |
}; |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
ve.dm.MWParameterModel.prototype.remove = function () { |
| 170 |
this.template.removeParameter( this ); |
| 171 |
}; |