OSDN Git Service

fix event
[pettanr/pettanr.git] / app / assets / javascripts / locmare / profiler / association / has_one.js.coffee
1 class Locmare.ProfilerModule.AssociationModule.HasOne extends Backbone.View\r
2   tagName: 'div'\r
3   \r
4   initialize: (options) ->\r
5     @association = options.association\r
6     @has_one_manifest = options.has_one_manifest\r
7     @filer = null\r
8     controller = Manifest.manifest().controllers[@has_one_manifest.controller_name]\r
9     action = controller.actions[@has_one_manifest.action_name]\r
10     @list = Locmare.ListGroup.list(\r
11       action.path_name(), action.name, \r
12       @profiler().operators, {id: @item().get('id')}\r
13     )\r
14     @list.open((page_status) =>\r
15       @filer = new Locmare.Filer({\r
16         item_name: @has_one_model().item_name(), \r
17         items: @list.items(), \r
18         pager: @pager, \r
19         operators: @profiler().operators\r
20       })\r
21       @listenTo(@filer, 'navigate', @navigate)\r
22       @render()\r
23     )\r
24   \r
25   render: () ->\r
26     this.$el.html('')\r
27     if @filer\r
28       this.$el.html(@filer.render().el)\r
29     this\r
30   \r
31   item: () ->\r
32     @profiler().item\r
33   \r
34   has_one_model: () ->\r
35     @has_one_manifest.model()\r
36   \r
37   profiler: () ->\r
38     @association.profiler\r
39   \r
40   navigate: (url) ->\r
41     @trigger('navigate', url)\r
42   \r