X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fpanel.js.coffee;h=22102c56c9d389f970cd6aed718049fb4dd4e1a9;hb=dbe1cc622a8fda2e7f24294b97dbd064c1cb197e;hp=b1f8741330795ba1a914d92b9f9db42418e52cfb;hpb=fb42dde11a2dd2530b5418f3182fc2b67e4285a8;p=pettanr%2Fpettanr.git diff --git a/app/assets/javascripts/models/panel.js.coffee b/app/assets/javascripts/models/panel.js.coffee index b1f87413..22102c56 100644 --- a/app/assets/javascripts/models/panel.js.coffee +++ b/app/assets/javascripts/models/panel.js.coffee @@ -1,5 +1,4 @@ class Pettanr.Panel extends Peta.Root - url: '/panels/' @singular: () -> 'Panel' @@ -15,9 +14,6 @@ class Pettanr.Panel extends Peta.Root publish: 0 } - author: () -> - new Pettanr.Cache.Retriever(Pettanr.Author, @get('author_id')) - with_elements: () -> new Pettanr.Panel.WithElements({id: @get('id')}) @@ -56,30 +52,24 @@ class Pettanr.Panel extends Peta.Root _.each @scenario_elements(), (elm) -> return if not elm.my_class().has_picture() pid = elm.get('picture_id') - r[pid] = elm.picture() if not r[pid] + r[pid] = true if not r[pid] r - my_url: () -> - s = if @get('id') - '/' + @get('id') - else - '' - '/' + @path_name() + s + label: (shorten_length) -> + @_label('caption', shorten_length) initialize: (attr = {}, options = {}) -> super(attr, options) @set(attr) - if @get('id') - @url = @my_url() class Pettanr.Panel.WithElements extends Pettanr.Panel fetch: (options) -> - @url = @my_url() + '?with_elements=true' + @url = @default_url() + '?with_elements=true' super(options) save: (attrs) -> - @url = @my_url() + @url = @default_url() method = if @isNew() 'create' else @@ -88,6 +78,7 @@ class Pettanr.Panel.WithElements extends Pettanr.Panel xhr = @sync(method, this, { attrs: {panel: attrs}, success: (model, response, options) => + _this.set(model, {silent: true}) _this.trigger('save:success', _this, response) error: (model, response, options) => _this.trigger('save:fail', _this, response)