OSDN Git Service

operator move to cache
[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       {id: @item().get('id')}\r
13     )\r
14     @list.open((page_status) =>\r
15       @set_filer()\r
16       @render()\r
17     )\r
18   \r
19   clear: () ->\r
20     this.$el.html('')\r
21     this\r
22   \r
23   render: () ->\r
24     this.$el.html('')\r
25     this.$el.html(@filer.el)\r
26     this\r
27   \r
28   set_filer: () ->\r
29     @filer = new Locmare.Filer({\r
30       item_name: @has_one_model().item_name(), \r
31       items: @list.items(), \r
32       pager: @pager, \r
33     })\r
34     @filer.render()\r
35     @listenTo(@filer, 'http_get', @http_get)\r
36     @listenTo(@filer, 'pick', @pick)\r
37   \r
38   item: () ->\r
39     @profiler().item\r
40   \r
41   has_one_model: () ->\r
42     @has_one_manifest.model()\r
43   \r
44   profiler: () ->\r
45     @association.profiler\r
46   \r
47   add_pick: (target_model) ->\r
48     @list.open((page_status) =>\r
49       @set_filer()\r
50       @render()\r
51       @filer.add_pick(target_model)\r
52     )\r
53   \r
54   http_get: (url) ->\r
55     @trigger('http_get', url)\r
56   \r
57   pick: (item) ->\r
58     @trigger('pick', item)\r
59   \r