From 7cbf23088ce67c5ee56d779ff4ab308b2da5876e Mon Sep 17 00:00:00 2001 From: Max Ogden Date: Wed, 3 Aug 2011 19:33:12 -0400 Subject: [PATCH] add row controls and delete row button --- attachments/pages/index.html | 6 ++++++ attachments/script/recline.js | 11 +++++++++++ attachments/script/site.js | 11 ++++++++--- attachments/style/data-table.css | 15 +++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/attachments/pages/index.html b/attachments/pages/index.html index 56f06951..4bbc470b 100755 --- a/attachments/pages/index.html +++ b/attachments/pages/index.html @@ -85,6 +85,10 @@
  • Delete this column
  • + + @@ -135,6 +139,7 @@ + {{#headers}} {{#rows}} + {{#cells}}
    @@ -147,6 +152,7 @@
    diff --git a/attachments/script/recline.js b/attachments/script/recline.js index 4a798958..4edfc676 100755 --- a/attachments/script/recline.js +++ b/attachments/script/recline.js @@ -27,6 +27,17 @@ var recline = function() { deleteColumn: function() { var msg = "Are you sure? This will delete '" + app.currentColumn + "' from all documents."; if (confirm(msg)) costco.deleteColumn(app.currentColumn); + }, + deleteRow: function() { + var doc = _.find(app.cache, function(doc) { return doc._id === app.currentRow }); + doc._deleted = true; + costco.uploadDocs([doc]).then( + function(updatedDocs) { + util.notify("Row deleted successfully"); + recline.initializeTable(app.offset); + }, + function(err) { util.notify("Errorz! " + err) } + ) } } diff --git a/attachments/script/site.js b/attachments/script/site.js index 6f982591..18bb85c6 100755 --- a/attachments/script/site.js +++ b/attachments/script/site.js @@ -29,6 +29,12 @@ app.after = { util.render('columnActions', 'menu'); }); + $('.row-header-menu').click(function(e) { + app.currentRow = $(e.target).parents('tr:first').attr('data-id'); + util.position('menu', e); + util.render('rowActions', 'menu'); + }); + $('.data-table-cell-edit').click(function(e) { var editing = $('.data-table-cell-editor-editor'); if (editing.length > 0) { @@ -40,9 +46,8 @@ app.after = { util.render('cellEditor', cell, {value: cell.text()}); }) }, - columnActions: function() { - recline.handleMenuClick(); - }, + columnActions: function() { recline.handleMenuClick() }, + rowActions: function() { recline.handleMenuClick() }, cellEditor: function() { $('.data-table-cell-editor .okButton').click(function(e) { var cell = $(e.target); diff --git a/attachments/style/data-table.css b/attachments/style/data-table.css index ef610bc2..e64a1a5f 100755 --- a/attachments/style/data-table.css +++ b/attachments/style/data-table.css @@ -637,6 +637,21 @@ a.column-header-menu { background-repeat: no-repeat; } +a.row-header-menu:hover { + background-position: -17px 0px; + text-decoration: none; +} + +a.row-header-menu { + float: left; + display: block; + margin: 0 0 -2px 0; + width: 17px; + height: 19px; + background-image: url(images/menu-dropdown.png); + background-repeat: no-repeat; +} + a.column-header-menu:hover { background-position: -17px 0px; text-decoration: none;