Permalink
Browse files

Merge branch 'develop' of github.com:yahoo/mojito into partials

  • Loading branch information...
2 parents 46d19ea + fed74c6 commit 6c6834c1266647e0abc283e6efb8a69007fefe6c @caridy committed Jan 24, 2013

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -170,7 +170,7 @@ using ``Y.mojito.controllers[NAME]``.
}
};
controller.index(ac);
- A.isTrue(compCalled);
+ A.isTrue(doneCalled);
}
}));
YUITest.TestRunner.add(suite);
@@ -25,7 +25,11 @@ YUI.add('ShelfController', function (Y, NAME) {
vudata.tiles.push(feed);
});
- ac.composite.done({template: vudata});
+ ac.composite.done(vudata, {
+ view: {
+ name: 'index'
+ }
+ });
}
/**
@@ -9,7 +9,7 @@ YUI.add('Parent', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
index: function(ac) {
- ac.composite.done({template: {time: new Date().toString()}});
+ ac.composite.done({time: new Date().toString()});
}
};
@@ -119,29 +119,33 @@ YUI.add('mojito-composite-addon', function(Y, NAME) {
Y.mojito.controller = {
index: function(ac) {
ac.composite.done({
- template: { title: 'Hello there' } // for the view only
+ title: 'Hello there'
});
}
- };
+};
</pre>
* This will execute the child intances of the "FooMojit" and
* "BarMojit", returning their rendered values into the parent's view
* template, thus rendering the full parent view including the children.
- * All the parent parameters are passed along to children.
+ * The API of this method is equivalent to ac.done().
* @method done
- * @param {object} opts The configuration object to be used.
- * <em>template<em> can be used to provide additional
- * view template values.
+ * @param {object} templateData The data you want return by the request.
+ * @param {object} parentMeta Any meta-data required to service the request.
*/
- done: function(opts) {
- var template,
- ac = this.ac,
+ done: function(templateData, parentMeta) {
+ var ac = this.ac,
cfg = this.command.instance.config,
children = cfg.children;
- opts = opts || {};
+ templateData = templateData || {};
+ parentMeta = parentMeta || {};
- template = opts.template || {};
+ // Backward Compatibility block
+ if (templateData.template) {
+ Y.log('ac.composite.done({template:{title: "..."}}) is a legacy API, ' +
+ 'use ac.composite.done({title: "..."}) instead.', 'warn', NAME);
+ templateData = templateData.template;
+ }
if (!children || Y.Object.size(children) === 0) {
throw new Error('Cannot run composite mojit children because' +
@@ -150,9 +154,17 @@ Y.mojito.controller = {
}
this.execute(cfg, function(data, meta) {
- var merged = Y.merge(template, data);
- ac.done(merged, meta);
-
+ parentMeta.assets = Y.mojito.util.metaMerge(
+ parentMeta.assets || {},
+ meta.assets || {}
+ );
+ // 1. templateData and data are normally exclusive, in which case
+ // the prority is not relevent. In which case we set D
+ // 2. parentMeta and meta should be merged to preserve the children
+ // binders map, assets, etc. but giving parentMeta the priority in case
+ // a custom configuration in the parent should overrule something coming
+ // from the chindren merged meta
+ ac.done(Y.merge(data, templateData), Y.mojito.util.metaMerge(parentMeta, meta));
}, this);
},
@@ -25,9 +25,9 @@ YUI.add('BroadCast', function(Y, NAME) {
ac.assets.addCss('/static/BroadCast/assets/static.css');
ac.composite.done();
},
-
+
'destroychild': function(ac) {
- Y.log("inside destroy controller")
+ Y.log("inside destroy controller");
ac.assets.addCss('/static/BroadCast/assets/static.css');
ac.composite.done();
},
@@ -72,7 +72,7 @@ YUI.add('BroadCast', function(Y, NAME) {
ac.done(template, meta);
});
},
-
+
'destroydynochild': function(ac) {
var children = {
@@ -108,15 +108,13 @@ YUI.add('BroadCast', function(Y, NAME) {
ac.done(template, meta);
});
},
-
+
'selfinvoke': function(ac){
//var foovalue = ac.params.getFromBody('foo');
//Y.log("Here11111....."+foovalue);
- ac.composite.done({
- template: {
- title: 'foovalue='
- }
- });
+ ac.composite.done({
+ title: 'foovalue='
+ });
}
};
@@ -23,16 +23,16 @@ YUI.add('CM_Layout', function(Y, NAME) {
* @param ac {Object} The action context that provides access
* to the Mojito API.
*/
- index: function(ac) {
- ac.composite.done();
- },
+ index: function(ac) {
+ ac.composite.done();
+ },
myIndex: function(ac) {
Y.log('index()', 'debug', NAME);
var passParams = ac.params.getFromUrl('pass_params') || 'false';
var parentConfig = ac.config.get();
- var myId = parentConfig.id;
+ var myId = parentConfig.id;
var childrenConfig = parentConfig.children;
var childInfo = [];
@@ -46,24 +46,19 @@ YUI.add('CM_Layout', function(Y, NAME) {
childInfo.push(info);
});
- if (passParams === "false")
- {
- ac.composite.done({
- template: {
- title: 'This is the title from controller.js of ' + myId, childData: childInfo
- }
- });
- }
+ if (passParams === "false")
+ {
+ ac.composite.done({
+ title: 'This is the title from controller.js of ' + myId,
+ childData: childInfo
+ });
+ }
else
{
- ac.composite.done({
- template: {
- title: 'This is the title from controller.js of ' + myId, childData: childInfo
- },
- params: {
- fromParent: "I am from parent"
- }
- });
+ ac.composite.done({
+ title: 'This is the title from controller.js of ' + myId,
+ childData: childInfo
+ });
}
}
};
@@ -4,36 +4,38 @@
YUI.add('DepCheckParent', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- 'index': function(ac) {
- ac.done();
- },
- 'mytest': function(ac) {
- //ac.models.AppLevelMojit.getData(function(mydata){
- ac.models.get('DepCheckModel').getData(function(mydata){
- Y.log("data....."+mydata);
- ac.done({data:mydata});
- });
- },
- 'metachild': function(ac) {
- ac.composite.done({
- template: {
- title: 'My Child Mojits:'
- }
- });
- },
- 'retrievedata': function(ac) {
- //var retrieved = "old data";
- var retrieved;
- Y.log("data.....");
- ac.meta.retrieve(function(data){
- Y.log("data1.....");
- retrieved = data["mydata"];
- Y.log("data....."+ retrieved);
- ac.done({retrieved:"any....data"});
- });
- // ac.done({retrieved:retrieved});
- }
- };
+ 'index': function(ac) {
+ ac.done();
+ },
+ 'mytest': function(ac) {
+ //ac.models.AppLevelMojit.getData(function(mydata){
+ ac.models.get('DepCheckModel').getData(function(mydata) {
+ Y.log("data....." + mydata);
+ ac.done({
+ data: mydata
+ });
+ });
+ },
+ 'metachild': function(ac) {
+ ac.composite.done({
+ title: 'My Child Mojits:'
+ });
+ },
+ 'retrievedata': function(ac) {
+ //var retrieved = "old data";
+ var retrieved;
+ Y.log("data.....");
+ ac.meta.retrieve(function(data) {
+ Y.log("data1.....");
+ retrieved = data["mydata"];
+ Y.log("data....." + retrieved);
+ ac.done({
+ retrieved: "any....data"
+ });
+ });
+ // ac.done({retrieved:retrieved});
+ }
+ };
}, '0.0.1', {requires: [
'mojito',
@@ -29,12 +29,10 @@ YUI.add('MojitContainer', function(Y, NAME) {
myMojits: function(ac) {
Y.log('index()', 'debug', NAME);
- ac.composite.done({
- template: {
- title: 'My Child Mojits:'
- }
- });
-
+ ac.composite.done({
+ title: 'My Child Mojits:'
+ });
+
}
};
@@ -38,12 +38,11 @@ YUI.add('Container', function(Y, NAME) {
Y.log("***********************************************ChildName: " + childName + " and child spec: " + JSON.stringify(childSpec));
childInfo.push(info);
});
-
+
ac.composite.done({
- template: {
- title: "There are two children in this Container:", childData: childInfo
- }
- })
+ title: "There are two children in this Container:",
+ childData: childInfo
+ });
}
};
@@ -38,12 +38,10 @@ YUI.add('RefreshParent', function(Y, NAME) {
Y.log("**************ChildName: " + childName + " and child spec: " + JSON.stringify(childSpec));
childInfo.push(info);
});
-
+
ac.composite.done({
- template: {
- childData: childInfo
- }
- })
+ childData: childInfo
+ });
}
};
Oops, something went wrong.

0 comments on commit 6c6834c

Please sign in to comment.