diff --git a/src/model.js b/src/model.js index 85a93294..311b5707 100644 --- a/src/model.js +++ b/src/model.js @@ -2,26 +2,27 @@ this.recline = this.recline || {}; // A Dataset model. recline.Dataset = Backbone.Model.extend({ - initialize: function(data, rawTabularData) { - this.tabularData = new recline.TabularData(rawTabularData); + initialize: function(data, rawDocumentSet) { + this.documentSet = new recline.DocumentSet(rawDocumentSet); } - // get TabularData object associated with this Dataset - // - // async (as may involve getting data from the server) implementing standard promise API - , getTabularData: function() { - var dfd = $.Deferred(); - dfd.resolve(this.tabularData); - return dfd.promise(); - } }); -// TabularData model -recline.TabularData = Backbone.Model.extend({ +recline.Document = Backbone.Model.extend({}); + +recline.DocumentList = Backbone.Collection.extend({ + // webStore: new WebStore(this.url), + model: recline.Document +}) + +recline.DocumentSet = Backbone.Model.extend({ + fetch: function(options) { + options.success(this); + }, getLength: function() { return this.get('rows').length; - } - , getRows: function(numRows, start) { + }, + getRows: function(numRows, start) { if (start === undefined) { start = 0; } @@ -33,4 +34,5 @@ recline.TabularData = Backbone.Model.extend({ dfd.resolve(results); return dfd.promise(); } -}); + +}); \ No newline at end of file diff --git a/test/model.test.js b/test/model.test.js index c8a33426..41141ae6 100644 --- a/test/model.test.js +++ b/test/model.test.js @@ -23,16 +23,18 @@ test('new Dataset', function () { equal(dataset.get('name'), metadata.name); expect(6); setTimeout(2); - dataset.getTabularData().then(function(tabularData) { - equal(tabularData.get('headers'), indata.headers); - equal(tabularData.getLength(), 6); - tabularData.getRows(4, 2).then(function(rows) { - equal(rows[0], indata.rows[2]); - }); - tabularData.getRows().then(function(rows) { - equal(rows.length, Math.min(10, indata.rows.length)); - equal(rows[0], indata.rows[0]); - }); + dataset.documentSet.fetch({ + success: function(documentSet) { + equal(documentSet.get('headers'), indata.headers); + equal(documentSet.getLength(), 6); + documentSet.getRows(4, 2).then(function(rows) { + equal(rows[0], indata.rows[2]); + }); + documentSet.getRows().then(function(rows) { + equal(rows.length, Math.min(10, indata.rows.length)); + equal(rows[0], indata.rows[0]); + }); + } }); });