OSDN Git Service

fix event
[pettanr/pettanr.git] / app / assets / javascripts / peta / item.js.coffee
index 2d5391a..477ad94 100644 (file)
@@ -11,7 +11,7 @@ class Peta.Item extends Backbone.Model
     this\r
   \r
   my_class: () ->\r
-    Pettanr[@constructor.name]\r
+    @constructor\r
   \r
   @my_peta: () ->\r
     return null if not Manifest.manifest().items\r
@@ -25,7 +25,8 @@ class Peta.Item extends Backbone.Model
     'Name'\r
   \r
   @plural: () ->\r
-    'Names'\r
+    table_name = Manifest.manifest().pluralize @item_name()\r
+    Pettanr.camelize(table_name)\r
   \r
   @class_name: () ->\r
     @singular()\r
@@ -54,6 +55,9 @@ class Peta.Item extends Backbone.Model
   @parent_model: () ->\r
     null\r
   \r
+  @has_picture: () ->\r
+    false\r
+  \r
   @path_name: (with_engine = false) ->\r
     @table_name()\r
   \r
@@ -78,10 +82,10 @@ class Peta.Item extends Backbone.Model
   #InstanceMethods\r
   \r
   singular: () ->\r
-    Pettanr[@constructor.name].singular()\r
+    @my_class().singular()\r
   \r
   plural: () ->\r
-    Pettanr[@constructor.name].plural()\r
+    @my_class().plural()\r
   \r
   item_name: () ->\r
     @my_class().item_name()\r
@@ -114,15 +118,16 @@ class Peta.Item extends Backbone.Model
       @item_name()\r
   \r
   boosts: (level) ->\r
-    _this = this\r
     c = @my_class().my_peta().boost\r
-    _.each c, (boost_manifest, boost_name) ->\r
-      next if level == 'read' and boost_manifest.level == 'post'\r
-      _this.boost boost_manifest\r
+    _.each c, (boost_manifest, boost_name) =>\r
+      return if level == 'read' and boost_manifest.level == 'post'\r
+      @boost boost_manifest\r
   \r
   boost: (boost_manifest) ->\r
     @boosters ||= {}\r
-    @boosters[boost_manifest.name] ||= new Locmare.Booster(boost_manifest, this)\r
+    @boosters[boost_manifest.name] = new Locmare.Booster(boost_manifest, this)\r
+    # fetched item is not cleared .  force write booster\r
+    #@boosters[boost_manifest.name] ||= new Locmare.Booster(boost_manifest, this)\r
   \r
   boosters: () ->\r
     @boosters ||= {}\r
@@ -137,6 +142,30 @@ class Peta.Item extends Backbone.Model
       return false if not operators.is_resource_reader()\r
     true\r
   \r
+  icon_view: (half) ->\r
+    new Pettanr.Views[@my_class().singular()].Icon({item: this, half: half})\r
+  \r
+  @index_url: () ->\r
+    Pettanr.url(@table_name(), 'index', {id: null})\r
+  \r
+  index_url: () ->\r
+    @my_class().index_url()\r
+  \r
+  list_url: (action_name = 'index') ->\r
+    Pettanr.url(@table_name(), action_name, {id: @get('id')})\r
+  \r
+  show_url: () ->\r
+    Pettanr.url(@table_name(), 'show', {id: @get('id')})\r
+  \r
+  prof_url: () ->\r
+    Pettanr.url(@table_name(), 'show', {id: @get('id'), format: 'prof'})\r
+  \r
+  edit_url: () ->\r
+    Pettanr.url(@table_name(), 'edit', {id: @get('id')})\r
+  \r
+  destroy_url: () ->\r
+    Pettanr.url(@table_name(), 'destroy', {id: @get('id')})\r
+  \r
   is_editize: () ->\r
     @editor\r
   \r