starting to implement functional transforms

This commit is contained in:
Max Ogden 2011-07-02 18:38:42 -07:00
parent b19b5e258d
commit b1adc3f80b
4 changed files with 18 additions and 9 deletions

View File

@ -90,7 +90,7 @@
<div bind="toolPanelDiv" id="tool-panel">
<div bind="summaryBarDiv" id="summary-bar">
<span>
{{doc_count}} rows
{{doc_count}} documents
</span>
</div>
<div id="download">

View File

@ -4,8 +4,8 @@ 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,

View File

@ -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');
})

View File

@ -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 () {