From d8687ccb3a97604c33de770645da6f42d50aa471 Mon Sep 17 00:00:00 2001 From: cmrd Senya Date: Fri, 22 Jul 2016 23:14:34 +0300 Subject: [PATCH] Rename contacts[:count] to contacts_count in gon --- app/assets/javascripts/app/pages/profile.js | 4 ++-- app/assets/javascripts/app/views/profile_header_view.js | 2 +- app/assets/templates/profile_header_tpl.jst.hbs | 4 ++-- app/controllers/people_controller.rb | 8 ++------ app/controllers/photos_controller.rb | 4 +--- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/app/pages/profile.js b/app/assets/javascripts/app/pages/profile.js index 5bc6bd416..f42f1e31e 100644 --- a/app/assets/javascripts/app/pages/profile.js +++ b/app/assets/javascripts/app/pages/profile.js @@ -24,8 +24,8 @@ app.pages.Profile = app.views.Base.extend({ if(app.hasPreload("photos")){ this.photos = app.parsePreload("photos"); } - if(app.hasPreload("contacts")){ - this.contacts = app.parsePreload("contacts"); + if (app.hasPreload("contacts_count")) { + this.contacts = app.parsePreload("contacts_count"); } this.streamCollection = _.has(opts, "streamCollection") ? opts.streamCollection : null; diff --git a/app/assets/javascripts/app/views/profile_header_view.js b/app/assets/javascripts/app/views/profile_header_view.js index c5c0e40d5..5d49b2f0f 100644 --- a/app/assets/javascripts/app/views/profile_header_view.js +++ b/app/assets/javascripts/app/views/profile_header_view.js @@ -42,7 +42,7 @@ app.views.ProfileHeader = app.views.Base.extend({ }, _shouldShowContacts: function() { - return (this.contacts && this.contacts.count > 0); + return (this.contacts && this.contacts > 0); }, showMentionModal: function(){ diff --git a/app/assets/templates/profile_header_tpl.jst.hbs b/app/assets/templates/profile_header_tpl.jst.hbs index 41d2c3434..22bc5b7e0 100644 --- a/app/assets/templates/profile_header_tpl.jst.hbs +++ b/app/assets/templates/profile_header_tpl.jst.hbs @@ -88,13 +88,13 @@ {{t 'profile.contacts'}} -
{{contacts.count}}
+
{{contacts}}
{{else}} {{t 'profile.contacts'}} -
{{contacts.count}}
+
{{contacts}}
{{/if}} diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 90477fc49..21340b5ae 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -78,9 +78,7 @@ class PeopleController < ApplicationController gon.preloads[:photos] = { count: Photo.visible(current_user, @person).count(:all) } - gon.preloads[:contacts] = { - count: Contact.contact_contacts_for(current_user, @person).count(:all), - } + gon.preloads[:contacts_count] = Contact.contact_contacts_for(current_user, @person).count(:all) respond_with @person, layout: "with_header" end @@ -140,9 +138,7 @@ class PeopleController < ApplicationController gon.preloads[:photos] = { count: Photo.visible(current_user, @person).count(:all) } - gon.preloads[:contacts] = { - count: @contacts_of_contact.count(:all), - } + gon.preloads[:contacts_count] = @contacts_of_contact.count(:all) @contacts_of_contact = @contacts_of_contact.paginate(page: params[:page], per_page: (params[:limit] || 15)) @hashes = hashes_for_people @contacts_of_contact, @aspects respond_with @person, layout: "with_header" diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index dafe53307..72a200945 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -30,9 +30,7 @@ class PhotosController < ApplicationController gon.preloads[:photos] = { count: Photo.visible(current_user, @person).count(:all) } - gon.preloads[:contacts] = { - count: Contact.contact_contacts_for(current_user, @person).count(:all), - } + gon.preloads[:contacts_count] = Contact.contact_contacts_for(current_user, @person).count(:all) render "people/show", layout: "with_header" end format.mobile { render "people/show" }