Fix to 83aaac5: copy changes into client/

This commit is contained in:
Carl Eberhard
2014-09-24 13:54:04 -04:00
parent 8ba9d93b45
commit 5bcbbdc40b
3 changed files with 59 additions and 20 deletions
+52 -1
View File
@@ -73,8 +73,59 @@ var GalaxyFrame = Backbone.View.extend(
});
this._refresh();
},
/**
* Add a dataset to the frames.
*/
add_dataset: function(dataset_id) {
var self = this;
require(['mvc/data'], function(DATA) {
var dataset = new DATA.Dataset({ id: dataset_id });
$.when( dataset.fetch() ).then( function() {
// Construct frame config based on dataset's type.
var frame_config = {
title: dataset.get('name')
},
// HACK: For now, assume 'tabular' and 'interval' are the only
// modules that contain tabular files. This needs to be replaced
// will a is_datatype() function.
is_tabular = _.find(['tabular', 'interval'], function(data_type) {
return dataset.get('data_type').indexOf(data_type) !== -1;
});
// Use tabular chunked display if dataset is tabular; otherwise load via URL.
if (is_tabular) {
var tabular_dataset = new DATA.TabularDataset(dataset.toJSON());
_.extend(frame_config, {
type: 'other',
content: function( parent_elt ) {
DATA.createTabularDatasetChunkedView({
model: tabular_dataset,
parent_elt: parent_elt,
embedded: true,
height: '100%'
});
}
});
}
else {
_.extend(frame_config, {
type: 'url',
content: galaxy_config.root + 'datasets/' +
dataset.id + '/display/?preview=True'
});
}
self.add(frame_config);
});
});
},
// adds and displays a new frame/window
/**
* Add and display a new frame/window based on options.
*/
add: function(options)
{
// open new tab
+5 -1
View File
@@ -20,7 +20,11 @@ var Dataset = Backbone.Model.extend({
},
initialize: function() {
this._set_metadata();
// Metadata can be passed in as a model or a set of attributes; if it's
// already a model, there's no need to set metadata.
if (!this.get('metadata')) {
this._set_metadata();
}
// Update metadata on change.
this.on('change', this._set_metadata, this);
@@ -161,24 +161,8 @@ var DatasetListItemView = _super.extend(
var self = this;
displayBtnData.onclick = function( ev ){
if( Galaxy.frame && Galaxy.frame.active ){
// Create frame with TabularChunkedView.
Galaxy.frame.add({
title : "Data Viewer: " + self.model.get( 'name' ),
type : "other",
content : function( parent_elt ){
require(['mvc/data'], function(DATA) {
var new_dataset = new DATA.TabularDataset({ id: self.model.get( 'id' ) });
$.when( new_dataset.fetch() ).then( function(){
DATA.createTabularDatasetChunkedView({
model: new_dataset,
parent_elt: parent_elt,
embedded: true,
height: '100%'
});
});
});
}
});
// Add dataset to frames.
Galaxy.frame.add_dataset(self.model.get('id'));
ev.preventDefault();
}
};