OSDN Git Service

fix: show's destroy button
[pettanr/pettanr.git] / app / assets / javascripts / models / story.js.coffee
index 6ab4cf1..606df47 100644 (file)
@@ -1,15 +1,34 @@
 class Pettanr.Story extends Peta.Binder\r
-  @single: () ->\r
+  \r
+  @singular: () ->\r
     'Story'\r
   \r
   @plural: () ->\r
     'Stories'\r
   \r
   defaults: {\r
-    id: 11\r
+    id: null,\r
+    visible: 0,\r
+    author_id: null\r
   } \r
   \r
-  initialize: () ->\r
-    confirm("Welcome to Panel")\r
+  author: () ->\r
+    new Pettanr.Cache.Retriever(Pettanr.Author, @get('author_id'))\r
+  \r
+  overwrite: (options) ->\r
+    operators = Pettanr.cache.operators\r
+    return false if not operators.author\r
+    @set('author_id', operators.author.id)\r
+  \r
+  is_visible: (operators = Pettanr.cache.operators) ->\r
+    switch super(operators)\r
+      when null\r
+        return true\r
+      when false\r
+        return false\r
+      else\r
+        @get('visible') > 0\r
+  \r
+  initialize: (attr = {}, options = {}) ->\r
+    super(attr, options)\r
   \r
-\r