Created
October 20, 2011 13:37
-
-
Save diago/1301163 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
dojo.provide( 'outland.store.JsonRestTreeModel' ); | |
dojo.require( 'dojo.store.JsonRest' ); | |
dojo.declare | |
( 'outland.store.JsonRestTreeModel' | |
, [ dojo.store.JsonRest ] | |
, { idProperty : 'id' | |
, rootQuery : { name: 'CONTAINER' } | |
, mayHaveChildren : function(obj) { | |
return obj.has_children; | |
} // mayHaveChildren | |
, getChildren : function( obj, onComplete, onError ) { | |
if( ! onComplete) | |
onComplete = dojo.hitch( this, function( children ){ | |
this.onChildrenChange( obj, children ); | |
} ); | |
this.query( { parent_id: obj.id } ).then( onComplete, onError ); | |
} // getChildren | |
, getRoot : function( onItem, onError ) { | |
this.query( this.rootQuery ).then( function( root ){ | |
this.root = root[0]; | |
onItem( this.root ); | |
}, onError ); | |
} // getRoot | |
, getLabel : function( obj ) { | |
return obj.name ; | |
} // getLabel | |
, pasteItem : function( item, from, to ) { | |
item.parent_id = to.id | |
this.put( item ).then( dojo.hitch( this, function() { | |
this.getChildren( from ); | |
this.getChildren( to ); | |
} ) ); | |
} // pasteItem | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment