implement json copypaste bulk uploader

This commit is contained in:
Max Ogden
2011-07-24 13:44:28 -07:00
parent a6093b1018
commit ce26ed6afb
3 changed files with 36 additions and 1 deletions

View File

@@ -40,6 +40,8 @@ var recline = function() {
function renderRows(response) {
var rows = response.rows;
if (rows.length < 1) return;
var tableRows = [];
rows.map(function(row) {

View File

@@ -185,6 +185,33 @@ app.after = {
}
);
})
},
pasteImport: function() {
$('.dialog-content .okButton').click(function(e) {
util.notify("Uploading documents...", {persist: true, loader: true});
try {
var docs = JSON.parse($('.data-table-cell-copypaste-editor').val());
} catch(e) {
util.notify("JSON parse error: " + e);
}
if (docs) {
if(_.isArray(docs)) {
costco.uploadDocs(docs).then(
function(docs) {
util.notify("Data uploaded successfully!");
recline.fetchRows(false, app.offset);
util.hide('dialog');
},
function (err) {
util.hide('dialog');
util.notify("Error uploading: " + err.responseText);
}
);
} else {
util.notify("Error: JSON must be an array of objects");
}
}
})
}
}