OSDN Git Service

v07
[pettanr/pettanr.git] / app / assets / javascripts / models / sheet.js.coffee
index 6b1c72b..ecfba80 100644 (file)
@@ -1,5 +1,4 @@
 class Pettanr.Sheet extends Peta.Root\r
-  url: '/sheets/'\r
   \r
   @singular: () ->\r
     'Sheet'\r
@@ -13,10 +12,12 @@ class Pettanr.Sheet extends Peta.Root
     author_id: null\r
   } \r
   \r
-  author: () ->\r
-    new Pettanr.Author({id: @get('author_id')})\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) ->\r
+  is_visible: (operators = Pettanr.cache.operators) ->\r
     switch super(operators)\r
       when null\r
         return true\r
@@ -25,10 +26,13 @@ class Pettanr.Sheet extends Peta.Root
       else\r
         @get('visible') > 0\r
   \r
-  initialize: () ->\r
-    if @id\r
-      @url = @url + @id\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
+  initialize: (attr = {}, options = {}) ->\r
+    super(attr, options)\r
   \r
-class Pettanr.Sheet.Collection extends Backbone.Collection\r
-  model: Pettanr.Sheet\r
-  url: '/sheets'\r