(function(){RB.Config={};"use strict";RB.Config.ResourceListItem=Djblets.Config.ListItem.extend({defaults:_.defaults({resource:null},Djblets.Config.ListItem.prototype.defaults),syncAttrs:[],initialize:function initialize(){var _this=this;var resource=this.get("resource");if(resource){this.set(_.pick(resource.attributes,this.syncAttrs))}else{resource=this.createResource(_.extend({id:this.get("id")},_.pick(this.attributes,this.syncAttrs)));this.set("resource",resource)}this.resource=resource;Djblets.Config.ListItem.prototype.initialize.apply(this,arguments);this.listenTo(resource,"request",function(){for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}return _this.trigger.apply(_this,["request"].concat(args))});this.listenTo(resource,"sync",function(){for(var _len2=arguments.length,args=Array(_len2),_key2=0;_key2<_len2;_key2++){args[_key2]=arguments[_key2]}return _this.trigger.apply(_this,["sync"].concat(args))});this.listenTo(resource,"destroy",this.destroy);this.syncAttrs.forEach(function(attr){return _this.listenTo(resource,"change:"+attr,function(model,value){return _this.set(attr,value)})})},createResource:function createResource(){console.assert(false,"createResource must be implemented")},destroy:function destroy(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};this.stopListening(this.resource);this.trigger("destroy",this,this.collection,options);if(_.isFunction(options.success)){options.success(this,null,options)}}})}).call(this);
