From b1adc3f80b9f9f56d0a3d936118cec6249445e7b Mon Sep 17 00:00:00 2001 From: Max Ogden Date: Sat, 2 Jul 2011 18:38:42 -0700 Subject: [PATCH] starting to implement functional transforms --- attachments/pages/index.html | 2 +- attachments/script/costco.js | 11 +++++------ attachments/script/removalist.js | 2 +- attachments/script/site.js | 12 +++++++++++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/attachments/pages/index.html b/attachments/pages/index.html index 0f8b0161..59c0dae5 100644 --- a/attachments/pages/index.html +++ b/attachments/pages/index.html @@ -90,7 +90,7 @@
- {{doc_count}} rows + {{doc_count}} documents
diff --git a/attachments/script/costco.js b/attachments/script/costco.js index 2fb4737c..8370f5be 100644 --- a/attachments/script/costco.js +++ b/attachments/script/costco.js @@ -3,9 +3,9 @@ var costco = function() { var toUpdate = []; - - function getDb() { - + + function handleEditorChange(e) { + console.log(e.target.value); } function computeChanges() { @@ -25,8 +25,7 @@ var costco = function() { return mapDocs(text); } } - if(!docs.length) - docs = [docs]; + if(!docs.length) docs = [docs]; toUpdate = docs; @@ -106,7 +105,7 @@ var costco = function() { } return { - getDb: getDb, + handleEditorChange: handleEditorChange, computeChanges: computeChanges, mapDocs: mapDocs, updateDocs: updateDocs, diff --git a/attachments/script/removalist.js b/attachments/script/removalist.js index 62c3e5dd..67410c9d 100644 --- a/attachments/script/removalist.js +++ b/attachments/script/removalist.js @@ -8,7 +8,7 @@ var removalist = function() { $( '.menu li' ).click(function(e) { if ($(e.target).hasClass('transform')) { util.show('dialog'); - util.render('bulkEdit', 'dialog-content'); + util.render('bulkEdit', 'dialog-content', {name: app.currentColumn}); $('.cancelButton').click(function(e) { util.hide('dialog'); }) diff --git a/attachments/script/site.js b/attachments/script/site.js index 7847b862..e40a0337 100644 --- a/attachments/script/site.js +++ b/attachments/script/site.js @@ -27,6 +27,7 @@ app.after = { }, dataTable: function() { $('.column-header-menu').click(function(e) { + app.currentColumn = $(e.target).siblings().text(); util.position('menu', e); util.render('columnActions', 'menu'); }); @@ -38,7 +39,16 @@ app.after = { }); }, exportActions: removalist.handleMenuClick, - columnActions: removalist.handleMenuClick + columnActions: removalist.handleMenuClick, + bulkEdit: function() { + var editor = $('.expression-preview-code'); + editor.val("function(doc) {\n doc['"+ app.currentColumn+"'] = doc['"+ app.currentColumn+"'];\n return doc;\n}"); + editor.focus().get(0).setSelectionRange(18, 18); + editor.keydown(function(e) { + // if you don't setTimeout it won't grab the latest character if you call e.target.value + window.setTimeout(function(){costco.handleEditorChange(e)}, 1, true); + }); + } } app.sammy = $.sammy(function () {