OSDN Git Service

946f9821d5ea1538ae37a45f7836fda0ef15b8d2
[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     @params = options.options\r
7     \r
8     @list_group_manifest = LocalManifest.manifest().list_groups[@list_group_name]\r
9     @list_manifest = @list_group_manifest.lists[@list_name]\r
10     \r
11     @controller_name = @list_group_name\r
12     @action_name = @list_name\r
13     @controller_manifest = Manifest.manifest().controllers[@controller_name]\r
14     @action_manifest = @controller_manifest.actions[@action_name]\r
15     @item_name = @action_manifest.item_name\r
16     @model_class = Manifest.item_name_to_model @item_name\r
17     @table_name = @model_class.table_name()\r
18     \r
19   parse: (res) ->\r
20     @page_status = res.page_status\r
21     res.list\r
22   \r
23   items: () ->\r
24     _.map @models, (model) =>\r
25       item = new @model_class(model.attributes)\r
26       Pettanr.cache.store(item)\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