Created
September 17, 2015 10:51
-
-
Save agubler/affcec1ffc4e07217993 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
"dojo/_base/declare", | |
"dojo/_base/lang", | |
"indium/router/router", | |
"indium/control/_BaseController" | |
], function ( | |
declare, | |
lang, | |
router, | |
_BaseController | |
) { | |
/** @module */ | |
return declare("admin.common._RouteController", [_BaseController], { | |
/** | |
* @type {boolean} | |
*/ | |
ownInjected: true, | |
/** | |
* @param {object} args | |
*/ | |
constructor: function (args) { | |
if (this.ownInjected && args) { | |
this._ownInjected(args); | |
} | |
this.view = new this.view(args); | |
if (this.outletName) { | |
this._registerOutlet("outlet", this.outletName); | |
} | |
this.own(this.view); | |
}, | |
/** | |
* @param {function} callback | |
* @param {string} outlet | |
*/ | |
_registerOutlet: function (callback, outlet) { | |
this.own(router.outlet(outlet, lang.hitch(this, callback))); | |
}, | |
/** | |
* @param {object} toOwn | |
*/ | |
_ownInjected: function (toOwn) { | |
var set = [], exclude, include; | |
exclude = this.ownInjected.exclude || []; | |
exclude = exclude === "*" ? Object.keys(toOwn) : exclude; | |
include = this.ownInjected.include || Object.keys(toOwn); | |
include.map(function (key) { | |
if (exclude.indexOf(key) < 0 && (toOwn[key].remove || toOwn[key].destroy)) { | |
set.push(toOwn[key]); | |
} | |
}); | |
this.own(set); | |
}, | |
/** | |
* @return {Object|undefined} response passed to the router | |
*/ | |
action: function () { | |
this.inherited(arguments); | |
return this.view; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment