diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-08-25 14:24:45 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-08-25 14:24:45 -0400 |
| commit | 124a698130f39992a1b47dcc8f32ef30c61a00eb (patch) | |
| tree | ce37d2bebb8a7975cd060a313f211f1cbe8be17e | |
| parent | 099dfd16940c62e931bf01e7f62b7a45f2b8c654 (diff) | |
stub in collaborator ui
| -rw-r--r-- | public/assets/javascripts/ui/editor/Collaborators.js | 64 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/editor/EditorView.js | 1 | ||||
| -rwxr-xr-x | public/assets/stylesheets/app.css | 6 | ||||
| -rw-r--r-- | server/index.js | 4 | ||||
| -rw-r--r-- | server/lib/api/collaborator.js | 4 | ||||
| -rw-r--r-- | server/lib/views.js | 2 | ||||
| -rw-r--r-- | views/controls/editor/collaborators.ejs | 24 | ||||
| -rw-r--r-- | views/controls/reader/about-room.ejs | 7 | ||||
| -rw-r--r-- | views/partials/scripts.ejs | 1 |
9 files changed, 99 insertions, 14 deletions
diff --git a/public/assets/javascripts/ui/editor/Collaborators.js b/public/assets/javascripts/ui/editor/Collaborators.js new file mode 100644 index 0000000..bb163f8 --- /dev/null +++ b/public/assets/javascripts/ui/editor/Collaborators.js @@ -0,0 +1,64 @@ + +var Collaborators = ModalFormView.extend({ + el: ".mediaDrawer.collaborators", + + template: $("#collaborator-template").html(), + + createAction: "/api/collaborator/:slug/create", + destroyAction: "/api/collaborator/:slug/destroy", + + events: { + "click [data-role=destroy-collaborator]": "destroy", + }, + + show: function(){ + if (! this.loaded) { + this.load() + } + else { + this.__super__.show.call(this) + } + }, + + load: function(){ + $.get("/api/collaborator/:slug/index", this.populate.bind(this)) + }, + + populate: function(collaborators){ + // + collaborators.forEach(function(collab){ + var $el = $( this.template ) + $el.data("collaborator-id", collab.id) + + if (collab.user) { + $el.find(".email").remove() + + $el.find(".user") + .attr("href", "/profile/" + collab.username) + + $el.find(".avatar") + .css("background-image", "url(" + collab.photo + ")") + + $el.find(".username") + .html( collab.displayName ) + } + else { + $el.remove(".user") + $el.find(".email").html( collab.email ) + } + + $("#collaborators").append($el) + }.bind(this)) + + this.__super__.show.call(this) + }, + + success: function(data){ + this.populate([data]) + }, + + destroy: function(e){ + var _id = $(e.currentTarget).closest("li").data("collaborator-id") + }, + +}) diff --git a/public/assets/javascripts/ui/editor/EditorView.js b/public/assets/javascripts/ui/editor/EditorView.js index 4067c4d..5fc5147 100644 --- a/public/assets/javascripts/ui/editor/EditorView.js +++ b/public/assets/javascripts/ui/editor/EditorView.js @@ -16,6 +16,7 @@ var EditorView = View.extend({ this.mediaEditor = new MediaEditor ({ parent: this }) this.wallpaperPicker = new WallpaperPicker ({ parent: this }) this.lightControl = new LightControl ({ parent: this }) + this.collaborators = new Collaborators ({ parent: this }) }, load: function(name){ diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 3b00cd2..92eed33 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -1615,6 +1615,12 @@ form li textarea { text-decoration:underline; } +.aboutRoom .editlink { + color: red; + text-decoration: none; + border-bottom: 1px dotted; +} + .aboutRoom h2{ font-size: 13px; margin: 5px 0; diff --git a/server/index.js b/server/index.js index 212db01..e946788 100644 --- a/server/index.js +++ b/server/index.js @@ -125,8 +125,8 @@ site.route = function () { app.get('/project', middleware.ensureAuthenticated, views.modal) app.get('/project/new', middleware.ensureAuthenticated, views.modal) app.get('/project/new/:layout', middleware.ensureAuthenticated, views.editor_new) - app.get('/project/:slug', middleware.ensureProject, views.reader) - app.get('/project/:slug/view', middleware.ensureProject, views.reader) + app.get('/project/:slug', middleware.ensureProject, middleware.ensureIsCollaborator, views.reader) + app.get('/project/:slug/view', middleware.ensureProject, middleware.ensureIsCollaborator, views.reader) app.get('/project/:slug/edit', middleware.ensureProject, middleware.ensureIsCollaborator, views.editor) app.get('/api/layout', middleware.ensureAuthenticated, api.layouts.index) diff --git a/server/lib/api/collaborator.js b/server/lib/api/collaborator.js index 4b55f09..f39022f 100644 --- a/server/lib/api/collaborator.js +++ b/server/lib/api/collaborator.js @@ -54,9 +54,9 @@ var collaborator = { return res.json({ error: "can't find project" }) } var data = util.cleanQuery(req.body) - delete data.user_id - + data.email = util.sanitize( data.email ) data.project_id = req.project._id + delete data.user_id Collaborator.makeNonce(function(nonce){ data.nonce = nonce diff --git a/server/lib/views.js b/server/lib/views.js index 4faf80f..7137041 100644 --- a/server/lib/views.js +++ b/server/lib/views.js @@ -57,6 +57,8 @@ views.reader = function (req, res) { date: moment(req.project.updated_at).format("M/DD/YYYY"), author: user.displayName, authorlink: "/profile/" + user.username, + canEdit: req.isOwner || req.isCollaborator, + editlink: "/project/" + req.project.slug + "/edit", noui: !! (req.query.noui === '1'), }) }) diff --git a/views/controls/editor/collaborators.ejs b/views/controls/editor/collaborators.ejs index 448b6d4..035507b 100644 --- a/views/controls/editor/collaborators.ejs +++ b/views/controls/editor/collaborators.ejs @@ -1,14 +1,6 @@ -<div class="collaborators fixed animate"> +<div class="collaborators fixed mediaDrawer animate"> <span class="close">X</span> - <ul id="collaborator-list"> - <li> - <div class="avatar"></div> - <span class="username"></span> - <button class="remove-user">Remove</button> - </li> - </ul> - <div> To invite others to contribute to this project, submit their email address below. They'll receive an email with instructions to join this blog and register if they're not a Vvalls user yet. </div> @@ -18,4 +10,18 @@ <button id="collaborator-invite">Invite to this project</button> </form> + <ul id="collaborator-list"> + </ul> + </div> + +<script type="text/html" id="collaborator-template"> + <li> + <a class="user"> + <div class="avatar"></div> + <span class="username"></span> + </a> + <span class="email"></span> + <button data-role="destroy-collaborator" class="remove-user">Remove</button> + </li> +</script> diff --git a/views/controls/reader/about-room.ejs b/views/controls/reader/about-room.ejs index f990da8..2aa244b 100644 --- a/views/controls/reader/about-room.ejs +++ b/views/controls/reader/about-room.ejs @@ -3,7 +3,12 @@ [[- name ]],<br> <a href="[[- authorlink ]]">[[- author ]]</a> </h1> - <h2>Last modified [[- date ]]</h2> + <h2> + Last modified [[- date ]] + [[ if (canEdit) { ]] + · <a href="[[- editlink ]]" class="editlink">Edit</a> + [[ } ]] + </h2> <span>[[- description ]]</span> </div> diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs index 6d85699..ae5b31f 100644 --- a/views/partials/scripts.ejs +++ b/views/partials/scripts.ejs @@ -91,6 +91,7 @@ <script type="text/javascript" src="/assets/javascripts/ui/editor/EditorSettings.js"></script> <script type="text/javascript" src="/assets/javascripts/ui/editor/EditorToolbar.js"></script> <script type="text/javascript" src="/assets/javascripts/ui/editor/LightControl.js"></script> +<script type="text/javascript" src="/assets/javascripts/ui/editor/Collaborators.js"></script> <script type="text/javascript" src="/assets/javascripts/ui/editor/MediaEditor.js"></script> <script type="text/javascript" src="/assets/javascripts/ui/editor/MediaUpload.js"></script> <script type="text/javascript" src="/assets/javascripts/ui/editor/MediaViewer.js"></script> |
