OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / models / license.js.coffee
index 214c4ac..c5f32eb 100644 (file)
@@ -1,15 +1,43 @@
 class Pettanr.License extends Peta.SystemResource\r
-  @single: () ->\r
+  url: '/licenses/'\r
+  \r
+  @singular: () ->\r
     'License'\r
   \r
   @plural: () ->\r
     'Licenses'\r
   \r
   defaults: {\r
-    id: 11\r
+    id: null\r
   } \r
   \r
+  license_group: () ->\r
+    r = new Pettanr.LicenseGroup({id: @get('license_group_id')})\r
+  \r
+  system_picture: () ->\r
+    new Pettanr.SystemPicture({id: @get('system_picture_id')})\r
+  \r
+  symbol_option: (cb) ->\r
+    i = @system_picture()\r
+    i.fetch({cache: true}).done ->\r
+      cb(i.tmb_opt_img_tag())\r
+  \r
+  caption_with_group: () ->\r
+    new Pettanr.License.Caption({license: this, license_group: @license_group()})\r
+  \r
   initialize: () ->\r
-    confirm("Welcome to Panel")\r
+    if @id\r
+      @url = @url + @id\r
+  \r
+class Pettanr.License.Caption extends Backbone.View\r
+  tagName: 'span'\r
+  initialize: (options) ->\r
+    @license = options.license\r
+    @license_group = options.license_group\r
+    \r
+  render: () ->\r
+    _this = this\r
+    @license_group.fetch({cache: true}).done ->\r
+      _this.$el.html(_this.license_group.get('caption') + '/' + _this.license.get('caption'))\r
+    this\r
   \r
-\r