OSDN Git Service

fix: view system2
[pettanr/pettanr.git] / app / assets / javascripts / models / panel.js.coffee
index 0884634..22102c5 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.Panel extends Peta.Root\r
-  url: '/panels/'\r
   \r
   @singular: () ->\r
     'Panel'\r
@@ -15,21 +14,15 @@ class Pettanr.Panel extends Peta.Root
     publish: 0\r
   } \r
   \r
-  author: () ->\r
-    Pettanr.cache.store(new Pettanr.Author({id: @get('author_id')}, {expire_time: (new Date)}))\r
-  \r
-  pp: () ->\r
-    new Pettanr.PanelPicture({id: @get('pp_id')})\r
-  \r
   with_elements: () ->\r
     new Pettanr.Panel.WithElements({id: @get('id')})\r
   \r
   overwrite: (options) ->\r
-    operators = options.operators\r
+    operators = Pettanr.cache.operators\r
     return false if not operators.author\r
     @set('author_id', operators.author.id)\r
   \r
-  is_visible: (operators) ->\r
+  is_visible: (operators = Pettanr.cache.operators) ->\r
     switch super(operators)\r
       when null # super return\r
         return true\r
@@ -40,9 +33,9 @@ class Pettanr.Panel extends Peta.Root
         @is_publish()\r
   \r
   overwrite: (options) ->\r
-    @set('author_id', options.operators.author.id)\r
+    @set('author_id', Pettanr.cache.operators.author.id)\r
   \r
-  is_usable: (operators) ->\r
+  is_usable: (operators = Pettanr.cache.operators) ->\r
     @is_visible(operators)\r
   \r
   is_publish: () ->\r
@@ -59,26 +52,24 @@ class Pettanr.Panel extends Peta.Root
     _.each @scenario_elements(), (elm) ->\r
       return if not elm.my_class().has_picture()\r
       pid = elm.get('picture_id')\r
-      r[pid] = elm.picture() if not r[pid]\r
+      r[pid] = true if not r[pid]\r
     r\r
   \r
-  my_url: () ->\r
-    '/' + @path_name() + '/' + @get('id')\r
+  label: (shorten_length) ->\r
+    @_label('caption', shorten_length)\r
   \r
   initialize: (attr = {}, options = {}) ->\r
     super(attr, options)\r
     @set(attr)\r
-    if @get('id')\r
-      @url = @my_url()\r
   \r
 class Pettanr.Panel.WithElements extends Pettanr.Panel\r
   \r
   fetch: (options) ->\r
-    @url = @my_url() + '?with_elements=true'\r
+    @url = @default_url() + '?with_elements=true'\r
     super(options)\r
   \r
   save: (attrs) ->\r
-    @url = @my_url()\r
+    @url = @default_url()\r
     method = if @isNew()\r
       'create'\r
     else\r
@@ -87,6 +78,7 @@ class Pettanr.Panel.WithElements extends Pettanr.Panel
     xhr = @sync(method, this, {\r
       attrs: {panel: attrs},\r
       success: (model, response, options) =>\r
+        _this.set(model, {silent: true})\r
         _this.trigger('save:success', _this, response)\r
       error: (model, response, options) =>\r
         _this.trigger('save:fail', _this, response)\r