@filer_list()\r
\r
show_html: () ->\r
- @item = new Pettanr.Panel({id: @item.get('id')}, {with_elements: true}) # retake panel for 'with_elements' mode\r
+ @item = new Pettanr.Panel.WithElements({id: @item.get('id')}) # retake panel for 'with_elements' mode\r
@item.fetch({cache: false}).done =>\r
@trigger('retitle', @params, @item.get('caption'))\r
show = new Pettanr.Views.Panel.Show({\r
_.each @fields, (field) =>\r
@item.set(field.field_name, field.val())\r
if @item.save()\r
- window.router.navigate('/' + @item.table_name() + '/' + Pettanr.to_s(@item.get('id')), true)\r
+ # redirect_to show\r
+ @trigger('navigate', @item.show_url())\r
return false\r
else\r
+ # render_form\r
alert('invalid')\r
\r
put: () ->\r
\r
save: (attrs = null, options = null) ->\r
if attrs\r
- @item.save_with_elements(attrs, options)\r
+ @item.save(attrs, options)\r
else\r
@item.save()\r
\r
pp: () ->\r
new Pettanr.PanelPicture({id: @get('pp_id')})\r
\r
+ with_elements: () ->\r
+ new Pettanr.Panel.WithElements({id: @get('id')})\r
+ \r
is_visible: (operators) ->\r
switch super(operators)\r
when null # super return\r
r[pid] = elm.picture() if not r[pid]\r
r\r
\r
- save_with_elements: (attrs, options = {}) ->\r
+ my_url: () ->\r
+ '/' + @path_name() + '/' + @get('id')\r
+ \r
+ initialize: (attr = {}, options = {}) ->\r
+ @set(attr)\r
+ if @get('id')\r
+ @url = @my_url()\r
+ @bind('change:width', () ->\r
+ console.log('cng')\r
+ )\r
+ \r
+class Pettanr.Panel.WithElements extends Pettanr.Panel\r
+ \r
+ fetch: (options) ->\r
+ @url = @my_url() + '?with_elements=true'\r
+ super(options)\r
+ \r
+ save: (attrs, options = {}) ->\r
+ @url = @my_url()\r
options.attrs = {panel: attrs}\r
method = if @isNew()\r
'create'\r
xhr = @sync(method, this, options)\r
xhr\r
\r
- initialize: (attr = {}, options = {}) ->\r
- @set(attr)\r
- if @get('id')\r
- @url = @url + @get('id')\r
- if options.with_elements\r
- @url = @url + '?with_elements=true'\r
- @bind('change:width', () ->\r
- console.log('cng')\r
- )\r
+ destroy: (options) ->\r
+ @url = @my_url()\r
+ super(options)\r
\r
new Pettanr.Scroll({id: @get('scroll_id')})\r
\r
panel: () ->\r
- new Pettanr.Panel({id: @get('panel_id')}, {with_elements: true})\r
+ # get with elm in case play mode\r
+ new Pettanr.Panel.WithElements({id: @get('panel_id')})\r
\r
has_panel: () ->\r
if @get('panel_id')\r
@listenTo(this, 'ready', @ready)\r
@speech_balloon = @item.speech_balloon()\r
@speech_balloon.fetch({cache: true}).done =>\r
- @panel = @speech_balloon.panel({with_elements: true})\r
+ @panel = @speech_balloon.panel().with_elements()\r
@panel.fetch({cache: false}).done => # with elements\r
@author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
@body = new Pettanr.Views.Panel.Body({\r
prof_url: prof_url\r
})\r
@listenTo(this, 'ready', @ready)\r
- @panel = @item.panel({with_elements: true})\r
+ @panel = @item.panel().with_elements()\r
@panel.fetch({cache: false}).done => # with elements\r
@author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
@body = new Pettanr.Views.Panel.Body({\r
prof_url: prof_url\r
})\r
@listenTo(this, 'ready', @ready)\r
- @panel = @item.panel({with_elements: true})\r
+ @panel = @item.panel().with_elements()\r
@panel.fetch({cache: false}).done => # with elements\r
@author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
@body = new Pettanr.Views.Panel.Body({\r
prof_url: prof_url\r
})\r
@listenTo(this, 'ready', @ready)\r
- @panel = @item.panel({with_elements: true})\r
+ @panel = @item.panel().with_elements()\r
@panel.fetch({cache: false}).done => # with elements\r
@author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
@body = new Pettanr.Views.Panel.Body({\r
prof_url: prof_url\r
})\r
@listenTo(this, 'ready', @ready)\r
- @panel = @item.panel({with_elements: true})\r
+ @panel = @item.panel().with_elements()\r
@panel.fetch({cache: false}).done => # with elements\r
@author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
@body = new Pettanr.Views.Panel.Body({\r
@listenTo(this, 'ready', @ready)\r
@speech_balloon = @item.speech_balloon()\r
@speech_balloon.fetch({cache: true}).done =>\r
- @panel = @speech_balloon.panel({with_elements: true})\r
+ @panel = @speech_balloon.panel().with_elements()\r
@panel.fetch({cache: false}).done => # with elements\r
@author = new Pettanr.Views.Show.HeaderAuthor({item: @panel})\r
@body = new Pettanr.Views.Panel.Body({\r