1 class Pettanr.Panel extends Peta.Root
\r
18 new Pettanr.Cache.Retriever(Pettanr.Author, @get('author_id'))
\r
20 with_elements: () ->
\r
21 new Pettanr.Panel.WithElements({id: @get('id')})
\r
23 overwrite: (options) ->
\r
24 operators = Pettanr.cache.operators
\r
25 return false if not operators.author
\r
26 @set('author_id', operators.author.id)
\r
28 is_visible: (operators = Pettanr.cache.operators) ->
\r
29 switch super(operators)
\r
30 when null # super return
\r
35 return true if @isNew()
\r
38 overwrite: (options) ->
\r
39 @set('author_id', Pettanr.cache.operators.author.id)
\r
41 is_usable: (operators = Pettanr.cache.operators) ->
\r
42 @is_visible(operators)
\r
47 @licensed_pictures: (panels) ->
\r
49 _.each panels, (panel) ->
\r
50 _.extend r, panel.licensed_pictures()
\r
53 licensed_pictures: () ->
\r
55 _.each @scenario_elements(), (elm) ->
\r
56 return if not elm.my_class().has_picture()
\r
57 pid = elm.get('picture_id')
\r
58 r[pid] = elm.picture() if not r[pid]
\r
61 initialize: (attr = {}, options = {}) ->
\r
62 super(attr, options)
\r
65 class Pettanr.Panel.WithElements extends Pettanr.Panel
\r
68 @url = @default_url() + '?with_elements=true'
\r
72 @url = @default_url()
\r
73 method = if @isNew()
\r
78 xhr = @sync(method, this, {
\r
79 attrs: {panel: attrs},
\r
80 success: (model, response, options) =>
\r
81 _this.set(model, {silent: true})
\r
82 _this.trigger('save:success', _this, response)
\r
83 error: (model, response, options) =>
\r
84 _this.trigger('save:fail', _this, response)
\r
88 destroy: (options) ->
\r