apisandbox.js - split UploadParamWidget to separate file
Bug: T269952 Change-Id: I13b05f91b008cf31c70ff26b6f29889c42d08fc1
This commit is contained in:
parent
b782926025
commit
6f1515ee28
3 changed files with 51 additions and 21 deletions
|
|
@ -1838,6 +1838,7 @@ return [
|
|||
'packageFiles' => [
|
||||
'apisandbox.js',
|
||||
'OptionalParamWidget.js',
|
||||
'UploadParamWidget.js',
|
||||
],
|
||||
'targets' => [ 'desktop', 'mobile' ],
|
||||
'dependencies' => [
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
* A wrapper for OO.ui.SelectFileWidget
|
||||
*
|
||||
* @class
|
||||
* @private
|
||||
* @constructor
|
||||
*/
|
||||
function UploadParamWidget() {
|
||||
UploadParamWidget.parent.call( this );
|
||||
}
|
||||
|
||||
OO.inheritClass( UploadParamWidget, OO.ui.SelectFileWidget );
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
UploadParamWidget.prototype.getApiValueForDisplay = function () {
|
||||
return '...';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {Mixed}
|
||||
*/
|
||||
UploadParamWidget.prototype.getApiValue = function () {
|
||||
return this.getValue();
|
||||
};
|
||||
|
||||
/**
|
||||
* There should be `@param {Mixed} newValue` but that results in
|
||||
* `no-unused-vars` eslint rule failing
|
||||
*/
|
||||
UploadParamWidget.prototype.setApiValue = function () {
|
||||
// No-op
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean} shouldSuppressErrors
|
||||
* @return {jQuery.Promise}
|
||||
*/
|
||||
UploadParamWidget.prototype.apiCheckValid = function ( shouldSuppressErrors ) {
|
||||
var ok = this.getValue() !== null && this.getValue() !== undefined || shouldSuppressErrors;
|
||||
this.info.setIcon( ok ? null : 'alert' );
|
||||
this.setTitle( ok ? '' : mw.message( 'apisandbox-alert-field' ).plain() );
|
||||
return $.Deferred().resolve( ok ).promise();
|
||||
};
|
||||
|
||||
module.exports = UploadParamWidget;
|
||||
|
|
@ -12,7 +12,8 @@
|
|||
pages = {},
|
||||
moduleInfoCache = {},
|
||||
baseRequestParams,
|
||||
OptionalParamWidget = require( './OptionalParamWidget.js' );
|
||||
OptionalParamWidget = require( './OptionalParamWidget.js' ),
|
||||
UploadParamWidget = require( './UploadParamWidget.js' );
|
||||
|
||||
WidgetMethods = {
|
||||
textInputWidget: {
|
||||
|
|
@ -198,24 +199,6 @@
|
|||
return { value: val, path: map[ val ] };
|
||||
} );
|
||||
}
|
||||
},
|
||||
|
||||
uploadWidget: {
|
||||
getApiValueForDisplay: function () {
|
||||
return '...';
|
||||
},
|
||||
getApiValue: function () {
|
||||
return this.getValue();
|
||||
},
|
||||
setApiValue: function () {
|
||||
// Can't, sorry.
|
||||
},
|
||||
apiCheckValid: function ( shouldSuppressErrors ) {
|
||||
var ok = this.getValue() !== null && this.getValue() !== undefined || shouldSuppressErrors;
|
||||
this.info.setIcon( ok ? null : 'alert' );
|
||||
this.setTitle( ok ? '' : mw.message( 'apisandbox-alert-field' ).plain() );
|
||||
return $.Deferred().resolve( ok ).promise();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -439,9 +422,8 @@
|
|||
break;
|
||||
|
||||
case 'upload':
|
||||
widget = new OO.ui.SelectFileWidget();
|
||||
widget = new UploadParamWidget();
|
||||
widget.paramInfo = pi;
|
||||
$.extend( widget, WidgetMethods.uploadWidget );
|
||||
break;
|
||||
|
||||
case 'namespace':
|
||||
|
|
|
|||
Loading…
Reference in a new issue