OSDN Git Service

fix:replace row break
[pettanr/pettanr.git] / app / assets / javascripts / locmare / profiler / association / has_many.js.coffee
1 class Locmare.ProfilerModule.AssociationModule.HasMany extends Pettanr.View\r
2   tagName: 'div'\r
3   \r
4   initialize: (options) ->\r
5     @association = options.association\r
6     @has_many_manifest = options.has_many_manifest\r
7     @filer = null\r
8     controller = Manifest.manifest().controllers[@has_many_manifest.controller_name]\r
9     action = controller.actions[@has_many_manifest.action_name]\r
10     @list = Locmare.ListGroup.list(\r
11       action.path_name(), action.name, \r
12       {id: @item().get('id'), page: 1, page_size: 3}\r
13     )\r
14     @pager = new Locmare.ListGroupModule.LibModule.PagerModule.More({\r
15       params: {controller: action.path_name(), action: action.name, id: @item().get('id')}\r
16     })\r
17   \r
18   clear: () ->\r
19     this.$el.html('')\r
20     @list.open((page_status) =>\r
21       @set_filer()\r
22       @render()\r
23     )\r
24     this\r
25   \r
26   render: () ->\r
27     this.$el.html(@filer.el)\r
28     this\r
29   \r
30   set_filer: () ->\r
31     @filer = new Locmare.Filer({\r
32       item_name: @has_many_model().item_name(), \r
33       items: @list.items(), \r
34       pager: @pager, \r
35     })\r
36     @filer.render()\r
37     @listenTo(@filer, 'http_get', @http_get)\r
38     @listenTo(@filer, 'pick', @pick)\r
39   \r
40   item: () ->\r
41     @profiler().item\r
42   \r
43   has_many_model: () ->\r
44     @has_many_manifest.model()\r
45   \r
46   profiler: () ->\r
47     @association.profiler\r
48   \r
49   add_pick: (target_model) ->\r
50     @list.open((page_status) =>\r
51       @set_filer()\r
52       @render()\r
53       @filer.add_pick(target_model)\r
54     )\r
55   \r
56   http_get: (url) ->\r
57     @trigger('http_get', url)\r
58  \r
59   pick: (item) ->\r
60     @trigger('pick', item)\r
61   \r