From 3741dd19e79ce256ab383122f80c5eaf5382bf7d Mon Sep 17 00:00:00 2001 From: Ronan Date: Wed, 13 Apr 2016 14:53:23 +0200 Subject: [PATCH] [FIX] Add track to playlist (#16) --- app/styles/playlists.styl | 1 + app/styles/popup-menu.styl | 2 +- app/views/playlist.js | 6 ++++-- app/views/playlists.js | 4 ++++ app/views/popupPlaylists.js | 11 ++++++++++- app/views/templates/content.jst | 2 +- app/views/templates/notification.jst | 2 +- app/views/templates/player.jst | 2 +- app/views/templates/playlist.jst | 2 +- app/views/templates/playlists.jst | 2 +- app/views/templates/popupPlaylist.jst | 1 + app/views/templates/popupPlaylists.jst | 2 +- app/views/templates/tracks.jst | 2 +- 13 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 app/views/templates/popupPlaylist.jst diff --git a/app/styles/playlists.styl b/app/styles/playlists.styl index 15d53ac..f67a843 100644 --- a/app/styles/playlists.styl +++ b/app/styles/playlists.styl @@ -71,6 +71,7 @@ div[role='toolbar'] overflow: hidden text-overflow: "…" white-space: nowrap + a width: 100% height: 100% diff --git a/app/styles/popup-menu.styl b/app/styles/popup-menu.styl index bc16e56..256ae58 100644 --- a/app/styles/popup-menu.styl +++ b/app/styles/popup-menu.styl @@ -29,7 +29,7 @@ color: $text-dark align-items: center - a + p width: 100% height: 100% text-decoration: none diff --git a/app/views/playlist.js b/app/views/playlist.js index 62f7759..6b72ef4 100644 --- a/app/views/playlist.js +++ b/app/views/playlist.js @@ -4,10 +4,12 @@ import application from '../application'; const PlaylistView = Mn.ItemView.extend({ - template: require('./templates/playlist'), - tagName: 'li', + initialize(options) { + this.template = options.template; + }, + className() { let currentPlaylist = application.appState.get('currentPlaylist'); let selected = currentPlaylist == this.model ? 'selected' : '' diff --git a/app/views/playlists.js b/app/views/playlists.js index b5e607a..5ddaf11 100644 --- a/app/views/playlists.js +++ b/app/views/playlists.js @@ -12,6 +12,10 @@ const Playlists = Mn.CompositeView.extend({ childView: PlaylistView, + childViewOptions: { + template: require('./templates/playlist') + }, + modelEvents: { "change:currentPlaylist": "render" }, diff --git a/app/views/popupPlaylists.js b/app/views/popupPlaylists.js index 2915050..fad259c 100644 --- a/app/views/popupPlaylists.js +++ b/app/views/popupPlaylists.js @@ -12,6 +12,10 @@ const PopupPlaylists = Mn.CompositeView.extend({ childView: PlaylistView, + childViewOptions: { + template: require('./templates/popupPlaylist') + }, + ui: { addPlaylist: '#add-playlist', playlistText: '#playlist-text', @@ -19,7 +23,7 @@ const PopupPlaylists = Mn.CompositeView.extend({ }, events: { - 'click li': 'addToPlaylist', + 'click li p': 'addToPlaylist', 'click @ui.addPlaylist': 'showInput', 'keyup @ui.playlistText': 'keyupPlaylistText', }, @@ -69,6 +73,11 @@ const PopupPlaylists = Mn.CompositeView.extend({ newPlaylist.addTrack(this.model); application.allPlaylists.add(newPlaylist); this.ui.playlistText.val(''); + let notification = { + status: 'ok', + message: 'Added to ' + newPlaylist.get('title') + } + application.channel.request('notification', notification); } }, diff --git a/app/views/templates/content.jst b/app/views/templates/content.jst index 3471719..dd6c6fe 100644 --- a/app/views/templates/content.jst +++ b/app/views/templates/content.jst @@ -1,2 +1,2 @@
-
\ No newline at end of file +
diff --git a/app/views/templates/notification.jst b/app/views/templates/notification.jst index 6f9b903..c154ca9 100644 --- a/app/views/templates/notification.jst +++ b/app/views/templates/notification.jst @@ -9,4 +9,4 @@ <% } %>

<%= message %>

- \ No newline at end of file + diff --git a/app/views/templates/player.jst b/app/views/templates/player.jst index 41edc8e..2f8fb10 100644 --- a/app/views/templates/player.jst +++ b/app/views/templates/player.jst @@ -62,4 +62,4 @@ - \ No newline at end of file + diff --git a/app/views/templates/playlist.jst b/app/views/templates/playlist.jst index f5f9518..306d365 100644 --- a/app/views/templates/playlist.jst +++ b/app/views/templates/playlist.jst @@ -1 +1 @@ -<%= title %> \ No newline at end of file +<%= title %> diff --git a/app/views/templates/playlists.jst b/app/views/templates/playlists.jst index a84b85c..3bbab5f 100644 --- a/app/views/templates/playlists.jst +++ b/app/views/templates/playlists.jst @@ -13,4 +13,4 @@

<%= t('add playlist') %>

- \ No newline at end of file + diff --git a/app/views/templates/popupPlaylist.jst b/app/views/templates/popupPlaylist.jst new file mode 100644 index 0000000..95c4ce8 --- /dev/null +++ b/app/views/templates/popupPlaylist.jst @@ -0,0 +1 @@ +

<%= title %>

diff --git a/app/views/templates/popupPlaylists.jst b/app/views/templates/popupPlaylists.jst index 8ba2c81..a959ca3 100644 --- a/app/views/templates/popupPlaylists.jst +++ b/app/views/templates/popupPlaylists.jst @@ -6,4 +6,4 @@

Add to New Playlist

- \ No newline at end of file + diff --git a/app/views/templates/tracks.jst b/app/views/templates/tracks.jst index 4a9602e..a5d08c0 100644 --- a/app/views/templates/tracks.jst +++ b/app/views/templates/tracks.jst @@ -5,4 +5,4 @@
ALBUM
LENGTH
- \ No newline at end of file +