X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fpanel.js.coffee;h=c3479411e5d36e69a2be32a6ececb9f180f04aae;hb=6b12a345e25cadadaf2a4cc15b8f4967193d6afb;hp=c68472890747469bb822f4cb9aa236ce889f3b66;hpb=091b085aa054691dfe37d6f55f699dcb80f63ee5;p=pettanr%2Fpettanr.git diff --git a/app/assets/javascripts/models/panel.js.coffee b/app/assets/javascripts/models/panel.js.coffee index c6847289..c3479411 100644 --- a/app/assets/javascripts/models/panel.js.coffee +++ b/app/assets/javascripts/models/panel.js.coffee @@ -19,6 +19,9 @@ class Pettanr.Panel extends Peta.Root pp: () -> new Pettanr.PanelPicture({id: @get('pp_id')}) + with_elements: () -> + new Pettanr.Panel.WithElements({id: @get('id')}) + is_visible: (operators) -> switch super(operators) when null # super return @@ -52,13 +55,34 @@ class Pettanr.Panel extends Peta.Root r[pid] = elm.picture() if not r[pid] r + my_url: () -> + '/' + @path_name() + '/' + @get('id') + initialize: (attr = {}, options = {}) -> @set(attr) if @get('id') - @url = @url + @get('id') - if options.with_elements - @url = @url + '?with_elements=true' + @url = @my_url() @bind('change:width', () -> console.log('cng') ) +class Pettanr.Panel.WithElements extends Pettanr.Panel + + fetch: (options) -> + @url = @my_url() + '?with_elements=true' + super(options) + + save: (attrs, options = {}) -> + @url = @my_url() + options.attrs = {panel: attrs} + method = if @isNew() + 'create' + else + 'update' + xhr = @sync(method, this, options) + xhr + + destroy: (options) -> + @url = @my_url() + super(options) +