OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / assets / javascripts / models / license.js.coffee
index dd57148..9f734b5 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.License extends Peta.SystemResource\r
-  url: '/licenses/'\r
   \r
   @singular: () ->\r
     'License'\r
@@ -11,27 +10,23 @@ class Pettanr.License extends Peta.SystemResource
     id: null\r
   } \r
   \r
-  license_group: () ->\r
-    r = new Pettanr.LicenseGroup({id: @get('license_group_id')})\r
+  @trace_routes: () ->\r
+    {\r
+      symbol: ['system_picture']\r
+    }\r
   \r
-  system_picture: () ->\r
-    new Pettanr.SystemPicture({id: @get('system_picture_id')})\r
+  caption_with_group: (context, options) ->\r
+    @get_parent('license_group', this, {\r
+      success: (license_group) => \r
+        caption = license_group.escape('caption') + '/' + @escape('caption')\r
+        options.success.call(context, caption)\r
+      fail: (response, opt) =>\r
+        options.fail.call(context, response, opt)\r
+    })\r
   \r
-  symbol_option: () ->\r
-    i = @system_picture()\r
-    i.fetch({cache: true}).done =>\r
-      @trigger('ready:symbol', i.tmb_opt_img_tag())\r
-  \r
-  caption_with_group: () ->\r
-    i = @license_group()\r
-    i.fetch({cache: true}).done =>\r
-      caption = i.escape('caption') + '/' + @escape('caption')\r
-      @trigger('ready:caption', caption)\r
   is_own: () ->\r
     true\r
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
-    if @id\r
-      @url = @url + @id\r
   \r