OSDN Git Service

v07
[pettanr/pettanr.git] / app / assets / javascripts / models / sheet.js.coffee
index d4ee92d..ecfba80 100644 (file)
@@ -1,25 +1,38 @@
-class Sheet extends Item\r
-  @single: () ->\r
+class Pettanr.Sheet extends Peta.Root\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
-  initialize: () ->\r
-    confirm("Welcome to Panel")\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
+  label: (shorten_length) ->\r
+    @_label('title', shorten_length)\r
+  \r
+  # item is root, but binder like\r
+  play_url: () ->\r
+    Pettanr.url(@table_name(), 'play', {id: @get('id')})\r
   \r
-  @test: () ->\r
-    confirm( @single())\r
-    confirm( @plural() )\r
-    confirm( @class_name() )\r
-    confirm( @element_name() )\r
-    confirm( @table_name() )\r
-    \r
+  initialize: (attr = {}, options = {}) ->\r
+    super(attr, options)\r
   \r
-  test: () ->\r
-\r
-@Panel = Panel\r