class Locmare.ProfilerModule.Association extends Pettanr.View tagName: 'div' initialize: (options) -> @profiler = options.profiler @association_manifest = options.association_manifest @belongs_to = _.map @association_manifest.belongs_to, (belongs_to_manifest) => new Locmare.ProfilerModule.AssociationModule.BelongsTo({association: this, belongs_to_manifest: belongs_to_manifest}) @has_many = _.map @association_manifest.has_many, (list_manifest) => new Locmare.ProfilerModule.AssociationModule.HasMany({association: this, has_many_manifest: list_manifest}) @has_one = _.map @association_manifest.has_one, (list_manifest) => new Locmare.ProfilerModule.AssociationModule.HasOne({association: this, has_one_manifest: list_manifest}) @render() render: () -> this.$el.html('') caption = new Tag.Div({class_name: 'caption', content: 'associations'}) this.$el.append(caption.render().el) caption = new Tag.Div({class_name: 'caption', content: 'belongs_to'}) this.$el.append(caption.render().el) _.each @belongs_to, (f) => @listenTo(f, 'http_get', @http_get) @listenTo(f, 'pick', @click_pick) this.$el.append(f.clear().el) caption = new Tag.Div({class_name: 'caption', content: 'has_many'}) this.$el.append(caption.render().el) _.each @has_many, (f) => @listenTo(f, 'http_get', @http_get) @listenTo(f, 'pick', @click_pick) this.$el.append(f.clear().el) caption = new Tag.Div({class_name: 'caption', content: 'has_one'}) this.$el.append(caption.render().el) _.each @has_one, (f) => @listenTo(f, 'http_get', @http_get) @listenTo(f, 'pick', @click_pick) this.$el.append(f.clear().el) this item: () -> @profiler.item model_manifest: () -> Manifest.manifest().models[@profiler.item_name] add_pick: (target_model) -> _.each @belongs_to, (f) => f.add_pick(target_model) _.each @has_many, (f) => f.add_pick(target_model) _.each @has_one, (f) => f.add_pick(target_model) http_get: (url) -> @trigger('http_get', url) click_pick: (item) -> @trigger('pick', item) class Locmare.ProfilerModule.AssociationModule