Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.23.0/no-editing-on-profile-page #1465

Merged
merged 2 commits into from
Jan 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion website/static/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,6 @@ h4 {
/* Profile gravatar
-------------------------------------------------- */
#profile-gravatar{
float:left;
margin-right:.5em;
width:70px;
height:70px;
Expand Down Expand Up @@ -1651,6 +1650,24 @@ div.pydocx-center{
display: block;
}

span.edit-profile-settings {
display: block;
position: absolute;
bottom: 0;
right: 0;
}

div.profile-fullname{
display: block;
position: relative;
bottom: 0;
}

span#profileFullname{
position: absolute;
bottom: 0;
}

.scripted {display: none;}

.pointer {cursor: pointer;}
Expand Down
6 changes: 3 additions & 3 deletions website/static/js/pages/profile-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ require('../logFeed.js'); // Needed for nodelists to work

var ctx = window.contextVars;
// Instantiate all the profile modules
new profile.Social('#social', ctx.socialUrls, ['edit', 'view']);
new profile.Jobs('#jobs', ctx.jobsUrls, ['edit', 'view']);
new profile.Schools('#schools', ctx.schoolsUrls, ['edit', 'view']);
new profile.Social('#social', ctx.socialUrls, ['view']);
new profile.Jobs('#jobs', ctx.jobsUrls, ['view']);
new profile.Schools('#schools', ctx.schoolsUrls, ['view']);
13 changes: 9 additions & 4 deletions website/static/js/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@ var BaseViewModel = function(urls, modes) {
self.urls = urls;
self.modes = modes || ['view'];
self.viewable = $.inArray('view', modes) >= 0;
self.editable = ko.observable(false);
self.mode = ko.observable(self.viewable ? 'view' : 'edit');
self.editAllowed = $.inArray('edit', self.modes) >= 0;
self.editable = ko.observable(self.editAllowed);
self.mode = ko.observable(self.editable() ? 'edit' : 'view');

self.original = ko.observable();
self.tracked = []; // Define for each view model that inherits
Expand Down Expand Up @@ -286,7 +287,7 @@ BaseViewModel.prototype.fetch = function() {
};

BaseViewModel.prototype.edit = function() {
if (this.editable()) {
if (this.editable() && this.editAllowed) {
this.mode('edit');
}
};
Expand Down Expand Up @@ -651,7 +652,11 @@ ListViewModel.prototype.removeContent = function(content) {

ListViewModel.prototype.unserialize = function(data) {
var self = this;
self.editable(data.editable);
if(self.editAllowed) {
self.editable(data.editable);
} else {
self.editable(false);
}
self.contents(ko.utils.arrayMap(data.contents || [], function (each) {
return new self.ContentModel(self).unserialize(each);
}));
Expand Down
2 changes: 1 addition & 1 deletion website/templates/include/profile/social.mako
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<div class="well well-sm">Not provided</div>
</div>

<div data-bind="if: editable">
<div data-bind="if: editAllowed">
<a class="btn btn-default" data-bind="click: edit">Edit</a>
</div>

Expand Down
41 changes: 11 additions & 30 deletions website/templates/profile.mako
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,6 @@
<%def name="title()">${profile["fullname"]}</%def>

<%def name="javascript_bottom()">

<script>
% if user["is_profile"]:
$.fn.editable.defaults.mode = 'inline';
$(function() {
$('#profile-fullname > span').editable({
type: 'text',
pk: '${profile["id"]}',
name: 'fullname',
url: '/api/v1/profile/${profile["id"]}/edit/',
title: 'Edit Full Name',
placement: 'bottom',
value: '${profile["fullname"] | js_str}',
success: function(data) {
// Also change the display name in the user info table
$(".fullname").text(data['name']);
}
});

var gravatar = $('#profile-gravatar');
});
% endif
## TODO: Make the following modules CommonJS-compatible:
## $script(['/static/addons/badges/bake-badges.js'], 'bakery');
## $script(['/static/addons/badges/badge-popover.js'], 'display');
</script>
% if user['is_profile']:
<%include file="profile/modal_change_avatar.mako"/>
% endif
Expand All @@ -43,15 +17,22 @@


<div class="page-header">
<a href="#changeAvatarModal" data-toggle="modal">
<div class="profile-fullname">
% if user['is_profile']:
<a href="#changeAvatarModal" data-toggle="modal">
<img id='profile-gravatar' src="${profile['gravatar_url']}"
rel="tooltip" title="click to change avatar"/>
</a>
% else:
<img id='profile-gravatar' src="${profile['gravatar_url']}"/>
<img id='profile-gravatar' src="${profile['gravatar_url']}"/>
% endif

<span id="profileFullname" class="h1 overflow ">${profile["fullname"]}</span>
<span class="edit-profile-settings">
% if user['is_profile']:
<a href="/settings/">Edit your profile</a></span>
% endif
</a>
<h1 id="profile-fullname"><span class="overflow">${profile["fullname"]}</span></h1>
</div>
</div><!-- end-page-header -->


Expand Down