class Pettanr.Panel extends Peta.Root url: '/panels/' @singular: () -> 'Panel' @plural: () -> 'Panels' defaults: { id: null, border: 2, publish: 0 } author: () -> new Pettanr.Author({id: @get('author_id')}) pp: () -> new Pettanr.PanelPicture({id: @get('pp_id')}) is_visible: (operators) -> switch super(operators) when null # super return return true when false return false else return true if @isNew() @is_publish() overwrite: (options) -> @set('author_id', options.operators.author.id) is_usable: (operators) -> @is_visible(operators) is_publish: () -> @get('publish') > 0 @licensed_pictures: (panels) -> r = {} _.each panels, (panel) -> _.extend r, panel.licensed_pictures() r licensed_pictures: () -> r = {} _.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 save_with_elements: (attrs, options = {}) -> options.attrs = {panel: attrs} method = if @isNew() 'create' else 'update' xhr = @sync(method, this, options) xhr initialize: (attr = {}, options = {}) -> @set(attr) if @get('id') @url = @url + @get('id') if options.with_elements @url = @url + '?with_elements=true' @bind('change:width', () -> console.log('cng') )