[refactor][s]: rename rowCount to docCount and remove getLength method as can just use dataset.docCount.
This commit is contained in:
parent
e23354eb4e
commit
250f931c36
14
src/model.js
14
src/model.js
@ -6,14 +6,16 @@ recline.Model = function($) {
|
||||
var my = {};
|
||||
|
||||
// A Dataset model.
|
||||
//
|
||||
// Other than standard list of Backbone attributes it has two important attributes:
|
||||
//
|
||||
// * currentDocuments: a DocumentList containing the Documents we have currently loaded for viewing (you update currentDocuments by calling getRows)
|
||||
// * docCount: total number of documents in this dataset (obtained on a fetch for this Dataset)
|
||||
my.Dataset = Backbone.Model.extend({
|
||||
__type__: 'Dataset',
|
||||
initialize: function() {
|
||||
this.currentDocuments = new my.DocumentList();
|
||||
},
|
||||
|
||||
getLength: function() {
|
||||
return this.rowCount;
|
||||
this.docCount = null;
|
||||
},
|
||||
|
||||
// Get rows (documents) from the backend returning a recline.DocumentList
|
||||
@ -103,7 +105,7 @@ my.BackendMemory = Backbone.Model.extend({
|
||||
dataset.set({
|
||||
headers: rawDataset.data.headers
|
||||
});
|
||||
dataset.rowCount = rawDataset.data.rows.length;
|
||||
dataset.docCount = rawDataset.data.rows.length;
|
||||
dfd.resolve(dataset);
|
||||
}
|
||||
return dfd.promise();
|
||||
@ -184,7 +186,7 @@ my.BackendWebstore = Backbone.Model.extend({
|
||||
dataset.set({
|
||||
headers: headers
|
||||
});
|
||||
dataset.rowCount = schema.count;
|
||||
dataset.docCount = schema.count;
|
||||
dfd.resolve(dataset, jqxhr);
|
||||
});
|
||||
return dfd.promise();
|
||||
|
||||
@ -31,7 +31,7 @@ test('new Dataset', function () {
|
||||
dataset.fetch().then(function(dataset) {
|
||||
equal(dataset.get('name'), metadata.name);
|
||||
deepEqual(dataset.get('headers'), indata.headers);
|
||||
equal(dataset.getLength(), 6);
|
||||
equal(dataset.docCount, 6);
|
||||
dataset.getRows(4, 2).then(function(documentList) {
|
||||
deepEqual(indata.rows[2], documentList.models[0].toJSON());
|
||||
});
|
||||
@ -158,7 +158,7 @@ test('Webstore Backend', function() {
|
||||
|
||||
dataset.fetch().then(function(dataset) {
|
||||
deepEqual(['__id__', 'date', 'geometry', 'amount'], dataset.get('headers'));
|
||||
equal(3, dataset.rowCount)
|
||||
equal(3, dataset.docCount)
|
||||
dataset.getRows().then(function(docList) {
|
||||
equal(3, docList.length)
|
||||
equal("2009-01-01", docList.models[0].get('date'));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user