1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/396202a06c1d/ changeset: 396202a06c1d user: jgoecks date: 2013-02-11 18:05:50 summary: More refactoring for tabular data display. affected #: 2 files diff -r 7ccddea80a25cf7cdb1e4a9df2056153a326737c -r 396202a06c1d5a195752fe8a561df8a69e8efad3 static/scripts/mvc/data.js --- a/static/scripts/mvc/data.js +++ b/static/scripts/mvc/data.js @@ -202,11 +202,40 @@ } }); +// -- Utility functions. -- + +/** + * Create a model, attach it to a view, render view, and attach it to a parent element. + */ +var createModelAndView = function(model, view, model_config, parent_elt) { + // Create model, view. + var a_view = new view({ + model: new model(model_config) + }); + + // Render view and add to parent element. + a_view.render(); + if (parent_elt) { + parent_elt.append(a_view.$el); + } + + return a_view; +}; + +/** + * Create a tabular dataset chunked view (and requisite tabular dataset model) + * and appends to parent_elt. + */ +var createTabularDatasetChunkedView = function(dataset_config, parent_elt) { + return createModelAndView(TabularDataset, TabularDatasetChunkedView, dataset_config, parent_elt); +}; + return { Dataset: Dataset, TabularDataset: TabularDataset, DatasetCollection: DatasetCollection, - TabularDatasetChunkedView: TabularDatasetChunkedView + TabularDatasetChunkedView: TabularDatasetChunkedView, + createTabularDatasetChunkedView: createTabularDatasetChunkedView }; }); diff -r 7ccddea80a25cf7cdb1e4a9df2056153a326737c -r 396202a06c1d5a195752fe8a561df8a69e8efad3 templates/webapps/galaxy/dataset/tabular_chunked.mako --- a/templates/webapps/galaxy/dataset/tabular_chunked.mako +++ b/templates/webapps/galaxy/dataset/tabular_chunked.mako @@ -16,22 +16,18 @@ }); require(['mvc/data'], function(data) { - - // Set up dataset. - var dataset = new data.TabularDataset( _.extend( ${h.to_json_string( dataset.get_api_value() )}, - { - chunk_url: "${h.url_for( controller='/dataset', action='display', + data.createTabularDatasetChunkedView( + // Dataset config. TODO: encode id. + _.extend( ${h.to_json_string( dataset.get_api_value() )}, + { + chunk_url: "${h.url_for( controller='/dataset', action='display', dataset_id=trans.security.encode_id( dataset.id ))}", - first_data_chunk: ${chunk} - } - ) ); - - // Set up, render, and add view. - var dataset_view = new data.TabularDatasetChunkedView({ - model: dataset - }); - dataset_view.render(); - $('body').append(dataset_view.$el); + first_data_chunk: ${chunk} + } + ), + // Append view to body. + $('body') + ); }); </script></%def> Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.