OSDN Git Service

0c0499914581f7c99e9881cbea1bb68e6d866110
[pettanr/pettanr.git] / app / assets / javascripts / locmare / list_group / list / base.js.coffee
1 class Locmare.ListGroupModule.Base extends Backbone.Collection\r
2   \r
3   initialize: (options) ->\r
4     @list_group_name = options.list_group_name\r
5     @list_name = options.list_name\r
6     @operators = options.operators\r
7     @params = options.options\r
8     \r
9     @list_group_manifest = LocalManifest.manifest().list_groups[@list_group_name]\r
10     @list_manifest = @list_group_manifest.lists[@list_name]\r
11     \r
12     @controller_name = @list_group_name\r
13     @action_name = @list_name\r
14     @controller_manifest = Manifest.manifest().controllers[@controller_name]\r
15     @action_manifest = @controller_manifest.actions[@action_name]\r
16     @item_name = @action_manifest.item_name\r
17     @model_class = Manifest.item_name_to_model @item_name\r
18     @table_name = @model_class.table_name()\r
19     \r
20   parse: (res) ->\r
21     @page_status = res.page_status\r
22     res.list\r
23   \r
24   items: () ->\r
25     _.map @models, (model) =>\r
26       new @model_class(model.attributes)\r
27   \r
28   count: () ->\r
29     new Pettanr.CounterModel({}, {url: '/' + @action_manifest.counter_url(@params)})\r
30   \r
31   open: (cb) ->\r
32     @url = '/' + @action_manifest.url(@params)\r
33     @fetch({cache: true}).done =>\r
34       # @boost(items)\r
35       cb()\r
36   \r