VRFS-1442 band profile, members editing; change notifyAlert to default to 1 button; added band_admin attribute to band members

This commit is contained in:
Jonathan Kolyer 2014-11-26 04:32:06 +00:00
parent 588f03a199
commit 45542b7a1d
8 changed files with 74 additions and 25 deletions

View File

@ -20,6 +20,9 @@
// hide until we know if 'isMember'
$("#btn-follow-band").hide();
$("#btn-edit-band-profile").hide();
$("#btn-edit-band-info").hide();
$("#btn-edit-band-members").hide();
$("#btn-edit-band-delete").hide();
resetForm();
events();
@ -141,10 +144,16 @@
if (isMember) {
$("#btn-follow-band").hide();
$("#btn-edit-band-profile").show();
$("#btn-edit-band-info").show();
$("#btn-edit-band-members").show();
$("#btn-edit-band-delete").show();
}
else {
$("#btn-follow-band").show();
$("#btn-edit-band-profile").hide();
$("#btn-edit-band-info").hide();
$("#btn-edit-band-members").hide();
$("#btn-edit-band-delete").hide();
}
if ($('#band-profile-about-link').hasClass('active')) {
@ -247,6 +256,7 @@
rest.getBandFollowers(bandId)
.done(function(response) {
$.each(response, function(index, val) {
// var template = $('#template-profile-social').html();
var template = $('#template-band-profile-social').html();
var followerHtml = context.JK.fillTemplate(template, {
userId: val.id,
@ -354,10 +364,11 @@
instrumentLogoHtml += '<img src="' + inst + '" width="24" height="24" />&nbsp;';
}
}
var bandAdmin = musician.band_admin;
var template = $('#template-band-profile-members').html();
var memberHtml = context.JK.fillTemplate(template, {
userId: musician.id,
band_admin: bandAdmin,
profile_url: "/client#/profile/" + musician.id,
avatar_url: context.JK.resolveAvatarUrl(musician.photo_url),
name: musician.name,
@ -374,7 +385,7 @@
// wire up Follow button click handler
configureMemberFollowingButton(musician.is_following, musician.id);
configureRemoveMemberButton(musician.id, isPending);
configureRemoveMemberButton(musician.id, isPending, bandAdmin);
// TODO: wire up Friend button click handler
// var friend = isFriend(musician.id);
@ -382,21 +393,30 @@
});
}
function configureRemoveMemberButton(userId, isPending) {
function configureRemoveMemberButton(userId, isPending, bandAdmin) {
var $divMember = $('div[user-id=' + userId + ']', '#band-profile-members');
var $btnRemoveMember = $divMember.find('#btn-remove-member');
if (isMember && !isPending) {
if (isMember && !isPending && !bandAdmin) {
$btnRemoveMember.show();
$btnRemoveMember.unbind("click");
$btnRemoveMember.click(function() {
rest.removeBandMember(bandId, userId)
var confirmMemberDeleteTxt;
if (userId == context.JK.currentUserId)
confirmMemberDeleteTxt = 'Are you sure you want to delete yourself from the band?';
else
confirmMemberDeleteTxt = 'Are you sure you want to delete this member from the band?';
var confirmDialog = new context.JK.ConfirmDialog(app, "DELETE", confirmMemberDeleteTxt, "Edit Band Membership",
function() {
app.layout.closeDialog('confirm');
rest.removeBandMember(bandId, userId)
.done(function() {
$divMember.remove();
$divMember.remove();
})
.fail(app.ajaxError);
return false;
});
confirmDialog.initialize();
context.JK.app.layout.showDialog('confirm');
return false;
});
}
else {
@ -433,7 +453,10 @@
$('#band-profile-social-link').unbind('click').click(renderSocial);
$("#btn-edit-band-profile").unbind('click').click(function() {
//$('div[layout-id="band/setup"] .hdn-band-id').val(bandId);
context.location = "/client#/band/setup/" + bandId + '/step1';
return false;
});
$("#btn-edit-band-info").unbind('click').click(function() {
context.location = "/client#/band/setup/" + bandId + '/step1';
return false;
});

View File

@ -202,7 +202,7 @@
* title property and a text property.
*/
this.notify = function (message, descriptor) {
this.layout.notify(message, descriptor);
this.layout.notify(message, descriptor, true);
};
/** Shows an alert notification. Expects text, title */

View File

@ -867,7 +867,8 @@
// this allows clients to just specify the important action button without having to repeat the cancel descripton everywhere
if (buttons.length === 1) {
buttons.push(cancelButton);
// jkolyer: changed default to remove cancel as this is used as an alert, not a confirmation (see ConfirmDialog)
// buttons.push(cancelButton);
}
var $notify = $('[layout="notify"]');

View File

@ -14,7 +14,6 @@
var profileScreen = null;
var textMessageDialog = null;
var feed = null;
var isBandMember = false;
var instrument_logo_map = context.JK.getInstrumentIconMap24();
@ -609,6 +608,7 @@
addMoreBandsLink();
$.each(response, function (index, val) {
var isBandMember = false;
// build band member HTML
var musicianHtml = '';
@ -628,6 +628,9 @@
instrumentLogoHtml += '<img src="' + inst + '" title="' + toolTip + '" width="24" height="24" />&nbsp;';
}
}
if (!isBandMember)
isBandMember = musician.id === context.JK.currentUserId;
// this template is in _findSession.html.erb
var musicianTemplate = $('#template-musician-info').html();
musicianHtml += context.JK.fillTemplate(musicianTemplate, {
@ -645,6 +648,8 @@
bandId: val.id,
biography: val.biography,
profile_url: "/client#/bandProfile/" + val.id,
band_edit_url: "/client#/band/setup/" + val.id + '/step1',
band_member_url: "/client#/band/setup/" + val.id + '/step2',
avatar_url: context.JK.resolveBandAvatarUrl(val.photo_url),
name: val.name,
location: val.location,
@ -656,6 +661,13 @@
});
$('#profile-bands').append(bandHtml);
$('.profile-band-link-member-true').each(function(idx) {
isBandMember ? $(this).show() : $(this).hide();
});
$('.profile-band-link-member-false').each(function(idx) {
isBandMember ? $(this).hide() : $(this).show();
});
// wire up Band Follow button click handler
configureBandFollowingButton(val.is_following, val.id);

View File

@ -54,7 +54,7 @@ class ApiBandsController < ApiController
def musician_destroy
unless params[:id].blank? || params[:user_id].blank?
BandMusician.delete_all "(band_id = '#{params[:id]}' AND user_id = '#{params[:user_id]}')"
BandMusician.delete_all "(band_id = '#{params[:id]}' AND user_id = '#{params[:user_id]}' AND admin = 'f')"
end
render :json => {}, :status => 202
end
@ -236,4 +236,4 @@ class ApiBandsController < ApiController
raise PermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR
end
end
end
end

View File

@ -2,6 +2,10 @@ collection @musicians
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :follower_count, :following_count, :recording_count, :session_count, :biography
node :band_admin do |musician|
't' == musician.band_admin ? true : false
end
node :instruments do |musician|
unless musician.instruments.nil? || musician.instruments.size == 0
child :musician_instruments => :instruments do

View File

@ -19,9 +19,7 @@
<div class="right">
<a id="btn-follow-band" class="button-orange">FOLLOW</a>
<a id="btn-edit-band-profile" class="button-orange">PROFILE</a>
<a id="btn-edit-band-info" class="button-orange">EDIT BAND</a>
<a id="btn-edit-band-members" class="button-orange">INVITE MEMBERS</a>
<a id="btn-edit-band-profile" class="button-orange">EDIT PROFILE</a>
</div>
<br clear="all" /><br />
@ -54,7 +52,13 @@
<span id="band-profile-recording-stats"></span><br />
</div>
<div class="band-profile-about-right">
<p id="band-profile-biography"></p>
<div class="left">
<a id="btn-edit-band-info" class="button-orange">EDIT</a>
<a id="btn-edit-band-members" class="button-orange">INVITE</a>
<a id="btn-edit-band-delete" class="button-orange">DELETE</a>
</div>
<br clear="all" /><br />
<p id="band-profile-biography"></p>
</div>
<div class="band-profile-about-right">
<p><a id="band-profile-website" target="_blank" rel="external"></a></p><br />
@ -71,7 +75,7 @@
<br clear="all" />
</div>
<!-- @FIXME cf clients/_profile.html.erb to mimic layout for scrolling header -->
<div id="band-profile-social" class="band-profile-wrapper">
<div id="band-profile-social" class="band-profile-wrapper profile-body-content">
<div class="band-profile-social-left">
<h2>Followers</h2>
<div id="band-profile-social-followers">
@ -85,7 +89,7 @@
</div>
<script type="text/template" id="template-band-profile-members">
<div user-id="{userId}" class="band-profile-members">
<div user-id="{userId}" class="band-profile-members" band-admin="{band_admin}">
<div class="left" style="width:63px;">
<div class="avatar-small">
<img src="{avatar_url}" />
@ -123,11 +127,13 @@
</script>
<script type="text/template" id="template-band-profile-social">
<div class="profile-block">
<div>
<div class="band-profile-block">
<div user-id="{userId}" hoveraction="{hoverAction}" class="avatar-small">
<img src="{avatar_url}" />
</div>
<div user-id="{userId}" hoveraction="{hoverAction}" class="profile-block-name">{userName}</div>
<div class="profile-block-city">{location}</div>
<div user-id="{userId}" hoveraction="{hoverAction}" class="band-profile-block-name">{userName}</div>
<div class="band-profile-block-city">{location}</div>
</div>
</div>
</script>

View File

@ -206,7 +206,10 @@
</div>
<div class="result-list-button-wrapper">
<a class="button-orange smallbutton" href="{profile_url}">PROFILE</a>
<a id="btn-follow-band-2" class="button-orange smallbutton">FOLLOW</a>
<span class="profile-band-link-member-false"><a id="btn-follow-band-2" class="button-orange smallbutton">FOLLOW</a></span>
<span class="profile-band-link-member-true"><a href="{band_edit_url}" class="button-orange smallbutton">EDIT BAND</a></span>
<span class="profile-band-link-member-true"><a href="{band_member_url}" class="button-orange smallbutton">INVITE MEMBERS</a></span>
<span class="profile-band-link-delete"><a href="{band_delete_url}" class="button-orange smallbutton">DELETE</a></span>
</div>
</div>
</div>