[#174,refactor][s]: rename currentRecords to records on Dataset.
This commit is contained in:
@@ -22,7 +22,7 @@ my.Dataset = Backbone.Model.extend({
|
||||
}
|
||||
}
|
||||
this.fields = new my.FieldList();
|
||||
this.currentRecords = new my.RecordList();
|
||||
this.records = new my.RecordList();
|
||||
this._changes = {
|
||||
deletes: [],
|
||||
updates: [],
|
||||
@@ -172,7 +172,7 @@ my.Dataset = Backbone.Model.extend({
|
||||
// It will query based on current query state (given by this.queryState)
|
||||
// updated by queryObj (if provided).
|
||||
//
|
||||
// Resulting RecordList are used to reset this.currentRecords and are
|
||||
// Resulting RecordList are used to reset this.records and are
|
||||
// also returned.
|
||||
query: function(queryObj) {
|
||||
var self = this;
|
||||
@@ -188,7 +188,7 @@ my.Dataset = Backbone.Model.extend({
|
||||
.done(function(queryResult) {
|
||||
self._handleQueryResult(queryResult);
|
||||
self.trigger('query:done');
|
||||
dfd.resolve(self.currentRecords);
|
||||
dfd.resolve(self.records);
|
||||
})
|
||||
.fail(function(arguments) {
|
||||
self.trigger('query:fail', arguments);
|
||||
@@ -210,7 +210,7 @@ my.Dataset = Backbone.Model.extend({
|
||||
});
|
||||
return _doc;
|
||||
});
|
||||
self.currentRecords.reset(docs);
|
||||
self.records.reset(docs);
|
||||
if (queryResult.facets) {
|
||||
var facets = _.map(queryResult.facets, function(facetResult, facetId) {
|
||||
facetResult.id = facetId;
|
||||
|
||||
@@ -43,8 +43,8 @@ my.Graph = Backbone.View.extend({
|
||||
this.model.bind('change', this.render);
|
||||
this.model.fields.bind('reset', this.render);
|
||||
this.model.fields.bind('add', this.render);
|
||||
this.model.currentRecords.bind('add', this.redraw);
|
||||
this.model.currentRecords.bind('reset', this.redraw);
|
||||
this.model.records.bind('add', this.redraw);
|
||||
this.model.records.bind('reset', this.redraw);
|
||||
// because we cannot redraw when hidden we may need when becoming visible
|
||||
this.bind('view:show', function() {
|
||||
if (this.needToRedraw) {
|
||||
@@ -89,7 +89,7 @@ my.Graph = Backbone.View.extend({
|
||||
// Uncaught Invalid dimensions for plot, width = 0, height = 0
|
||||
// * There is no data for the plot -- either same error or may have issues later with errors like 'non-existent node-value'
|
||||
var areWeVisible = !jQuery.expr.filters.hidden(this.el[0]);
|
||||
if ((!areWeVisible || this.model.currentRecords.length === 0)) {
|
||||
if ((!areWeVisible || this.model.records.length === 0)) {
|
||||
this.needToRedraw = true;
|
||||
return;
|
||||
}
|
||||
@@ -119,8 +119,8 @@ my.Graph = Backbone.View.extend({
|
||||
// However, that is non-trivial to work out from a dataset (datasets may
|
||||
// have no field type info). Thus at present we only do this for bars.
|
||||
var tickFormatter = function (val) {
|
||||
if (self.model.currentRecords.models[val]) {
|
||||
var out = self.model.currentRecords.models[val].get(self.state.attributes.group);
|
||||
if (self.model.records.models[val]) {
|
||||
var out = self.model.records.models[val].get(self.state.attributes.group);
|
||||
// if the value was in fact a number we want that not the
|
||||
if (typeof(out) == 'number') {
|
||||
return val;
|
||||
@@ -176,7 +176,7 @@ my.Graph = Backbone.View.extend({
|
||||
tickLength: 1,
|
||||
tickFormatter: tickFormatter,
|
||||
min: -0.5,
|
||||
max: self.model.currentRecords.length - 0.5
|
||||
max: self.model.records.length - 0.5
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -214,8 +214,8 @@ my.Graph = Backbone.View.extend({
|
||||
y = _tmp;
|
||||
}
|
||||
// convert back from 'index' value on x-axis (e.g. in cases where non-number values)
|
||||
if (self.model.currentRecords.models[x]) {
|
||||
x = self.model.currentRecords.models[x].get(self.state.attributes.group);
|
||||
if (self.model.records.models[x]) {
|
||||
x = self.model.records.models[x].get(self.state.attributes.group);
|
||||
} else {
|
||||
x = x.toFixed(2);
|
||||
}
|
||||
@@ -249,7 +249,7 @@ my.Graph = Backbone.View.extend({
|
||||
var series = [];
|
||||
_.each(this.state.attributes.series, function(field) {
|
||||
var points = [];
|
||||
_.each(self.model.currentRecords.models, function(doc, index) {
|
||||
_.each(self.model.records.models, function(doc, index) {
|
||||
var xfield = self.model.fields.get(self.state.attributes.group);
|
||||
var x = doc.getFieldValue(xfield);
|
||||
// time series
|
||||
|
||||
@@ -17,9 +17,9 @@ my.Grid = Backbone.View.extend({
|
||||
var self = this;
|
||||
this.el = $(this.el);
|
||||
_.bindAll(this, 'render', 'onHorizontalScroll');
|
||||
this.model.currentRecords.bind('add', this.render);
|
||||
this.model.currentRecords.bind('reset', this.render);
|
||||
this.model.currentRecords.bind('remove', this.render);
|
||||
this.model.records.bind('add', this.render);
|
||||
this.model.records.bind('reset', this.render);
|
||||
this.model.records.bind('remove', this.render);
|
||||
this.tempState = {};
|
||||
var state = _.extend({
|
||||
hiddenFields: []
|
||||
@@ -77,13 +77,13 @@ my.Grid = Backbone.View.extend({
|
||||
showColumn: function() { self.showColumn(e); },
|
||||
deleteRow: function() {
|
||||
var self = this;
|
||||
var doc = _.find(self.model.currentRecords.models, function(doc) {
|
||||
var doc = _.find(self.model.records.models, function(doc) {
|
||||
// important this is == as the currentRow will be string (as comes
|
||||
// from DOM) while id may be int
|
||||
return doc.id == self.tempState.currentRow;
|
||||
});
|
||||
doc.destroy().then(function() {
|
||||
self.model.currentRecords.remove(doc);
|
||||
self.model.records.remove(doc);
|
||||
self.trigger('recline:flash', {message: "Row deleted successfully"});
|
||||
}).fail(function(err) {
|
||||
self.trigger('recline:flash', {message: "Errorz! " + err});
|
||||
@@ -213,7 +213,7 @@ my.Grid = Backbone.View.extend({
|
||||
});
|
||||
var htmls = Mustache.render(this.template, this.toTemplateJSON());
|
||||
this.el.html(htmls);
|
||||
this.model.currentRecords.forEach(function(doc) {
|
||||
this.model.records.forEach(function(doc) {
|
||||
var tr = $('<tr />');
|
||||
self.el.find('tbody').append(tr);
|
||||
var newView = new my.GridRow({
|
||||
|
||||
@@ -48,13 +48,13 @@ my.Map = Backbone.View.extend({
|
||||
});
|
||||
|
||||
// Listen to changes in the records
|
||||
this.model.currentRecords.bind('add', function(doc){self.redraw('add',doc)});
|
||||
this.model.currentRecords.bind('change', function(doc){
|
||||
this.model.records.bind('add', function(doc){self.redraw('add',doc)});
|
||||
this.model.records.bind('change', function(doc){
|
||||
self.redraw('remove',doc);
|
||||
self.redraw('add',doc);
|
||||
});
|
||||
this.model.currentRecords.bind('remove', function(doc){self.redraw('remove',doc)});
|
||||
this.model.currentRecords.bind('reset', function(){self.redraw('reset')});
|
||||
this.model.records.bind('remove', function(doc){self.redraw('remove',doc)});
|
||||
this.model.records.bind('reset', function(){self.redraw('reset')});
|
||||
|
||||
this.bind('view:show',function(){
|
||||
// If the div was hidden, Leaflet needs to recalculate some sizes
|
||||
@@ -130,7 +130,7 @@ my.Map = Backbone.View.extend({
|
||||
if (this._geomReady() && this.mapReady){
|
||||
if (action == 'reset' || action == 'refresh'){
|
||||
this.features.clearLayers();
|
||||
this._add(this.model.currentRecords.models);
|
||||
this._add(this.model.records.models);
|
||||
} else if (action == 'add' && doc){
|
||||
this._add(doc);
|
||||
} else if (action == 'remove' && doc){
|
||||
|
||||
@@ -22,9 +22,9 @@ my.SlickGrid = Backbone.View.extend({
|
||||
this.el = $(this.el);
|
||||
this.el.addClass('recline-slickgrid');
|
||||
_.bindAll(this, 'render');
|
||||
this.model.currentRecords.bind('add', this.render);
|
||||
this.model.currentRecords.bind('reset', this.render);
|
||||
this.model.currentRecords.bind('remove', this.render);
|
||||
this.model.records.bind('add', this.render);
|
||||
this.model.records.bind('reset', this.render);
|
||||
this.model.records.bind('remove', this.render);
|
||||
|
||||
var state = _.extend({
|
||||
hiddenColumns: [],
|
||||
@@ -126,7 +126,7 @@ my.SlickGrid = Backbone.View.extend({
|
||||
|
||||
var data = [];
|
||||
|
||||
this.model.currentRecords.each(function(doc){
|
||||
this.model.records.each(function(doc){
|
||||
var row = {};
|
||||
self.model.fields.each(function(field){
|
||||
row[field.id] = doc.getFieldValueUnrendered(field);
|
||||
|
||||
@@ -41,7 +41,7 @@ my.Timeline = Backbone.View.extend({
|
||||
this.model.fields.bind('reset', function() {
|
||||
self._setupTemporalField();
|
||||
});
|
||||
this.model.currentRecords.bind('all', function() {
|
||||
this.model.records.bind('all', function() {
|
||||
self.reloadData();
|
||||
});
|
||||
var stateData = _.extend({
|
||||
@@ -120,7 +120,7 @@ my.Timeline = Backbone.View.extend({
|
||||
]
|
||||
}
|
||||
};
|
||||
this.model.currentRecords.each(function(record) {
|
||||
this.model.records.each(function(record) {
|
||||
var newEntry = self.convertRecord(record, self.fields);
|
||||
if (newEntry) {
|
||||
out.timeline.date.push(newEntry);
|
||||
|
||||
@@ -100,7 +100,7 @@ my.Transform = Backbone.View.extend({
|
||||
var editFunc = costco.evalFunction(e.target.value);
|
||||
if (!editFunc.errorMessage) {
|
||||
errors.text('No syntax error.');
|
||||
var docs = self.model.currentRecords.map(function(doc) {
|
||||
var docs = self.model.records.map(function(doc) {
|
||||
return doc.toJSON();
|
||||
});
|
||||
var previewData = costco.previewTransform(docs, editFunc);
|
||||
|
||||
Reference in New Issue
Block a user