class Pettanr.Panel extends Peta.Root\r
- url: '/panels/'\r
\r
@singular: () ->\r
'Panel'\r
publish: 0\r
} \r
\r
- author: () ->\r
- new Pettanr.Cache.Retriever(Pettanr.Author, @get('author_id'))\r
- \r
with_elements: () ->\r
new Pettanr.Panel.WithElements({id: @get('id')})\r
\r
_.each @scenario_elements(), (elm) ->\r
return if not elm.my_class().has_picture()\r
pid = elm.get('picture_id')\r
- r[pid] = elm.picture() if not r[pid]\r
+ r[pid] = true if not r[pid]\r
r\r
\r
- my_url: () ->\r
- s = if @get('id')\r
- '/' + @get('id')\r
- else\r
- ''\r
- '/' + @path_name() + s\r
+ label: (shorten_length) ->\r
+ @_label('caption', shorten_length)\r
+ \r
+ play: () ->\r
+ new Pettanr.Panel.Play({id: @get('id')})\r
+ \r
+ edit: (options) ->\r
+ i = new Pettanr.Panel.Edit({id: @get('id')})\r
+ i.load(options)\r
\r
initialize: (attr = {}, options = {}) ->\r
super(attr, options)\r
@set(attr)\r
- if @get('id')\r
- @url = @my_url()\r
\r
-class Pettanr.Panel.WithElements extends Pettanr.Panel\r
+class Pettanr.Panel.Play extends Pettanr.Panel\r
\r
fetch: (options) ->\r
- @url = @my_url() + '?with_elements=true'\r
+ @url = @default_url() + '?with_elements=true'\r
super(options)\r
\r
+class Pettanr.Panel.Edit extends Pettanr.Panel.Play\r
+ \r
+ load: (options) ->\r
+ @fetch().done =>\r
+ @attributes = @decoded_attributes()\r
+ @load_elements(options)\r
+ \r
save: (attrs) ->\r
- @url = @my_url()\r
+ @url = @default_url()\r
method = if @isNew()\r
'create'\r
else\r