set get controller

This commit is contained in:
Andrej 2019-06-30 18:06:23 +07:00
parent cbcd3d5e3c
commit cfa3631b0d
2 changed files with 18 additions and 7 deletions

View File

@ -20,20 +20,29 @@ import ControllerFactory from './ControllerFactory';
* *
* @extends dat.controllers.Controller * @extends dat.controllers.Controller
* *
* @param {Object} object The object to be manipulated
* @param {Function} [object.property] Returns an object with elements for adding into "property-name" class element.
* @param {string} property The name of the property to be manipulated
* @param {Object} [params] Optional parameters
*/ */
class CustomController extends Controller{ class CustomController extends Controller{
constructor(object, property) { /**
* Represents a custom controller.
* @param {Object} object The object to be manipulated
* @param {Function} [object.property] Returns an object with elements for adding into "property-name" class element.
* @param {string} property The name of the property to be manipulated
* @param {Object} [params] Optional parameters
*/
constructor(object, property) {
super(object, property); super(object, property);
this.arguments = { this.arguments = {
object: object, property: property, opts: Array.prototype.slice.call(arguments, 2) object: object, property: property, opts: Array.prototype.slice.call(arguments, 2)
} }
if(object.property) if(object.property)
this.property = object.property(); this.property = object.property( this );
}
set controller( newController ){
this._controller = newController;
}
get controller(){
return this._controller;
} }
} }

View File

@ -1157,7 +1157,9 @@ function add(gui, object, property, params) {
controller = ControllerFactory.apply(gui, factoryArgs); controller = ControllerFactory.apply(gui, factoryArgs);
} }
if ( controller === null ) if ( controller === null )
controller = customObject; controller = customObject;
else if( customObject !== undefined )
customObject.controller = controller;
if (params.before instanceof Controller) { if (params.before instanceof Controller) {
params.before = params.before.__li; params.before = params.before.__li;