Permalink
Browse files

restructure instance_list, need to modify instance to match

  • Loading branch information...
herbdaily committed Mar 29, 2012
1 parent bd3d8e6 commit 42469011f6b1970802b3f388c4972985227d7c5c
Showing with 27 additions and 16 deletions.
  1. +1 −0 lib/marley/client/jamaica.js
  2. +26 −16 lib/marley/client/reggae.js
@@ -26,6 +26,7 @@ pl(function(){
});
j={
+ copyObj:function(o){return JSON.parse(JSON.stringify(o));},
ajax_defaults:{
load:function(){pl('body').css('cursor','wait')},
always:function(){pl('body').css('cursor','default');},
@@ -164,24 +164,34 @@ r.nodeTypes={
"populate_schema":function(schema, vals){
},
"instance_list":function(il) {
- var schema=il.attrs.schema;
var name=il.attrs.name;
- var content_schema=[];
- while(schema[schema.length-1][0]=='resource'){
- content_schema << schema.pop();
- }
+ var schema=j.copyObj(il.attrs.schema);
+ if (il.attrs.recursive) { schema.push(il.attrs.schema);};
return pl.map(il.attrs.items,function(vals){
- var i=0;
- return r.call(["instance",{
- "name":name,
- "new_rec":false,
- "url":'asdf', //FIX THIS
- "schema": pl.map(schema, function(col){
- col[VALUE_INDEX]=vals[i];
- i++;
- return col;
- }),
- }]);
+ var instance_schema=[];
+ var content=[];
+ pl.each(schema, function(i,col_spec){
+ if (pl.type(col_spec[0], 'arr')) { //this is another schema
+ content.push(
+ ["instance_list",{
+ "schema":col_spec,
+ "items":vals[i],
+ "name":name
+ }]
+ );
+ } else {
+ instance_schema.push(col_spec.push(vals[i]));
+ }
+ });
+ return ["instance",
+ {
+ "name":name,
+ "new_rec":false,
+ "url":'asdf', //FIX THIS
+ "schema": instance_schema,
+ },
+ content
+ ];
});
},
};

0 comments on commit 4246901

Please sign in to comment.