Notifications and search page frontend updates
Updates introduce usage of client-side aspect dropdown rendering
This commit is contained in:
parent
94ce383498
commit
71ecd7b866
2 changed files with 26 additions and 4 deletions
|
|
@ -28,7 +28,8 @@ app.Router = Backbone.Router.extend({
|
||||||
"tags/:name": "followed_tags",
|
"tags/:name": "followed_tags",
|
||||||
"people/:id/photos": "photos",
|
"people/:id/photos": "photos",
|
||||||
"people/:id/contacts": "profile",
|
"people/:id/contacts": "profile",
|
||||||
"people": "_loadAspects",
|
"people": "pageWithAspectMembershipDropdowns",
|
||||||
|
"notifications": "pageWithAspectMembershipDropdowns",
|
||||||
|
|
||||||
"people/:id": "profile",
|
"people/:id": "profile",
|
||||||
"u/:name": "profile"
|
"u/:name": "profile"
|
||||||
|
|
@ -61,8 +62,7 @@ app.Router = Backbone.Router.extend({
|
||||||
|
|
||||||
contacts: function() {
|
contacts: function() {
|
||||||
app.aspect = new app.models.Aspect(gon.preloads.aspect);
|
app.aspect = new app.models.Aspect(gon.preloads.aspect);
|
||||||
app.contacts = new app.collections.Contacts(app.parsePreload("contacts"));
|
this._loadRelationshipsPreloads();
|
||||||
this._loadAspects();
|
|
||||||
|
|
||||||
var stream = new app.views.ContactStream({
|
var stream = new app.views.ContactStream({
|
||||||
collection: app.contacts,
|
collection: app.contacts,
|
||||||
|
|
@ -177,10 +177,32 @@ app.Router = Backbone.Router.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pageWithAspectMembershipDropdowns: function() {
|
||||||
|
this._loadRelationshipsPreloads();
|
||||||
|
this._renderAspectMembershipDropdowns();
|
||||||
|
},
|
||||||
|
|
||||||
_loadAspects: function() {
|
_loadAspects: function() {
|
||||||
app.aspects = new app.collections.Aspects(app.currentUser.get("aspects"));
|
app.aspects = new app.collections.Aspects(app.currentUser.get("aspects"));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_loadContacts: function() {
|
||||||
|
app.contacts = new app.collections.Contacts(app.parsePreload("contacts"));
|
||||||
|
},
|
||||||
|
|
||||||
|
_loadRelationshipsPreloads: function() {
|
||||||
|
this._loadContacts();
|
||||||
|
this._loadAspects();
|
||||||
|
},
|
||||||
|
|
||||||
|
_renderAspectMembershipDropdowns: function() {
|
||||||
|
$(".aspect_membership_dropdown.placeholder").each(function() {
|
||||||
|
var personId = $(this).data("personId");
|
||||||
|
var view = new app.views.AspectMembership({person: app.contacts.findWhere({"person_id": personId}).person});
|
||||||
|
$(this).html(view.render().$el);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
_hideInactiveStreamLists: function() {
|
_hideInactiveStreamLists: function() {
|
||||||
if(this.aspectsList && Backbone.history.fragment !== "aspects") {
|
if(this.aspectsList && Backbone.history.fragment !== "aspects") {
|
||||||
this.aspectsList.hideAspectsList();
|
this.aspectsList.hideAspectsList();
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class ContactsController < ApplicationController
|
||||||
|
|
||||||
@contacts = contacts_by_type(type)
|
@contacts = contacts_by_type(type)
|
||||||
@contacts_size = @contacts.length
|
@contacts_size = @contacts.length
|
||||||
gon.preloads[:contacts] = @contacts.map{ |c| ContactPresenter.new(c, current_user).full_hash_with_person }
|
gon.preloads[:contacts] = @contacts.map {|c| ContactPresenter.new(c, current_user).full_hash_with_person }
|
||||||
end
|
end
|
||||||
|
|
||||||
def contacts_by_type(type)
|
def contacts_by_type(type)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue