class Pettanr.Views.GroundPicture.NewElementLauncher extends Editor.EditorModule.DockModule.NewElementLauncher initialize: (options) -> super(options) @links_conf = {} _.extend(@links_conf, { users: { caption: "User's", params: { controller: @model.pick_model().path_name(), action: 'index', page_size: 6, format: 'html' } } }) if Pettanr.cache.operators.artist _.extend(@links_conf, { mine: { caption: 'Mine', params: { controller: @model.pick_model().path_name(), action: 'by_artist', id: Pettanr.cache.operators.artist.get('id'), page_size: 6, format: 'html' } } }) _.extend(@links_conf, { inspire_recent: { caption: "Inspire recent item", params: { controller: @model.path_name(), action: 'index', page_size: 6, format: 'html' } } }) if Pettanr.cache.operators.author _.extend(@links_conf, { inspire_my_recent: { caption: 'Inspire my recent item', params: { controller: @model.path_name(), action: 'by_author', id: Pettanr.cache.operators.author.get('id'), page_size: 6, format: 'html' } } }) render: () -> super() @add_links() this click_users: () -> @click_default(@links_conf.users.params) click_mine: () -> @click_default(@links_conf.mine.params) click_inspire_recent: () -> @click_default(@links_conf.inspire_recent.params) click_inspire_my_recent: () -> @click_default(@links_conf.inspire_my_recent.params) class Pettanr.Views.GroundPicture.NewElement extends Pettanr.View initialize: (options) -> @parent = options.parent @target_model = options.target_model @pick_model = @target_model.pick_model() start: (@dialog, params) -> @dialog.start(@target_model, params, null) @listenTo(@dialog, 'pick', @pick) @trigger('dialog:open', @dialog) pick: (item) -> if item.item_name() == @target_model.item_name() # Inspire @listenTo(this, 'ready', @ready) new_item = new @target_model(item.attributes) new_item.unset('id', {silent: true}) new_item.set({panel_id: @editor().item.get('id')}, {silent: true}) @trigger('ready', new_item) else if @target_model.is_traceable(item.item_name()) # Trace item.trace_to(item.my_class().pick_item_name(), this, { success: (resource_picture) => @dialog.http_get(resource_picture.show_url()) }) else if item.item_name() == @target_model.pick_item_name() # Pick resource_picture to ground_picture @listenTo(this, 'ready', @ready) new_item = new @target_model() new_item.set(new_item.pick(item), {silent: true}) @trigger('ready', new_item) ready: (new_item) -> @dialog.stop() @trigger('pick', new_item) dock: () -> @parent.dock() editor: () -> @dock().editor()