OSDN Git Service

fix: js models
[pettanr/pettanr.git] / app / assets / javascripts / models / story.js.coffee
index 6ab4cf1..a67d8ae 100644 (file)
@@ -1,15 +1,29 @@
 class Pettanr.Story extends Peta.Binder\r
-  @single: () ->\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
+  is_visible: (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: () ->\r
-    confirm("Welcome to Panel")\r
+    if @id\r
+      @url = @url + @id\r
   \r
-\r
+class Pettanr.Story.Collection extends Backbone.Collection\r
+  model: Pettanr.Story\r
+  url: '/stories'\r