* rename profile header view to make name more accurate
* include 'js-routes' for rails routes in javascript (TODO: config options?) * add handlebars helper for rails routes
This commit is contained in:
parent
0092c9c483
commit
9a16560d8d
15 changed files with 131 additions and 81 deletions
1
Gemfile
1
Gemfile
|
|
@ -81,6 +81,7 @@ gem 'handlebars_assets', '0.18.0'
|
|||
gem 'jquery-rails', '3.1.2'
|
||||
gem 'rails-assets-jquery', '1.11.1' # Should be kept in sync with jquery-rails
|
||||
gem 'js_image_paths', '0.0.1'
|
||||
gem 'js-routes', '0.9.9'
|
||||
|
||||
# jQuery plugins
|
||||
|
||||
|
|
|
|||
|
|
@ -238,6 +238,9 @@ GEM
|
|||
thor (>= 0.14, < 2.0)
|
||||
jquery-ui-rails (4.2.1)
|
||||
railties (>= 3.2.16)
|
||||
js-routes (0.9.9)
|
||||
railties (>= 3.2)
|
||||
sprockets-rails
|
||||
js_image_paths (0.0.1)
|
||||
rails (~> 4.0)
|
||||
json (1.8.1)
|
||||
|
|
@ -533,6 +536,7 @@ DEPENDENCIES
|
|||
jasmine (= 2.0.2)
|
||||
jasmine-jquery-rails (= 2.0.3)
|
||||
jquery-rails (= 3.1.2)
|
||||
js-routes (= 0.9.9)
|
||||
js_image_paths (= 0.0.1)
|
||||
json (= 1.8.1)
|
||||
markerb (= 1.0.2)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,15 @@ Handlebars.registerHelper('imageUrl', function(path){
|
|||
return ImagePaths.get(path);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('urlTo', function(path_helper, id, data){
|
||||
if( !data ) {
|
||||
// only one argument given to helper, mangle parameters
|
||||
data = id;
|
||||
return Routes[path_helper+'_path'](data.hash);
|
||||
}
|
||||
return Routes[path_helper+'_path'](id, data.hash);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('linkToPerson', function(context, block) {
|
||||
if( !context ) context = this;
|
||||
var html = "<a href=\"/people/" + context.guid + "\" class=\"author-name ";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
// TODO: update the aspect_membership dropdown, too, every time we render the view...
|
||||
app.pages.Profile = app.views.Base.extend({
|
||||
events: {
|
||||
'click #block_user_button': 'blockPerson',
|
||||
|
|
@ -8,7 +7,7 @@ app.pages.Profile = app.views.Base.extend({
|
|||
|
||||
subviews: {
|
||||
'#profile .badge': 'sidebarView',
|
||||
'.stream_container': 'streamView'
|
||||
'.profile_header': 'headerView'
|
||||
},
|
||||
|
||||
tooltipSelector: '.profile_button div, .sharing_message_container',
|
||||
|
|
@ -30,8 +29,8 @@ app.pages.Profile = app.views.Base.extend({
|
|||
return new app.views.ProfileSidebar({model: this.model});
|
||||
},
|
||||
|
||||
streamView: function() {
|
||||
return new app.views.ProfileStream({model: this.model});
|
||||
headerView: function() {
|
||||
return new app.views.ProfileHeader({model: this.model});
|
||||
},
|
||||
|
||||
blockPerson: function(evt) {
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ app.views.Hovercard = app.views.Base.extend({
|
|||
})) );
|
||||
|
||||
// set aspect dropdown
|
||||
// TODO render me client side!!!
|
||||
var href = this.href();
|
||||
href += "/aspect_membership_button";
|
||||
if(gon.bootstrap == true){
|
||||
|
|
|
|||
25
app/assets/javascripts/app/views/profile_header_view.js
Normal file
25
app/assets/javascripts/app/views/profile_header_view.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
app.views.ProfileHeader = app.views.Base.extend({
|
||||
templateName: 'profile_header',
|
||||
|
||||
presenter: function() {
|
||||
return _.extend({}, this.defaultPresenter(), {
|
||||
is_blocked: this.model.isBlocked()
|
||||
});
|
||||
},
|
||||
|
||||
postRenderTemplate: function() {
|
||||
var self = this;
|
||||
var dropdownEl = this.$('.aspect_membership_dropdown.placeholder');
|
||||
if( dropdownEl.length == 0 ) return;
|
||||
|
||||
// TODO render me client side!!!
|
||||
var href = this.model.url() + '/aspect_membership_button?create=true';
|
||||
if( gon.bootstrap ) href += '&bootstrap=true';
|
||||
|
||||
$.get(href, function(resp) {
|
||||
dropdownEl.html(resp);
|
||||
new app.views.AspectMembership({el: dropdownEl});
|
||||
})
|
||||
}
|
||||
});
|
||||
|
|
@ -15,4 +15,9 @@ app.views.ProfileSidebar = app.views.Base.extend({
|
|||
_shouldDoProfileBtns: function() {
|
||||
return (app.currentUser.authenticated() && !this.model.get('is_own_profile'));
|
||||
},
|
||||
|
||||
postRenderTemplate: function() {
|
||||
// UGLY (re-)attach the facebox
|
||||
this.$('a[rel*=facebox]').facebox();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
|
||||
app.views.ProfileStream = app.views.Base.extend({
|
||||
templateName: 'profile_stream',
|
||||
|
||||
presenter: function() {
|
||||
return _.extend({}, this.defaultPresenter(), {
|
||||
is_blocked: this.model.isBlocked()
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
* the COPYRIGHT file.
|
||||
*/
|
||||
//= require js_image_paths
|
||||
//= require js-routes
|
||||
//= require underscore
|
||||
//= require backbone
|
||||
//= require jquery.hotkeys
|
||||
|
|
|
|||
|
|
@ -3,13 +3,12 @@
|
|||
{{#if loggedIn}}
|
||||
{{#if is_own_profile}}
|
||||
{{!-- can't block myself, so don't check it here --}}
|
||||
<a href="TODO" class="button creation">{{t 'people.edit_my_profile'}}</a>
|
||||
{{/if}}
|
||||
{{#if is_blocked}}
|
||||
<a href="{{urlTo 'edit_profile'}}" class="button creation">{{t 'people.edit_my_profile'}}</a>
|
||||
{{else}} {{#if is_blocked}}
|
||||
<a href="#" id="unblock_user_button" class="button">{{t 'people.stop_ignoring'}}</a>
|
||||
{{else}}
|
||||
<div class="placeholder aspect_membership_dropdown"></div>
|
||||
{{/if}}
|
||||
{{/if}}{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
|
|
@ -17,6 +16,10 @@
|
|||
<span class="diaspora_handle">{{diaspora_id}}</span>
|
||||
|
||||
<div class="description">
|
||||
|
||||
{{#if loggedIn}}
|
||||
TODO
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
|
@ -10,22 +10,25 @@
|
|||
{{{sharingBadge this}}}
|
||||
|
||||
{{#if is_receiving}}
|
||||
{{!-- create status message with mention --}}
|
||||
<div class="profile_button">
|
||||
<a href="TODO" rel="facebox">
|
||||
<a href="{{urlTo 'new_status_message' person_id=id}}" rel="facebox">
|
||||
<div id="mention_button" class="icons-mention" title="{{t 'people.mention'}}" data-placement="bottom"></div>
|
||||
</a>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if is_mutual}}
|
||||
{{!-- create private conversation with person --}}
|
||||
<div class="profile_button">
|
||||
<a href="TODO" rel="facebox">
|
||||
<a href="{{urlTo 'new_conversation' contact_id=contact.id name=name facebox=true}}" rel="facebox">
|
||||
<div id="message_button" class="icons-message" title="{{t 'people.message'}}" data-placement="bottom"></div>
|
||||
</a>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if is_not_blocked}}
|
||||
{{!-- ignore the person --}}
|
||||
<div class="profile_button">
|
||||
<a href="#" rel="nofollow">
|
||||
<div id="block_user_button" class="icons-ignoreuser block_user" title="{{t 'ignore'}}" data-placement="bottom"></div>
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class PeopleController < ApplicationController
|
|||
|
||||
mark_corresponding_notifications_read if user_signed_in?
|
||||
|
||||
@aspect = :profile # what does this do?
|
||||
@aspect = :profile # let aspect dropdown create new aspects
|
||||
@post_type = :all # for mobile
|
||||
@person_json = PersonPresenter.new(@person, current_user).full_hash_with_profile
|
||||
|
||||
|
|
@ -179,7 +179,9 @@ class PeopleController < ApplicationController
|
|||
return render :text => I18n.t('people.person.thats_you') if @person == current_user.person
|
||||
|
||||
@contact = current_user.contact_for(@person) || Contact.new
|
||||
@aspect = :profile if params[:create] # let aspect dropdown create new aspects
|
||||
bootstrap = params[:bootstrap] || false
|
||||
|
||||
render :partial => 'aspect_membership_dropdown', :locals => {:contact => @contact, :person => @person, :hang => 'left', :bootstrap => bootstrap}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ class PersonPresenter < BasePresenter
|
|||
base_hash.merge({
|
||||
relationship: relationship,
|
||||
block: is_blocked? ? BlockPresenter.new(current_user_person_block).base_hash : false,
|
||||
contact: { id: current_user_person_contact.id },
|
||||
is_own_profile: own_profile?
|
||||
})
|
||||
end
|
||||
|
|
@ -44,7 +45,7 @@ class PersonPresenter < BasePresenter
|
|||
end
|
||||
|
||||
def relationship
|
||||
contact = current_user.contact_for(@presentable)
|
||||
contact = current_user_person_contact
|
||||
|
||||
is_mutual = contact ? contact.mutual? : false
|
||||
is_sharing = contact ? contact.sharing? : false
|
||||
|
|
@ -68,6 +69,10 @@ class PersonPresenter < BasePresenter
|
|||
@block ||= current_user.blocks.where(person_id: id).limit(1).first
|
||||
end
|
||||
|
||||
def current_user_person_contact
|
||||
@contact ||= current_user.contact_for(@presentable)
|
||||
end
|
||||
|
||||
def is_blocked?
|
||||
current_user_person_block.present?
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,9 +15,11 @@
|
|||
= render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact }
|
||||
|
||||
.span-18.last
|
||||
.stream_container
|
||||
.profile_header
|
||||
= render 'people/sub_header', :person => @person, :contact => @contact
|
||||
|
||||
.stream_container
|
||||
|
||||
#main_stream.stream
|
||||
- if @block.present?
|
||||
.dull
|
||||
|
|
|
|||
Loading…
Reference in a new issue