From a501d5fcce63acd37b01747943e3f9e43c4c21ed Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Thu, 13 Dec 2007 22:29:57 +0000 Subject: [PATCH] UI for invite revocation. --- NEWS | 2 +- static/css/note.css | 17 +++++++++++++ static/js/Editor.js | 16 +++++++++++- static/js/Wiki.js | 60 +++++++++++++++++++++++++++++++++------------ 4 files changed, 78 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index 760a38e..421b6aa 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,5 @@ 1.1.0: December ??, 2007 - * Ability to invite people to your notebook. + * Ability to invite people to view your notebook. * When the web browser is resized, all notes are automatically resized as well. * Fixed note focusing in Safari. * Fixed note state detection (bold, italic, etc.) in Safari. diff --git a/static/css/note.css b/static/css/note.css index 474ddc0..d1c0a83 100644 --- a/static/css/note.css +++ b/static/css/note.css @@ -73,6 +73,19 @@ h3 { background-color: #ffcc66; } +.revoke_button { + border-style: outset; + border-width: 0px; + background-color: #d0e0f0; + font-size: 90%; + outline: none; + cursor: pointer; +} + +.revoke_button:hover { + background-color: #ffcc66; +} + .text_field { margin-top: 0.25em; padding: 0.25em; @@ -117,6 +130,10 @@ ol li { text-decoration: none; } +.invite { + margin-left: 1em; +} + #access_table td { padding-right: 1em; } diff --git a/static/js/Editor.js b/static/js/Editor.js index 3aaa8f6..4e0e522 100644 --- a/static/js/Editor.js +++ b/static/js/Editor.js @@ -210,8 +210,22 @@ Editor.prototype.finish_init = function () { signal( self, "submit_form", "/users/send_invites", invite_form, function ( result ) { if ( !result.invites ) return; signal( self, "invites_updated", result.invites ); - } ); event.stop(); + } ); + event.stop(); } ); + + var revoke_buttons = getElementsByTagAndClassName( "input", "revoke_button" ); + for ( var i in revoke_buttons ) { + var revoke_button = revoke_buttons[ i ]; + var invite_id = revoke_button.id.split( "_" ).pop(); + connect( revoke_button, "onclick", function ( event ) { + signal( self, "revoke_invite", invite_id, function ( result ) { + if ( !result.invites ) return; + signal( self, "invites_updated", result.invites ); + } ); + event.stop(); + } ); + } } } ); diff --git a/static/js/Wiki.js b/static/js/Wiki.js index 104a579..7d5f7b9 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -644,6 +644,12 @@ Wiki.prototype.create_editor = function ( id, note_text, deleted_from_id, revisi connect( editor, "submit_form", function ( url, form, callback ) { self.invoker.invoke( url, "POST", null, callback, form ); } ); + connect( editor, "revoke_invite", function ( invite_id, callback ) { + self.invoker.invoke( "/users/revoke_invite", "POST", { + "notebook_id": self.notebook_id, + "invite_id": invite_id + }, callback ); + } ); this.clear_messages(); this.clear_pulldowns(); @@ -1297,7 +1303,7 @@ Wiki.prototype.share_notebook = function () { } var invite_area = createDOM( "p", { "id": "invite_area" } ); - this.update_invites( invite_area ); + this.display_invites( invite_area ); var div = createDOM( "div", {}, createDOM( "form", { "id": "invite_form" }, @@ -1323,39 +1329,63 @@ Wiki.prototype.share_notebook = function () { this.create_editor( "share_notebook", "

share this notebook

" + div.innerHTML, undefined, undefined, undefined, false, true, true, getElement( "notes_top" ) ); } -Wiki.prototype.update_invites = function ( invite_area ) { +Wiki.prototype.display_invites = function ( invite_area ) { if ( !this.invites || this.invites.length == 0 ) return; - var collaborators = createDOM( "ul", { "id": "collaborators" } ); - var viewers = createDOM( "ul", { "id": "viewers" } ); - var owners = createDOM( "ul", { "id": "owners" } ); + var collaborators = createDOM( "div", { "id": "collaborators" } ); + var viewers = createDOM( "div", { "id": "viewers" } ); + var owners = createDOM( "div", { "id": "owners" } ); + var self = this; for ( var i in this.invites ) { var invite = this.invites[ i ]; + var revoke_button = createDOM( "input", { + "type": "button", + "id": "revoke_" + invite.object_id, + "class": "revoke_button", + "value": " x ", + "title": "revoke this person's notebook access" + } ); + if ( invite.owner ) { - appendChildNodes( owners, createDOM( "li", {}, invite.email_address ) ); + appendChildNodes( + owners, createDOM( "div", { "class": "invite" }, + invite.email_address, " ", revoke_button ) + ); } else { if ( invite.read_write ) - appendChildNodes( collaborators, createDOM( "li", {}, invite.email_address ) ); + appendChildNodes( + collaborators, createDOM( "div", { "class": "invite" }, + invite.email_address, " ", revoke_button ) + ); else - appendChildNodes( viewers, createDOM( "li", {}, invite.email_address ) ); + appendChildNodes( + viewers, createDOM( "div", { "class": "invite" }, + invite.email_address, " ", revoke_button ) + ); } } var div = createDOM( "div" ); if ( collaborators.childNodes.length > 0 ) { - appendChildNodes( div, createDOM( "h3", {}, "collaborators" ) ); - appendChildNodes( div, collaborators ); + var p = createDOM( "p" ); + appendChildNodes( p, createDOM( "b", {}, "collaborators" ) ); + appendChildNodes( p, collaborators ); + appendChildNodes( div, p ); } if ( viewers.childNodes.length > 0 ) { - appendChildNodes( div, createDOM( "h3", {}, "viewers" ) ); - appendChildNodes( div, viewers ); + var p = createDOM( "p" ); + appendChildNodes( p, createDOM( "b", {}, "viewers" ) ); + appendChildNodes( p, viewers ); + appendChildNodes( div, p ); } if ( owners.childNodes.length > 0 ) { - appendChildNodes( div, createDOM( "h3", {}, "owners" ) ); - appendChildNodes( div, owners ); + var p = createDOM( "p" ); + appendChildNodes( p, createDOM( "b", {}, "owners" ) ); + appendChildNodes( p, owners ); + appendChildNodes( div, p ); } replaceChildNodes( invite_area, div ); @@ -1369,7 +1399,7 @@ Wiki.prototype.display_message = function ( text, nodes, position_after ) { for ( var i in nodes ) appendChildNodes( inner_div, nodes[ i ] ); - ok_button = createDOM( "input", { + var ok_button = createDOM( "input", { "type": "button", "class": "message_button", "value": "ok",