class Pettanr.Views.OriginalPicture.Show extends Pettanr.View.Show initialize: (options) -> @header = new Pettanr.View.Show.Header(@item, this, @default_header_options()) @authored_by = @item.authored_by() @listenTo(@header, 'click:pick', @click_pick) @listenTo(@authored_by, 'click', @click_authored_by) @body = new Pettanr.Views.OriginalPicture.Show.Body(@item, {}) @history = new Pettanr.Views.OriginalPicture.Show.History(@item, {}) @listenTo(@history, 'http_get', @http_get) render: () -> this.$el.html('') this.$el.append(@header.render().el) this.$el.append(@authored_by.render().el) this.$el.append(@body.render().el) this.$el.append(@history.render().el) this http_get: (url) -> @trigger('http_get', url) is_pickable: () -> false class Pettanr.Views.OriginalPicture.Show.Body extends Pettanr.View className: 'op-body' constructor: (@item, options) -> super(options) initialize: (options) -> @img = @item.real_picture() @owner = new Pettanr.View.Show.Footer(@item, this, { actions: { select: { url: @item.license_url(), dic_name: 'original_pictures.show.select', click: () => @create_dialog() @trigger('click:license', @dialog) }, replace: { url: @item.edit_url(), dic_name: 'original_pictures.show.replace', click: () => @trigger('http_get', @item.edit_url()) }, destroy: { url: @item.destroy_url(), click: () => redirect = (url) => @trigger('http_get', url) Pettanr.Proxy.destroy(@item, {redirect: redirect}) }, }, }) @summary = @item.summary(this, {}) @listenTo(@summary, 'http_get', @http_get) render: () -> this.$el.html('') this.$el.append(@img.render().el) this.$el.append(@summary.render().el) @append_rb() this.$el.append(@owner.render().el) this create_dialog: () -> @dialog = new Editor.PicturePublisher.Dialog({ parent: this }) this.$el.append(@dialog.render().el) _this = this @dialog.$el.dialog({ autoOpen: false, width: 500, height: 500, close: (ui, event) -> _this.close_dialog() }) params = { controller: 'original_picture_license_groups', action: 'new', id: @item.get('id'), } @listenTo(@dialog, 'success', @success) @dialog.start(params, null) @dialog success: (resource_picture) -> #Pettanr.cache.fix(@item) @trigger('success', @params, @dialog) @trigger('http_get', resource_picture.show_url()) Pettanr.cache.refresh(@item) close_dialog: () -> #Pettanr.cache.release(@item) @trigger('click:close', @dialog) class Pettanr.Views.OriginalPicture.Show.History extends Pettanr.View className: 'op-history' constructor: (@item, options) -> super(options) initialize: (options) -> super(options) controller = Manifest.manifest().controllers['original_pictures'] action = controller.actions['history'] @list = action.find(id: @item.get('id')) render: () -> this.$el.html('') h = new Tag.H2({ content: I18n.t('original_pictures.show.history') }) this.$el.append(h.render().el) @list.open(this, { success: (pictures) => _.each pictures, (picture) => history = new Pettanr.Views.Picture.History(picture) @listenTo(history, 'http_get', @http_get) this.$el.append(history.render().el) }) this http_get: (url) -> @trigger('http_get', url)