OSDN Git Service

fix: js models
[pettanr/pettanr.git] / app / assets / javascripts / models / speech_balloon_template.js.coffee
index 0416833..f86a167 100644 (file)
@@ -1,25 +1,40 @@
-class SpeechBalloonTemplate extends Item\r
-  @single: () ->\r
+class Pettanr.SpeechBalloonTemplate extends Peta.Template\r
+  relations: [{\r
+    type: Backbone.HasMany,\r
+    key: 'speech_balloons',\r
+    relatedModel: 'SpeechBalloon',\r
+    collectionType: 'SpeechBalloonCollection',\r
+    reverseRelation: {\r
+      key: 'livesIn',\r
+      includeInJSON: 'id'\r
+    }\r
+  }]\r
+  \r
+  @singular: () ->\r
     'SpeechBalloonTemplate'\r
   \r
   @plural: () ->\r
     'SpeechBalloonTemplates'\r
   \r
   defaults: {\r
-    id: 11\r
+    id: null\r
   } \r
   \r
-  initialize: () ->\r
-    confirm("Welcome to Panel")\r
+  get_system_picture: () ->\r
+    new Pettanr.SystemPicture({id: @get('system_picture_id')})\r
   \r
-  @test: () ->\r
-    confirm( @single())\r
-    confirm( @plural() )\r
-    confirm( @class_name() )\r
-    confirm( @element_name() )\r
-    confirm( @table_name() )\r
-    \r
+  symbol_option: () ->\r
+    _this = this\r
+    r = @get_system_picture()\r
+    r.fetch({}).done () ->\r
+      _this.system_picture = r\r
+      _this.system_picture.tmb_opt_img_tag()\r
+  \r
+  initialize: () ->\r
+    if @id\r
+      @url = @url + @id\r
+    @system_picture = null\r
   \r
-  test: () ->\r
-\r
-@Panel = Panel\r
+class Pettanr.SpeechBalloonTemplate.Collection extends Backbone.Collection\r
+  model: Pettanr.SpeechBalloonTemplate\r
+  url: '/speech_balloon_templates'\r