Skip to content

Commit

Permalink
Merge pull request #114 from tablekat/FixInconsistentCallbacks
Browse files Browse the repository at this point in the history
Made cell.save consistent with row.save in terms of requiring a callback (#105)
  • Loading branch information
theoephraim authored May 27, 2017
2 parents 0b241d6 + d1a2dc5 commit 1da46ed
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ var SpreadsheetWorksheet = function( spreadsheet, data ){
spreadsheet.addRow(self.id, data, cb);
}
this.bulkUpdateCells = function(cells, cb) {
if ( !cb ) cb = function(){};

var entries = cells.map(function (cell, i) {
cell._needsSave = false;
return "<entry>\n <batch:id>" + cell.batchId + "</batch:id>\n <batch:operation type=\"update\"/>\n <id>" + self['_links']['cells']+'/'+cell.batchId + "</id>\n <link rel=\"edit\" type=\"application/atom+xml\"\n href=\"" + cell._links.edit + "\"/>\n <gs:cell row=\"" + cell.row + "\" col=\"" + cell.col + "\" inputValue=\"" + cell.valueForSave + "\"/>\n </entry>";
Expand All @@ -440,6 +442,7 @@ var SpreadsheetWorksheet = function( spreadsheet, data ){
}

this.setHeaderRow = function(values, cb) {
if ( !cb ) cb = function(){};
if (!values) return cb();
if (values.length > self.colCount){
return cb(new Error('Sheet is not large enough to fit '+values.length+' columns. Resize the sheet first.'));
Expand Down Expand Up @@ -620,6 +623,7 @@ var SpreadsheetCell = function( spreadsheet, worksheet_id, data ){
});

self.save = function(cb) {
if ( !cb ) cb = function(){};
self._needsSave = false;

var edit_id = 'https://spreadsheets.google.com/feeds/cells/key/worksheetId/private/full/R'+self.row+'C'+self.col;
Expand Down

0 comments on commit 1da46ed

Please sign in to comment.