OSDN Git Service

change: cache system
[pettanr/pettanr.git] / app / assets / javascripts / models / sheet.js.coffee
index d4ee92d..959a870 100644 (file)
@@ -1,25 +1,36 @@
-class Sheet extends Item\r
-  @single: () ->\r
+class Pettanr.Sheet extends Peta.Root\r
+  url: '/sheets/'\r
+  \r
+  @singular: () ->\r
     'Sheet'\r
   \r
   @plural: () ->\r
     'Sheets'\r
   \r
   defaults: {\r
-    id: 11\r
+    id: null,\r
+    visible: 0,\r
+    author_id: null\r
   } \r
   \r
+  author: () ->\r
+    new Pettanr.Cache.Retriever(Pettanr.Author, @get('author_id'))\r
+  \r
+  overwrite: (options) ->\r
+    operators = options.operators\r
+    return false if not operators.author\r
+    @set('author_id', operators.author.id)\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
-  \r
-  @test: () ->\r
-    confirm( @single())\r
-    confirm( @plural() )\r
-    confirm( @class_name() )\r
-    confirm( @element_name() )\r
-    confirm( @table_name() )\r
-    \r
-  \r
-  test: () ->\r
-\r
-@Panel = Panel\r
+    if @id\r
+      @url = @url + @id\r
+  \r