link musician/band profile on feed page

This commit is contained in:
Bert Owen 2014-04-18 19:14:11 -07:00
parent 0a811a147c
commit bd0df88e24
6 changed files with 57 additions and 6 deletions

View File

@ -282,6 +282,23 @@
return false;
}
function toggleUserProfile() {
var userId = $(this).attr('user-id');
window.location = '/client#/profile/' + userId;
return false;
}
function toggleBandProfile() {
var bandId = $(this).attr('band-id');
if (bandId == null) {
var userId = $(this).attr('user-id');
window.location = '/client#/profile/' + userId;
}
else {
window.location = '/client#/bandProfile/' + bandId;
}
return false;
}
function renderFeeds(feeds) {
@ -302,6 +319,9 @@
$('.details', $feedItem).click(toggleSessionDetails);
$('.details-arrow', $feedItem).click(toggleSessionDetails);
$('.play-button', $feedItem).click(toggleSessionPlay);
$('.avatar-tiny', $feedItem).click(toggleUserProfile);
$('.musician-name', $feedItem).click(toggleUserProfile);
$('.artist', $feedItem).click(toggleBandProfile);
// put the feed item on the page
renderFeed($feedItem);

View File

@ -241,6 +241,7 @@
margin-bottom:10px;
overflow: hidden;
white-space: nowrap;
text-decoration: none;
}
.name {

View File

@ -3,6 +3,18 @@ module FeedsHelper
(music_session_history.band.nil? ? nil : music_session_history.band.name) || music_session_history.user.name
end
def session_artist_id(music_session_history)
(music_session_history.band.nil? ? nil : music_session_history.band.id) || music_session_history.user.id
end
def session_artist_hoveraction(music_session_history)
music_session_history.band.nil? ? 'musician' : 'band'
end
def session_artist_datakey(music_session_history)
music_session_history.band.nil? ? 'user-id' : 'band-id'
end
def session_avatar(music_session_history)
image_tag resolve_avatarables(music_session_history.band, music_session_history.user)
end
@ -50,6 +62,18 @@ module FeedsHelper
(recording.band.nil? ? nil : recording.band.name) || recording.candidate_claimed_recording.user.name
end
def recording_artist_id(recording)
(recording.band.nil? ? nil : recording.band.id) || recording.candidate_claimed_recording.user.id
end
def recording_artist_hoveraction(recording)
recording.band.nil? ? 'musician' : 'band'
end
def recording_artist_datakey(recording)
recording.band.nil? ? 'user-id' : 'band-id'
end
def recording_avatar(recording)
image_tag resolve_avatarables(recording.band, recording.owner)
end

View File

@ -14,6 +14,9 @@ glue :music_session_history do
helpers: {
avatar: asset_path(resolve_avatarables(history.band, history.user)),
artist_name: session_artist_name(history),
artist_id: session_artist_id(history),
artist_datakey: session_artist_datakey(history),
artist_hoveraction: session_artist_hoveraction(history),
utc_created_at: history.created_at.getutc.iso8601,
description: session_description(history),
status: session_text(history),
@ -81,6 +84,9 @@ glue :recording do
helpers: {
avatar: asset_path(resolve_avatarables(recording.band, recording.owner)),
artist_name: recording_artist_name(recording),
artist_id: recording_artist_id(recording),
artist_hoveraction: recording_artist_hoveraction(recording),
artist_datakey: recording_artist_datakey(recording),
utc_created_at: recording.created_at.getutc.iso8601,
name: recording_name(recording),
description: recording_description(recording),

View File

@ -6,7 +6,7 @@
/ type and artist
.left.ml20.w15
.title{hoveraction: 'session', :'session-id' => '{{data.feed_item.id}}' } SESSION
.artist
%a.artist{href: "#", :hoveraction => '{{data.feed_item.helpers.artist_hoveraction}}', :'{{data.feed_item.helpers.artist_datakey}}' => '{{data.feed_item.helpers.artist_id}}'}
= '{{data.feed_item.helpers.artist_name}}'
%time.small.created_at.timeago{datetime: '{{data.feed_item.helpers.utc_created_at}}'}= '{{data.feed_item.created_at}}'
/ name and description
@ -55,10 +55,10 @@
= '{% _.each(data.feed_item.participants, function(user) { %}'
%tr
%td{:width => "24"}
%a.avatar-tiny{:href => "#"}
%a.avatar-tiny{:href => "#", :hoveraction => "musician", :'user-id' => '{{user.id}}'}
%img{src: '{{user.helpers.avatar}}'}
%td
%a{:href => "#"}
%a.musician-name{:href => "#", :hoveraction => "musician", :'user-id' => '{{user.id}}'}
= '{{user.first_name}} {{user.last_name}}'
%td
.nowrap

View File

@ -6,7 +6,7 @@
/ type and artist
.left.ml20.w15
.title{hoveraction: 'recording', :'recording-id' => '{{data.candidate_claimed_recording.id}}' } RECORDING
.artist
%a.artist{href: "#", :hoveraction => '{{data.feed_item.helpers.artist_hoveraction}}', :'{{data.feed_item.helpers.artist_datakey}}' => '{{data.feed_item.helpers.artist_id}}'}
= '{{data.feed_item.helpers.artist_name}}'
%time.small.created_at.timeago{datetime: '{{data.feed_item.helpers.utc_created_at}}'}
= '{{data.feed_item.created_at}}'
@ -75,10 +75,10 @@
= '{% _.each(data.feed_item.grouped_tracks, function(track) { %}'
%tr
%td{:width => "24"}
%a.avatar-tiny{:href => "#"}
%a.avatar-tiny{:href => "#", :hoveraction => "musician", :"user-id" => '{{track.musician.id}}'}
%img{src: '{{track.musician.helpers.avatar}}'}
%td
%a{:href => "#"}
%a.musician-name{:href => "#", :hoveraction => "musician", :"user-id" => '{{track.musician.id}}'}
= '{{track.musician.first_name}} {{track.musician.last_name}}'
%td
.nowrap