OSDN Git Service

js viewer worked
[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.table_name]\r
9     action = controller.actions[@has_one_manifest.list_name]\r
10     @list = Locmare.ListGroup.list(@has_one_manifest.item_name, @has_one_manifest.list_name)\r
11     params = {id: @item().get('id')}\r
12     _this = this\r
13     @list.open(@profiler().operators, params, action, {}, (page_status) ->\r
14       _this.filer = new Locmare.Filer({\r
15         item_name: _this.has_one_model().item_name(), \r
16         items: _this.list.models, \r
17         pager: _this.pager, \r
18         operators: _this.profiler().operators\r
19       })\r
20       _this.render()\r
21     )\r
22   \r
23   render: () ->\r
24     this.$el.html('')\r
25     if @filer\r
26       this.$el.html(@filer.render().el)\r
27     this\r
28   \r
29   item: () ->\r
30     @profiler().item\r
31   \r
32   has_one_model: () ->\r
33     @has_one_manifest.model()\r
34   \r
35   profiler: () ->\r
36     @association.profiler\r
37   \r