OSDN Git Service

fix: new elm
[pettanr/pettanr.git] / app / assets / javascripts / models / panel.js.coffee
index 2d5d711..7b13d47 100644 (file)
@@ -22,11 +22,11 @@ class Pettanr.Panel extends Peta.Root
     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
@@ -37,9 +37,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
@@ -60,15 +60,17 @@ class Pettanr.Panel extends Peta.Root
     r\r
   \r
   my_url: () ->\r
-    '/' + @path_name() + '/' + @get('id')\r
+    s = if @get('id')\r
+      '/' + @get('id')\r
+    else\r
+      ''\r
+    '/' + @path_name() + s\r
   \r
   initialize: (attr = {}, options = {}) ->\r
+    super(attr, options)\r
     @set(attr)\r
     if @get('id')\r
       @url = @my_url()\r
-    @bind('change:width', () ->\r
-      console.log('cng')\r
-    )\r
   \r
 class Pettanr.Panel.WithElements extends Pettanr.Panel\r
   \r
@@ -86,6 +88,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