X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Flocmare%2Fprofiler%2Fassociation%2Fhas_one.js.coffee;h=6b6995634d4a1b91517047e4b4ec574aac6a3866;hb=011acbc4bee1e83e966014a008f8226c4917e1d3;hp=8ddd7fb3be1e3506411353db2fbb2dbc835ec42f;hpb=c45c5a09d02072bf526c03a3fec185a1963118aa;p=pettanr%2Fpettanr.git diff --git a/app/assets/javascripts/locmare/profiler/association/has_one.js.coffee b/app/assets/javascripts/locmare/profiler/association/has_one.js.coffee index 8ddd7fb3..6b699563 100644 --- a/app/assets/javascripts/locmare/profiler/association/has_one.js.coffee +++ b/app/assets/javascripts/locmare/profiler/association/has_one.js.coffee @@ -5,27 +5,38 @@ class Locmare.ProfilerModule.AssociationModule.HasOne extends Backbone.View @association = options.association @has_one_manifest = options.has_one_manifest @filer = null - controller = Manifest.manifest().controllers[@has_one_manifest.table_name] - action = controller.actions[@has_one_manifest.list_name] - @list = Locmare.ListGroup.list(@has_one_manifest.item_name, @has_one_manifest.list_name) - params = {id: @item().get('id')} - _this = this - @list.open(@profiler().operators, params, action, {}, (page_status) -> - _this.filer = new Locmare.Filer({ - item_name: _this.has_one_model().item_name(), - items: _this.list.models, - pager: _this.pager, - operators: _this.profiler().operators - }) - _this.render() + controller = Manifest.manifest().controllers[@has_one_manifest.controller_name] + action = controller.actions[@has_one_manifest.action_name] + @list = Locmare.ListGroup.list( + action.path_name(), action.name, + @profiler().operators, + {id: @item().get('id')} ) + clear: () -> + this.$el.html('') + @list.open((page_status) => + @set_filer() + @render() + ) + this + render: () -> this.$el.html('') - if @filer - this.$el.html(@filer.render().el) + this.$el.html(@filer.el) this + set_filer: () -> + @filer = new Locmare.Filer({ + item_name: @has_one_model().item_name(), + items: @list.items(), + pager: @pager, + operators: @profiler().operators + }) + @filer.render() + @listenTo(@filer, 'http_get', @http_get) + @listenTo(@filer, 'pick', @pick) + item: () -> @profiler().item @@ -35,3 +46,16 @@ class Locmare.ProfilerModule.AssociationModule.HasOne extends Backbone.View profiler: () -> @association.profiler + add_pick: (target_model) -> + @list.open((page_status) => + @set_filer() + @render() + @filer.add_pick(target_model) + ) + + http_get: (url) -> + @trigger('http_get', url) + + pick: (item) -> + @trigger('pick', item) +