1 class Locmare.ProfilerModule.Association extends Pettanr.View
\r
4 initialize: (options) ->
\r
5 @profiler = options.profiler
\r
6 @association_manifest = options.association_manifest
\r
7 @belongs_to = _.map @association_manifest.belongs_to, (belongs_to_manifest) =>
\r
8 new Locmare.ProfilerModule.AssociationModule.BelongsTo({association: this, belongs_to_manifest: belongs_to_manifest})
\r
9 @has_many = _.map @association_manifest.has_many, (list_manifest) =>
\r
10 new Locmare.ProfilerModule.AssociationModule.HasMany({association: this, has_many_manifest: list_manifest})
\r
11 @has_one = _.map @association_manifest.has_one, (list_manifest) =>
\r
12 new Locmare.ProfilerModule.AssociationModule.HasOne({association: this, has_one_manifest: list_manifest})
\r
17 caption = new Tag.Div({class_name: 'caption', content: 'associations'})
\r
18 this.$el.append(caption.render().el)
\r
19 caption = new Tag.Div({class_name: 'caption', content: 'belongs_to'})
\r
20 this.$el.append(caption.render().el)
\r
21 _.each @belongs_to, (f) =>
\r
22 @listenTo(f, 'http_get', @http_get)
\r
23 @listenTo(f, 'pick', @click_pick)
\r
24 this.$el.append(f.clear().el)
\r
25 caption = new Tag.Div({class_name: 'caption', content: 'has_many'})
\r
26 this.$el.append(caption.render().el)
\r
27 _.each @has_many, (f) =>
\r
28 @listenTo(f, 'http_get', @http_get)
\r
29 @listenTo(f, 'pick', @click_pick)
\r
30 this.$el.append(f.clear().el)
\r
31 caption = new Tag.Div({class_name: 'caption', content: 'has_one'})
\r
32 this.$el.append(caption.render().el)
\r
33 _.each @has_one, (f) =>
\r
34 @listenTo(f, 'http_get', @http_get)
\r
35 @listenTo(f, 'pick', @click_pick)
\r
36 this.$el.append(f.clear().el)
\r
42 model_manifest: () ->
\r
43 Manifest.manifest().models[@profiler.item_name]
\r
45 add_pick: (target_model) ->
\r
46 _.each @belongs_to, (f) =>
\r
47 f.add_pick(target_model)
\r
48 _.each @has_many, (f) =>
\r
49 f.add_pick(target_model)
\r
50 _.each @has_one, (f) =>
\r
51 f.add_pick(target_model)
\r
54 @trigger('http_get', url)
\r
56 click_pick: (item) ->
\r
57 @trigger('pick', item)
\r
59 class Locmare.ProfilerModule.AssociationModule
\r