[#43,backend][s]: GDocs backend working (and has improved docs).
This commit is contained in:
@@ -272,15 +272,27 @@ this.recline.Model = this.recline.Model || {};
|
|||||||
|
|
||||||
// ## Google spreadsheet backend
|
// ## Google spreadsheet backend
|
||||||
//
|
//
|
||||||
// Connect to Google Docs spreadsheet. For write operations
|
// Connect to Google Docs spreadsheet.
|
||||||
|
//
|
||||||
|
// Dataset must have a url attribute pointing to the Gdocs
|
||||||
|
// spreadsheet's JSON feed e.g.
|
||||||
|
//
|
||||||
|
// <pre>
|
||||||
|
// var dataset = new recline.Model.Dataset({
|
||||||
|
// url: 'https://spreadsheets.google.com/feeds/list/0Aon3JiuouxLUdDQwZE1JdV94cUd6NWtuZ0IyWTBjLWc/od6/public/values?alt=json'
|
||||||
|
// },
|
||||||
|
// 'gdocs'
|
||||||
|
// );
|
||||||
|
// </pre>
|
||||||
my.BackendGDoc = Backbone.Model.extend({
|
my.BackendGDoc = Backbone.Model.extend({
|
||||||
sync: function(method, model, options) {
|
sync: function(method, model, options) {
|
||||||
|
var self = this;
|
||||||
if (method === "read") {
|
if (method === "read") {
|
||||||
var dfd = $.Deferred();
|
var dfd = $.Deferred();
|
||||||
var dataset = model;
|
var dataset = model;
|
||||||
|
|
||||||
$.getJSON(model.backendConfig.url, function(d) {
|
$.getJSON(model.get('url'), function(d) {
|
||||||
result = my.backends['gdocs'].gdocsToJavascript(d);
|
result = self.gdocsToJavascript(d);
|
||||||
model.set({'headers': result.header});
|
model.set({'headers': result.header});
|
||||||
// cache data onto dataset (we have loaded whole gdoc it seems!)
|
// cache data onto dataset (we have loaded whole gdoc it seems!)
|
||||||
model._dataCache = result.data;
|
model._dataCache = result.data;
|
||||||
|
|||||||
@@ -452,13 +452,11 @@ var sample_gdocs_spreadsheet_data = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("GDoc Backend", function() {
|
test("GDoc Backend", function() {
|
||||||
var dataset = new recline.Model.Dataset();
|
var dataset = new recline.Model.Dataset({
|
||||||
dataset.backendConfig = {
|
url: 'https://spreadsheets.google.com/feeds/list/0Aon3JiuouxLUdDQwZE1JdV94cUd6NWtuZ0IyWTBjLWc/od6/public/values?alt=json'
|
||||||
type: 'gdocs',
|
},
|
||||||
url: 'https://spreadsheets.google.com/feeds/list/0Aon3JiuouxLUdDQwZE1JdV94cUd6NWtuZ0IyWTBjLWc/od6/public/values?alt=json'
|
'gdocs'
|
||||||
};
|
);
|
||||||
|
|
||||||
console.log('got gdoc dataset', dataset);
|
|
||||||
|
|
||||||
var stub = sinon.stub($, 'getJSON', function(options, cb) {
|
var stub = sinon.stub($, 'getJSON', function(options, cb) {
|
||||||
console.log('options are', options, cb);
|
console.log('options are', options, cb);
|
||||||
|
|||||||
Reference in New Issue
Block a user