class Locmare.ProfilerModule.AssociationModule.HasMany extends Pettanr.View tagName: 'div' initialize: (options) -> @association = options.association @has_many_manifest = options.has_many_manifest @filer = null controller = Manifest.manifest().controllers[@has_many_manifest.controller_name] action = controller.actions[@has_many_manifest.action_name] @list = action.find({id: @item().get('id'), page: 1, page_size: 3}) @pager = new Locmare.ListGroupModule.LibModule.PagerModule.More({ params: {controller: action.path_name(), action: action.name, id: @item().get('id')} }) clear: () -> this.$el.html('') @list.open(this, { success: (page_status) => @set_filer() @render() fail: (response, opt) => @open_error_dialog(response, opt) }) this render: () -> this.$el.html(@filer.el) this set_filer: () -> @filer = new Locmare.Filer({ item_name: @has_many_model().item_name(), items: @list.items(), pager: @pager, }) @filer.render() @listenTo(@filer, 'http_get', @http_get) @listenTo(@filer, 'pick', @pick) item: () -> @profiler().item has_many_model: () -> @has_many_manifest.model() profiler: () -> @association.profiler add_pick: (target_model) -> @list.open(this, { success: (page_status) => @set_filer() @render() @filer.add_pick(target_model) fail: (response, opt) => @open_error_dialog(response, opt) }) http_get: (url) -> @trigger('http_get', url) pick: (item) -> @trigger('pick', item)