From c200c386fbf00564f04e07f150ff07829004e7b8 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Fri, 13 May 2011 11:58:18 -0700 Subject: [PATCH] pulled new aspect into modal window --- app/controllers/aspects_controller.rb | 5 +++-- app/views/aspects/{_new_aspect.haml => _new.haml} | 4 +++- app/views/aspects/create.js.erb | 2 ++ app/views/aspects/new.haml | 5 +++++ app/views/contacts/_aspect_dropdown.html.haml | 13 +------------ app/views/layouts/_header.html.haml | 2 +- config/locales/diaspora/en.yml | 2 +- features/connects_users.feature | 4 +++- 8 files changed, 19 insertions(+), 18 deletions(-) rename app/views/aspects/{_new_aspect.haml => _new.haml} (78%) create mode 100644 app/views/aspects/new.haml diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 78b70a22f..f1949bee3 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -7,9 +7,8 @@ class AspectsController < ApplicationController before_filter :save_sort_order, :only => :index before_filter :ensure_page, :only => :index - respond_to :html + respond_to :html, :js respond_to :json, :only => [:show, :create] - respond_to :js def index if params[:a_ids] @@ -84,6 +83,8 @@ class AspectsController < ApplicationController def new @aspect = Aspect.new + @person_id = params[:person_id] + render :layout => false end def destroy diff --git a/app/views/aspects/_new_aspect.haml b/app/views/aspects/_new.haml similarity index 78% rename from app/views/aspects/_new_aspect.haml rename to app/views/aspects/_new.haml index ff5c2978b..3812a4c27 100644 --- a/app/views/aspects/_new_aspect.haml +++ b/app/views/aspects/_new.haml @@ -7,8 +7,10 @@ %h4 = t('aspects.manage.add_a_new_aspect') - = form_for Aspect.new do |aspect| + = form_for(Aspect.new, :remote => (defined?(remote) && remote) ) do |aspect| = aspect.error_messages + - if defined?(person_id) + = aspect.hidden_field :person_id, :value => person_id %p = aspect.label :name , t('.name') = aspect.text_field :name, :maxlength => 20 diff --git a/app/views/aspects/create.js.erb b/app/views/aspects/create.js.erb index c6402dead..8f9d48e38 100644 --- a/app/views/aspects/create.js.erb +++ b/app/views/aspects/create.js.erb @@ -1,2 +1,4 @@ $('ul.dropdown_list[data-person_id=<%= @person.id %>] .newItem').before("<%= escape_javascript( render('contacts/aspect_dropdown_list_item', :aspect => @aspect, :person => @person, :contact => @contact)) %>"); +$.facebox.close(); +$('#profile .dropdown').toggleClass("active"); diff --git a/app/views/aspects/new.haml b/app/views/aspects/new.haml new file mode 100644 index 000000000..0747f9658 --- /dev/null +++ b/app/views/aspects/new.haml @@ -0,0 +1,5 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + += render 'new', :remote => true, :person_id => @person_id diff --git a/app/views/contacts/_aspect_dropdown.html.haml b/app/views/contacts/_aspect_dropdown.html.haml index bbb3ce58a..8c30d29f5 100644 --- a/app/views/contacts/_aspect_dropdown.html.haml +++ b/app/views/contacts/_aspect_dropdown.html.haml @@ -14,15 +14,4 @@ %li.newItem .add_aspect - = form_for(Aspect.new, :remote => true) do |aspect| - = aspect.error_messages - = aspect.hidden_field :person_id, :value => person.id if person - = aspect.hidden_field :share_with, :value => true - %p - = aspect.text_field :name, :style => "display:inline;" - %p.checkbox_select - = aspect.label :contacts_visible, t('aspects.edit.make_aspect_list_visible') - = aspect.check_box :contacts_visible, :checked => true, :default => true - .right - = aspect.submit t('contacts.share_with_pane.add_new_aspect'), :class => 'button' - + = link_to "Add a new aspect", new_aspect_path(:person_id => person.id), :rel => 'facebox' diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 2aa5a83f3..02150f905 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -58,4 +58,4 @@ .facebox_content #add_aspect_pane - = render "aspects/new_aspect" + = render "aspects/new" diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 12b058625..6330d35ad 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -111,7 +111,7 @@ en: no_requests: "No new requests" manage_aspects: "Manage aspects" drag_to_add: "Drag to add people" - new_aspect: + new: name: "Name" create: "Create" create: diff --git a/features/connects_users.feature b/features/connects_users.feature index 03b3cb251..7d12f75c7 100644 --- a/features/connects_users.feature +++ b/features/connects_users.feature @@ -70,7 +70,9 @@ Feature: sending and receiving requests When I sign in as "alice@alice.alice" And I am on "bob@bob.bob"'s page - And I press the first ".share_with.button" within "#author_info" + And I press the first ".toggle.button" + And I press the first "a" within ".add_aspect" + And I wait for the ajax to finish And I fill in "Name" with "Super People" in the modal window And I press "aspect_submit" in the modal window