mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Charts: Add configuration model, link all view functions to model events
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
// dependencies
|
||||
define(['library/portlet', 'library/ui', 'library/utils',
|
||||
'views/charts', 'views/viewport', 'views/chart', 'views/group',
|
||||
'models/datasets', 'models/chart', 'models/charts', 'models/types'],
|
||||
'models/config', 'models/datasets', 'models/chart', 'models/charts', 'models/group', 'models/types'],
|
||||
function( Portlet, Ui, Utils,
|
||||
ChartsView, ViewportView, ChartView, GroupView,
|
||||
Datasets, Chart, Charts, Types
|
||||
Config, Datasets, Chart, Charts, Group, Types
|
||||
) {
|
||||
|
||||
// widget
|
||||
@@ -19,10 +19,14 @@ return Backbone.View.extend(
|
||||
// link galaxy
|
||||
this.modal = parent.Galaxy.modal;
|
||||
|
||||
// create configuration model
|
||||
this.config = new Config();
|
||||
|
||||
// create chart models
|
||||
this.types = new Types();
|
||||
this.chart = new Chart();
|
||||
this.charts = new Charts();
|
||||
this.group = new Group();
|
||||
|
||||
// create dataset handler
|
||||
this.datasets = new Datasets(this);
|
||||
|
||||
@@ -22,8 +22,9 @@ return Backbone.Model.extend(
|
||||
// reset
|
||||
reset: function()
|
||||
{
|
||||
this.clear().set(this.defaults);
|
||||
this.clear({silent: true}).set(this.defaults);
|
||||
this.groups.reset();
|
||||
this.trigger('reset', this);
|
||||
},
|
||||
|
||||
// copy
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// dependencies
|
||||
define([], function() {
|
||||
|
||||
|
||||
// model
|
||||
return Backbone.Model.extend(
|
||||
{
|
||||
// options
|
||||
defaults : {
|
||||
query_limit : 20,
|
||||
query_pace : 1000,
|
||||
query_max : 5
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,23 +1,14 @@
|
||||
// dependencies
|
||||
define(['library/utils'], function(Utils) {
|
||||
|
||||
define([], function() {
|
||||
|
||||
// model
|
||||
return Backbone.Model.extend(
|
||||
{
|
||||
// defaults
|
||||
defaults : {
|
||||
},
|
||||
|
||||
// initialize
|
||||
initialize: function(options)
|
||||
{
|
||||
},
|
||||
|
||||
// reset
|
||||
reset: function()
|
||||
{
|
||||
this.clear().set(this.defaults);
|
||||
this.clear({silent: true}).set(this.defaults);
|
||||
this.trigger('reset', this);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -125,6 +125,9 @@ return Backbone.View.extend(
|
||||
this.chart.on('change:type', function(chart) {
|
||||
self.table.value(chart.get('type'));
|
||||
});
|
||||
this.chart.on('reset', function(chart) {
|
||||
self._resetChart();
|
||||
});
|
||||
|
||||
// collection events
|
||||
this.app.charts.on('add', function(chart) {
|
||||
@@ -140,23 +143,17 @@ return Backbone.View.extend(
|
||||
});
|
||||
|
||||
// reset
|
||||
this.reset();
|
||||
this._resetChart();
|
||||
},
|
||||
|
||||
// reset
|
||||
reset: function() {
|
||||
this.chart.reset();
|
||||
_resetChart: function() {
|
||||
this.chart.set('id', Utils.uuid());
|
||||
this.chart.set('dataset_id', this.app.options.dataset.id);
|
||||
this.chart.set('type', 'bardiagram');
|
||||
this.chart.set('title', 'Chart title');
|
||||
},
|
||||
|
||||
// set chart
|
||||
setChart: function(new_chart) {
|
||||
this.chart.copy(new_chart);
|
||||
},
|
||||
|
||||
// create chart
|
||||
_saveChart: function() {
|
||||
// update chart data
|
||||
|
||||
@@ -16,12 +16,12 @@ return Backbone.View.extend(
|
||||
ondblclick : function(chart_id) {
|
||||
// get chart
|
||||
var chart = self.app.charts.get(chart_id);
|
||||
|
||||
self.app.chart.copy(chart);
|
||||
|
||||
// show edit
|
||||
self.$el.hide();
|
||||
|
||||
// update model and show create
|
||||
self.app.chart_view.setChart(chart);
|
||||
self.app.chart_view.$el.show();
|
||||
},
|
||||
onchange : function(chart_id) {
|
||||
@@ -41,7 +41,7 @@ return Backbone.View.extend(
|
||||
tooltip: 'Create',
|
||||
onclick: function() {
|
||||
self.$el.hide();
|
||||
self.app.chart_view.reset();
|
||||
self.app.chart.reset();
|
||||
self.app.chart_view.$el.show();
|
||||
}
|
||||
}),
|
||||
@@ -57,11 +57,11 @@ return Backbone.View.extend(
|
||||
|
||||
// get chart
|
||||
var chart = self.app.charts.get(chart_id);
|
||||
self.app.chart.copy(chart);
|
||||
|
||||
// show edit
|
||||
self.$el.hide();
|
||||
self.app.chart_view.$el.show();
|
||||
self.app.chart_view.setChart(chart);
|
||||
}
|
||||
}),
|
||||
'delete' : new Ui.ButtonIcon({
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
// dependencies
|
||||
define(['library/portlet', 'library/table', 'library/ui', 'library/utils', 'models/group'],
|
||||
function(Portlet, Table, Ui, Utils, Group) {
|
||||
define(['library/portlet', 'library/table', 'library/ui', 'library/utils'],
|
||||
function(Portlet, Table, Ui, Utils) {
|
||||
|
||||
// chart config
|
||||
return Backbone.View.extend(
|
||||
{
|
||||
// model
|
||||
group: new Group(),
|
||||
|
||||
// columns
|
||||
columns: [],
|
||||
|
||||
@@ -18,6 +15,7 @@ return Backbone.View.extend(
|
||||
|
||||
// get current chart object
|
||||
this.chart = this.app.chart;
|
||||
this.group = this.app.group;
|
||||
|
||||
// ui elements
|
||||
this.message = new Ui.Message();
|
||||
@@ -69,6 +67,9 @@ return Backbone.View.extend(
|
||||
this.group.on('change', function() {
|
||||
self._refreshGroup();
|
||||
});
|
||||
this.group.on('reset', function() {
|
||||
self._resetGroup();
|
||||
});
|
||||
},
|
||||
|
||||
// show
|
||||
@@ -77,8 +78,7 @@ return Backbone.View.extend(
|
||||
},
|
||||
|
||||
// reset
|
||||
reset: function() {
|
||||
this.group.reset();
|
||||
_resetGroup: function() {
|
||||
this.group.set('id', Utils.uuid());
|
||||
this.group.set('label', 'Group label');
|
||||
},
|
||||
|
||||
@@ -37,9 +37,9 @@ return Backbone.View.extend(
|
||||
icon : 'fa-plus',
|
||||
tooltip: 'Create',
|
||||
onclick: function() {
|
||||
self.app.group.reset();
|
||||
self.app.chart_view.$el.hide();
|
||||
self.app.group_view.show();
|
||||
self.app.group_view.reset();
|
||||
}
|
||||
}),
|
||||
'edit' : new Ui.ButtonIcon({
|
||||
|
||||
Reference in New Issue
Block a user