diff --git a/app/controllers/playlists_controller.rb b/app/controllers/playlists_controller.rb index 945c397a..cce51122 100644 --- a/app/controllers/playlists_controller.rb +++ b/app/controllers/playlists_controller.rb @@ -78,12 +78,11 @@ def load end def destroy - if current_user && params[:id] && (playlist = fetch_playlist) + if (playlist = current_user&.playlists&.find_by(id: params[:id])) playlist.destroy return render json: { success: true, msg: 'Playlist deleted' } end - - render json: { success: false, msg: 'Invalid delete request' } + render json: { success: false, msg: 'Invalid playlist delete request' } end def bookmark @@ -298,15 +297,19 @@ def activate_stored(playlist) def update_playlist(playlist) track_ids = playlist.playlist_tracks.order(position: :asc).pluck(:track_id) - session['playlist'].merge!( - tracks: track_ids, - shuffled_tracks: track_ids.shuffle, + session['playlist'].merge!(playlist_attrs(playlist, track_ids)) + end + + def playlist_attrs(playlist, track_ids) + { id: playlist.id, name: playlist.name, slug: playlist.slug, user_id: playlist.user.id, - username: playlist.user.username - ) + username: playlist.user.username, + tracks: track_ids, + shuffled_tracks: track_ids.shuffle + }.stringify_keys end def retrieve_bookmark(playlist) diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb index 90b100eb..3aa41bee 100644 --- a/app/helpers/navigation_helper.rb +++ b/app/helpers/navigation_helper.rb @@ -85,7 +85,7 @@ def char_starts_name_or_title?(current_item, char) end def default_char?(current_item, _char, idx) - (params[:char].nil? && current_item.nil? && idx.zero?) + params[:char].nil? && current_item.nil? && idx.zero? end def global_nav_items @@ -127,7 +127,7 @@ def playlists_sub_links def years_sub_links str = '' - ERAS.to_a.reverse.to_h.each do |_era, years| + ERAS.to_a.reverse.to_h.each_value do |years| years.reverse.each_with_index do |year, i| style = i + 1 == years.size ? 'margin-right: 15px' : '' css = year == params[:slug] ? 'active' : '' diff --git a/app/helpers/track_helper.rb b/app/helpers/track_helper.rb index dc07becf..4fcb2fae 100644 --- a/app/helpers/track_helper.rb +++ b/app/helpers/track_helper.rb @@ -15,7 +15,7 @@ def next_gap_link(song, date) # rubocop:disable Metrics/AbcSize, Metrics/MethodL .where('date BETWEEN ? AND ?', date, next_show.date) .count text = 'Next Performance' - text = "#{tag.i(class: 'glyphicon glyphicon-forward')}  #{text}(gap: #{gap})" + text = "#{tag.i(class: 'glyphicon glyphicon-forward')}  #{text} (gap: #{gap})" link_to(text.html_safe, "/#{next_show.date}/#{track.slug}") end diff --git a/app/javascript/packs/application.css.scss b/app/javascript/packs/application.css.scss index 1aabf61e..ec8c5ef0 100644 --- a/app/javascript/packs/application.css.scss +++ b/app/javascript/packs/application.css.scss @@ -68,19 +68,15 @@ $scrubbing: #1a80f6; border-radius: 5px; } .ui-dialog { - background: $gray_70; border-radius: 5px; .ui-dialog-titlebar { - background: $gray_80; border: none; - color: $background_gray; font-size: 1.5em; line-height: 1.2em; } .ui-dialog-content { font-family: 'Open Sans Condensed', sans-serif; - color: $background_gray } } .tagin_project {