From c21e096724ccd662a268c2ba302668b6f3107000 Mon Sep 17 00:00:00 2001 From: Pepf Date: Fri, 18 Jul 2014 13:10:24 +0200 Subject: [PATCH 1/3] Playlist privacy features --- client/lib/globalhelpers.js | 8 +++ client/views/playlists.html | 76 +++++++++++++++++++--------- client/views/playlists.js | 37 ++++++++++++++ client/views/userProfile.html | 14 +++-- client/views/userProfile.js | 13 ++++- collections.js => lib/collections.js | 10 +++- lib/router.js | 4 +- server/lib/publish.js | 7 +-- server/permissions.js | 25 ++++++++- server/serverMethods.js | 10 ++++ 10 files changed, 166 insertions(+), 38 deletions(-) rename collections.js => lib/collections.js (91%) create mode 100644 server/serverMethods.js diff --git a/client/lib/globalhelpers.js b/client/lib/globalhelpers.js index 7746194..c96a32a 100644 --- a/client/lib/globalhelpers.js +++ b/client/lib/globalhelpers.js @@ -31,6 +31,14 @@ Handlebars.registerHelper('username', function(user){ } }); +Handlebars.registerHelper('privacyIcon', function(playlist) { + var icon = "globe"; + if(this.privacy == "viewonly") { icon = "eye-open"; } + if(this.privacy == "private") { icon = "lock"; } + + return ''; +}); + Template.userProfile.avatarUrl = function() { if(this.profile.avatar) { return this.profile.avatar; diff --git a/client/views/playlists.html b/client/views/playlists.html index 336b783..300dbb7 100644 --- a/client/views/playlists.html +++ b/client/views/playlists.html @@ -1,15 +1,19 @@ diff --git a/client/views/playlists.js b/client/views/playlists.js index 2ce1ae8..5d5423e 100644 --- a/client/views/playlists.js +++ b/client/views/playlists.js @@ -1,3 +1,35 @@ +Template.insertPlaylistForm.rendered = function() { + Session.setDefault('playlistPrivacy','public'); + this.find('[data-schema-key=privacy]').value = 'public'; + $("button").tooltip(); + AutoForm.hooks({ + insertPlaylistForm: { + onSuccess: function(operation, result, template) { + Router.go('/playlist/'+result); + } + } + }); +} + +Template.insertPlaylistForm.events = { + 'click #privacyToggle button' : function(e,template) { + var btn = e.currentTarget; + Session.set('playlistPrivacy',btn.getAttribute("data-action")); + template.find('[data-schema-key=privacy]').value = btn.getAttribute("data-action"); + } +} + + +Template.playlist.rendered = function() { + AutoForm.hooks({ + removeButton: { //on successful remove, go back to playlist page + onSuccess: function(operation, result, template) { + Router.go('playlists'); + } + } + }); +} + Template.playlist.selected = function () { return Session.equals("playing_song", this._id) ? "selected" : ''; }; @@ -17,6 +49,7 @@ Template.playlist.playing = function () { return false; } }; + Template.playlist.songCount = function() { return this.songs ? this.songs.length : 0; }; @@ -207,6 +240,10 @@ Template.updatePlaylistForm.editingDoc = function () { return Playlists.findOne({_id: this._id}); }; +Template.ownerPanel.editingDoc = function () { + return Playlists.findOne({_id: this._id}); +}; + // initialize active_tab Session.set('active_tab', 'songs'); diff --git a/client/views/userProfile.html b/client/views/userProfile.html index c76feda..69b5147 100644 --- a/client/views/userProfile.html +++ b/client/views/userProfile.html @@ -34,11 +34,19 @@

Hey {{this.username}},

On top of that, you have already liked {{profile.lovedSongs.length}} songs, keep up the good work!

-

Your playlists

-

If we are correct, these are playlists made by you

+

Public playlists

+

If we are correct, these are playlists made by you and visible by everyone

{{#each userPlaylists}} {{>userPlaylist}} {{/each}} +

Private playlists

+ {{#if privatePlaylists}}

Additionally, you have some private playlists

+ {{else}} +

You have no private playlists yet

+ {{/if}} + {{#each privatePlaylists}} + {{>userPlaylist}} + {{/each}} {{else}}
@@ -53,7 +61,7 @@

{{this.username}}