OSDN Git Service

fix: views
[pettanr/pettanr.git] / app / assets / javascripts / views / original_pictures / summary.js.coffee
index 3782bc9..9a911cc 100644 (file)
@@ -1,24 +1,26 @@
-class Pettanr.Views.OriginalPicture.Summary extends Backbone.View\r
+class Pettanr.Views.OriginalPicture.Summary extends Pettanr.View.Summary\r
   className: 'op-smy'\r
   \r
   initialize: (options) ->\r
-    @item = options.item\r
-    #@item = new Pettanr.OriginalPicture({id: options.item.get('id')}) # with resource_picture\r
+    super(options)\r
   \r
   render: () ->\r
-    _this = this\r
-    @item.fetch({cache: false}).done ->\r
-      _this.$el.html('')\r
-      visible = new Tag.Span({\r
-        class_name: 'state',\r
-        content: I18n.t('original_pictures.' + _this.item.state())\r
-      })\r
-      _this.$el.append(visible.render().el)\r
-      if ra = _this.item.get('resource_picture')\r
-        resource_picture = new Pettanr.ResourcePicture(ra)\r
-        credit = resource_picture.credit_view(true)\r
-        _this.$el.append(credit.render().el)\r
-      rb = new Tag.RowBreak()\r
-      _this.$el.append(rb.render().el)\r
+    super()\r
+    @visible = new Tag.Span({\r
+      class_name: 'state',\r
+      content: I18n.t('original_pictures.' + @item.state())\r
+    })\r
+    this.$el.html('')\r
+    this.$el.append(@visible.render().el)\r
+    @item.get_child('resource_picture', this, {\r
+      success: (@resource_picture) =>\r
+        if @resource_picture\r
+          @resource_picture.get_parent('picture', this, {\r
+            success: (@picture) =>\r
+              @credit = new Pettanr.View.Credit(@picture, {icon: false})\r
+              this.$el.append(@credit.render().el)\r
+              @append_rb()\r
+          })\r
+    })\r
     this\r
   \r