diff --git a/app/assets/javascripts/app/views/contacts_view.js b/app/assets/javascripts/app/views/contacts_view.js index 5475f9b7b..1c85a3599 100644 --- a/app/assets/javascripts/app/views/contacts_view.js +++ b/app/assets/javascripts/app/views/contacts_view.js @@ -4,7 +4,7 @@ app.views.Contacts = Backbone.View.extend({ events: { "click #contacts_visibility_toggle" : "toggleContactVisibility", - "click #change_aspect_name" : "showNameChangeForm" + "click #change_aspect_name" : "showAspectNameForm" }, initialize: function() { @@ -33,7 +33,7 @@ app.views.Contacts = Backbone.View.extend({ } }, - showNameChangeForm: function() { + showAspectNameForm: function() { $(".header > h3").hide(); $(".header > #aspect_name_form").show(); }, diff --git a/app/assets/javascripts/aspect-edit-pane.js b/app/assets/javascripts/aspect-edit-pane.js index 57be91bd2..27dc0f07d 100644 --- a/app/assets/javascripts/aspect-edit-pane.js +++ b/app/assets/javascripts/aspect-edit-pane.js @@ -1,34 +1,3 @@ -/* Copyright (c) 2010-2011, Diaspora Inc. This file is - * licensed under the Affero General Public License version 3 or later. See - * the COPYRIGHT file. - */ - -function toggleAspectTitle(){ - $("#aspect_name_title").toggleClass('hidden'); - $("#aspect_name_edit").toggleClass('hidden'); -} - -function updateAspectName(new_name) { - $('#aspect_name_title .name').text(new_name); - $('input#aspect_name').val(new_name); -} -function updatePageAspectName( an_id, new_name) { - $('ul#aspect_nav [data-aspect-id="'+an_id+'"] .selectable').text(new_name); -} - -$(document).ready(function() { - $(document).on('click', '#rename_aspect_link', function(){ - toggleAspectTitle(); - }); - - $(document).on('ajax:success', 'form.edit_aspect', function(evt, data, status, xhr) { - updateAspectName(data['name']); - updatePageAspectName( data['id'], data['name'] ); - toggleAspectTitle(); - }); -}); - - /** * TEMPORARY SOLUTION * TODO remove me, when the contacts section is done with Backbone.js ... diff --git a/app/assets/stylesheets/aspects.css.scss b/app/assets/stylesheets/aspects.css.scss index 8b2730d08..a6603be88 100644 --- a/app/assets/stylesheets/aspects.css.scss +++ b/app/assets/stylesheets/aspects.css.scss @@ -38,224 +38,6 @@ display: inline-block; } - - -/* -- Used in contacts/index.html.haml -- */ -#aspect_controls { - @include border-radius(2px); - background-color: #fafafa; - border: 1px solid #ccc; - padding: 10px; - min-height: 23px; - - .button, .button_to { - margin-right: 5px; - } - - .button_to { display: inline-block; } - - .contact_visibility_padlock, - .modify_aspect, - .icons-mail, - .icons-monotone_close_exit_delete { - margin-left: 4px; - margin-bottom: -2px; - display: inline-block; - } - - .icons-mail { - width: 16px; - height: 13px; - margin-bottom: -1px; - } -} - -#aspect_nav { - list-style-type: none; - - .icons-check_yes_ok { - height:18px; - width:18px; - background: url('icons/check_yes_ok.png') no-repeat; - float: left; - visibility: hidden; - - &.selected { - visibility: visible; - } - - &.selected + a { - color: #333333; - } - } -} - -.contact_visibility_padlock { - height: 16px; - width: 16px; - /* -- To remove when the facebox will be deleted -- */ - display: inline-block; - margin-left: 4px; - margin-bottom: -2px; -} - -/* -- Used in aspects/edit.haml and in contacts/sharing.haml -- */ -#aspect_edit_controls { margin-top: 8px; } -#aspect_edit_pane { - width: 772px; - - .contact_list_controls { - height: 30px; - margin-bottom: 5px; - } - - #aspect_name_title { - margin: 0px 0px 5px 0px; - } - - #contact_list_search { - width: 200px; - margin-bottom: 2px; - margin-top: 0px; - float: right; - } - - .contact_list, - .aspect_list { - @include border-radius(3px); - height: 300px; - max-height: 300px; - overflow-y: auto; - overflow-x: hidden; - border: 1px solid #bbb; - background-color: rgb(252,252,252); - - .avatar { - float: left; - height: 50px; - width: 50px; - margin-right: 10px !important; - } - - .button.share { - padding-right: 20px; - .right { - right: 8px; - top: 3px; - } - } - - .icons-monotone_plus_add_round, - .icons-monotone_check_yes { - height: 20px; - width: 20px; - } - - & > .contacts { - margin: 0px; - padding: 5px; - padding-right: 0px; - - & > .contact { - @include border-radius(3px); - @include box-shadow(0, 1px, 5px, #ccc); - position: relative; - display: inline-block; - float: left; - height: 50px; - width: 170px; - overflow-x: hidden; - overflow-y: hidden; - margin-bottom: 5px; - margin-right: 5px; - padding: 5px; - background-color: #fff; - border: 1px solid $border-dark-grey; - - &.hidden { display: none; } - &.remote_friend { width: 285px; } - - & > .name { - font-size: 16px; - margin: 0px 0px 5px 0px; - white-space: nowrap; - } - - a.btn { - @include box-shadow(0,0,0); - border-bottom: none; - min-width: 90px; - float: right; - padding: 2px 0px; - margin-top: 5px; - margin-right: -5px; - - &.added { - @include linear-gradient(rgb(158,255,153), rgb(92,199,86)); - background-color: rgb(92,199,86); - } - - &.added.remove { - @include linear-gradient(rgb(255,153,153), rgb(199,86,86)); - - &:active { @include linear-gradient(rgb(199,119,119), rgb(130,55,55)); } - } - } - } - } - } - - .aspect_list { - height: 300px; - max-height: 300px; - - .name { left: 1em; } - - ul > li { - padding: 1em; - height: 1em; - - .right { - top: 2px; - right: 1em; - } - } - } - - .person_tiles .tile { - @include border-radius(2px); - padding: 6px; - padding-left: 65px; - margin: 3px; - margin-left: 0px; - display: inline-block; - width: 126px; - height: 50px; - border: 1px solid #eee; - position: relative; - - img { - position: absolute; - left: 6px; - } - } - - &.larger { width: 650px; } - - .bottom_submit_section { - margin-top: 12px; - - form { - display: inline-block; - margin: 0px; - } - - .creation { - float: right; - } - } -} - #new_aspect { #aspect_contacts_visible.checkbox { margin: 0px; diff --git a/app/assets/stylesheets/contacts.css.scss b/app/assets/stylesheets/contacts.css.scss index 1ccb84f4d..337660435 100644 --- a/app/assets/stylesheets/contacts.css.scss +++ b/app/assets/stylesheets/contacts.css.scss @@ -14,20 +14,20 @@ } .btn { margin-top: 10px; } } - a { + & > a, #aspect_controls > a { text-decoration: none; margin-right: 25px; } - .entypo { + .entypo.contacts-header-icon { font-size: 24.5px; line-height: 40px; color: lighten($black,75%); &:hover { color: $black; } } - .btn { margin-top: 8px; } + #suggest_member.btn { margin-top: 8px; } } - .contact_remove-from-aspect { + .contact_remove-from-aspect, .contact_add-to-aspect { text-decoration: none; .entypo { font-size: 20px; diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 4afce2b8d..18c354826 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -78,7 +78,7 @@ class AspectsController < ApplicationController @contacts_not_in_aspect = current_user.contacts.where(c[:id].not_in(@contacts_in_aspect.map(&:id))).includes(:aspect_memberships, :person => :profile).to_a.sort_by { |c| c.person.name } end - @contacts = @contacts_in_aspect + @contacts_not_in_aspect + @contacts = @contacts_not_in_aspect unless @aspect render :file => Rails.root.join('public', '404.html').to_s, :layout => false, :status => 404 diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index e8941e21c..ad8b76013 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -11,11 +11,11 @@ class ContactsController < ApplicationController def index respond_to do |format| - # Used for normal requests to contacts#index and subsequent infinite scroll calls + # Used for normal requests to contacts#index format.html { set_up_contacts } # Used by the mobile site - format.mobile { set_up_contacts } + format.mobile { set_up_contacts_mobile } # Used to populate mentions in the publisher format.json { @@ -26,11 +26,6 @@ class ContactsController < ApplicationController end end - def sharing - @contacts = current_user.contacts.sharing.includes(:aspect_memberships) - render :layout => false - end - def spotlight @spotlight = true @people = Person.community_spotlight @@ -39,6 +34,30 @@ class ContactsController < ApplicationController private def set_up_contacts + c = Contact.arel_table + @contacts = case params[:set] + when "only_sharing" + current_user.contacts.only_sharing.to_a.sort_by { |c| c.person.name } + when "all" + current_user.contacts.to_a.sort_by { |c| c.person.name } + else + if params[:a_id] + @aspect = current_user.aspects.find(params[:a_id]) + @contacts_in_aspect = @aspect.contacts.includes(:aspect_memberships, :person => :profile).to_a.sort_by { |c| c.person.name } + if @contacts_in_aspect.empty? + @contacts_not_in_aspect = current_user.contacts.includes(:aspect_memberships, :person => :profile).to_a.sort_by { |c| c.person.name } + else + @contacts_not_in_aspect = current_user.contacts.where(c[:id].not_in(@contacts_in_aspect.map(&:id))).includes(:aspect_memberships, :person => :profile).to_a.sort_by { |c| c.person.name } + end + @contacts_in_aspect + @contacts_not_in_aspect + else + current_user.contacts.receiving.to_a.sort_by { |c| c.person.name } + end + end + @contacts_size = @contacts.length + end + + def set_up_contacts_mobile @contacts = case params[:set] when "only_sharing" current_user.contacts.only_sharing diff --git a/app/helpers/contacts_helper.rb b/app/helpers/contacts_helper.rb index 7db5f2498..edd4bc56f 100644 --- a/app/helpers/contacts_helper.rb +++ b/app/helpers/contacts_helper.rb @@ -14,11 +14,24 @@ module ContactsHelper 'data-membership_id' => membership.id ) - else + elsif @aspect.nil? render :partial => 'people/relationship_action', :locals => { :person => contact.person, :contact => contact, :current_user => current_user } + else + link_to(content_tag(:i, nil, :class => 'entypo circled-plus'), + { :controller => "aspect_memberships", + :action => 'create', + :person_id => contact.person_id, + :aspect_id => @aspect.id + }, + :title => t('people.person.add_contact'), + :class => 'contact_add-to-aspect', + :method => 'create', + 'data-aspect_id' => @aspect.id, + 'data-person_id' => contact.person_id + ) end end @@ -28,7 +41,7 @@ module ContactsHelper conv_opts[:title] = t('.many_people_are_you_sure', suggested_limit: suggested_limit) if contacts_size > suggested_limit link_to new_conversation_path(aspect_id: aspect.id, name: aspect.name), conv_opts do - content_tag(:i, nil, :class => 'entypo mail', :title => t('contacts.index.start_a_conversation')) + content_tag(:i, nil, :class => 'entypo mail contacts-header-icon', :title => t('contacts.index.start_a_conversation')) end end end diff --git a/app/views/aspects/edit.html.haml b/app/views/aspects/edit.html.haml new file mode 100644 index 000000000..0ee1d00ba --- /dev/null +++ b/app/views/aspects/edit.html.haml @@ -0,0 +1,13 @@ +#people_stream.stream.contacts + - @contacts.each do |contact| + .media.stream_element{:id => contact.person_id} + .pull-right.contact_add-to-aspect + %i.entypo.circled-plus{:title => t('people.person.add_contact')} + .media-object.pull-left + = person_image_link(contact.person, :size => :thumb_small) + .media-body + = person_link(contact.person) + .info.diaspora_handle + = contact.person_diaspora_handle + .info.tags + = Diaspora::Taggable.format_tags(contact.person.profile.tag_string) diff --git a/app/views/contacts/_header.html.haml b/app/views/contacts/_header.html.haml index e930b4edb..5732ee081 100644 --- a/app/views/contacts/_header.html.haml +++ b/app/views/contacts/_header.html.haml @@ -1,20 +1,23 @@ .header - if @aspect - #aspect_control.pull-right + #aspect_controls.pull-right - if @contacts_size > 0 && @contacts_size < 20 = start_a_conversation_link(@aspect, @contacts_size) + = link_to aspect_toggle_contact_visibility_path(@aspect), id: "contacts_visibility_toggle", method: :put, remote: true do -if @aspect.contacts_visible? - %i.entypo.lock-open{:title => t('aspects.edit.aspect_list_is_visible')} + %i.entypo.lock-open.contacts-header-icon{:title => t('aspects.edit.aspect_list_is_visible')} -else - %i.entypo.lock{:title => t('aspects.edit.aspect_list_is_not_visible')} + %i.entypo.lock.contacts-header-icon{:title => t('aspects.edit.aspect_list_is_not_visible')} + = link_to @aspect, method: "delete", data: { confirm: t('aspects.edit.confirm_remove_aspect') }, class: 'delete' do - %i.entypo.trash{:title => t('delete')} + %i.entypo.trash.contacts-header-icon{:title => t('delete')} + %h3 %span#aspect_name = @aspect.name %span#change_aspect_name - %i.entypo.pencil{:title => t('aspects.edit.rename')} + %i.entypo.pencil.contacts-header-icon{:title => t('aspects.edit.rename')} #aspect_name_form = form_for @aspect, :remote => true do |aspect| = aspect.text_field :name, :maxlength => 20 diff --git a/app/views/contacts/index.html.haml b/app/views/contacts/index.html.haml index 53f7aaf2f..d833e9118 100644 --- a/app/views/contacts/index.html.haml +++ b/app/views/contacts/index.html.haml @@ -14,9 +14,8 @@ = render 'contacts/header' - if @contacts_size > 0 - = render @contacts - - = will_paginate @contacts + - @contacts.each do |contact| + = render 'contacts/contact', :contact => contact - else .no_contacts %h3 diff --git a/app/views/contacts/sharing.haml b/app/views/contacts/sharing.haml deleted file mode 100644 index b35f3fa1a..000000000 --- a/app/views/contacts/sharing.haml +++ /dev/null @@ -1,30 +0,0 @@ --# Copyright (c) 2010-2011, Diaspora Inc. This file is --# licensed under the Affero General Public License version 3 or later. See --# the COPYRIGHT file. - -#aspect_edit_pane - #facebox_header - .right - = t('contacts', :count =>@contacts.count) - - %h3#aspect_name_title - %span.name= t('.people_sharing') - - - if @contacts.count > 0 - .contact_list - = search_field_tag :contact_search, "", :id => 'contact_list_search', :class => 'contact_list_search', :results => 5, :placeholder => "People sharing with you" - %ul - - for contact in @contacts - %li{:data=>{:contact_id=>contact.id}} - = person_image_tag contact.person - %h4.name - = link_to contact.person_name, contact.person - .description - = contact.person_diaspora_handle - - .right - = aspect_membership_dropdown(contact, contact.person, 'right') - - %br - %div{:style => "text-align:right;"} - = link_to t('aspects.edit.done'), '#', :class => 'btn', :rel => 'close' diff --git a/app/views/contacts/spotlight.haml b/app/views/contacts/spotlight.haml index 6dc2fbbc3..0ad67fc04 100644 --- a/app/views/contacts/spotlight.haml +++ b/app/views/contacts/spotlight.haml @@ -15,7 +15,7 @@ .header - if AppConfig.settings.community_spotlight.suggest_email.present? .pull-right - = link_to t('contacts.spotlight.suggest_member'), "mailto:#{AppConfig.settings.community_spotlight.suggest_email}", :class => "btn btn-default" + = link_to t('contacts.spotlight.suggest_member'), "mailto:#{AppConfig.settings.community_spotlight.suggest_email}", :class => "btn btn-default", :id => "suggest_member" %h3 = t('contacts.spotlight.community_spotlight') diff --git a/config/routes.rb b/config/routes.rb index 6bc3b0265..558c8de7b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -146,7 +146,6 @@ Diaspora::Application.routes.draw do resources :contacts, :except => [:update, :create] do - get :sharing, :on => :collection end resources :aspect_memberships, :only => [:destroy, :create] resources :share_visibilities, :only => [:update]