From 5358ac32a1fcf9006620a261eb1df4912ac71c8c Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 5 Jan 2011 15:16:28 -0800 Subject: [PATCH] photos can be posted to multiple aspects. header nav works from pages other than aspect/index. --- app/controllers/people_controller.rb | 2 +- app/controllers/photos_controller.rb | 2 ++ app/helpers/aspects_helper.rb | 4 ++-- app/views/aspects/_all_aspects_contacts.haml | 4 ++-- app/views/aspects/_aspect.haml | 2 +- app/views/aspects/index.html.haml | 2 +- app/views/layouts/_header.html.haml | 4 ++-- app/views/photos/_new_photo.haml | 5 ++++- app/views/shared/_publisher.haml | 2 +- 9 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 2c204c0af..366fb52ba 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -122,7 +122,7 @@ class PeopleController < ApplicationController @aspects_with_person = @contact.aspects end - @aspects_without_person = @aspects.reject do |aspect| + @aspects_without_person = @all_aspects.reject do |aspect| @aspects_with_person.include?(aspect) end diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index b8d316f83..dd68fd58b 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -42,6 +42,8 @@ class PhotosController < ApplicationController if params[:photo][:aspect_ids] == "all" params[:photo][:aspect_ids] = current_user.aspects.collect{|x| x.id} + elsif params[:photo][:aspect_ids].is_a?(Hash) + params[:photo][:aspect_ids] = params[:photo][:aspect_ids].values end params[:photo][:user_file] = file_handler(params) diff --git a/app/helpers/aspects_helper.rb b/app/helpers/aspects_helper.rb index e173bc75f..7accf39de 100644 --- a/app/helpers/aspects_helper.rb +++ b/app/helpers/aspects_helper.rb @@ -3,8 +3,8 @@ # the COPYRIGHT file. module AspectsHelper - def link_for_aspect( aspect ) - link_to aspect.name, aspect + def link_for_aspect(aspect, opts={}) + link_to aspect.name, aspects_path("a_ids[]" => aspect.id), opts end def remove_link( aspect ) diff --git a/app/views/aspects/_all_aspects_contacts.haml b/app/views/aspects/_all_aspects_contacts.haml index 22fe355b1..7f62eeb6c 100644 --- a/app/views/aspects/_all_aspects_contacts.haml +++ b/app/views/aspects/_all_aspects_contacts.haml @@ -10,9 +10,9 @@ #left_pane .section.aspect_listings %h4 - = t('.aspects') - .right{:style=>"font-size:12px;top:5px;"} + .right{:style=>"font-size:12px;"} = link_to t('.manage_aspects'), aspects_manage_path + = t('.aspects') %ul - for a_hash in @aspect_hashes diff --git a/app/views/aspects/_aspect.haml b/app/views/aspects/_aspect.haml index fb319c2d7..cc2d0c907 100644 --- a/app/views/aspects/_aspect.haml +++ b/app/views/aspects/_aspect.haml @@ -1,4 +1,4 @@ %li %b - = link_to aspect, aspect + = link_for_aspect(aspect) = t('contacts', :count => contact_count) diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index 24f7bb16c..5e29276a1 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -6,7 +6,7 @@ - content_for :head do = include_javascripts :home -.span-24.last +.span-22.last %h3{:style => "position:relative;"} = current_user.name .right{:style=>"top:0"} diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 010416522..e281f6dcc 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -41,12 +41,12 @@ -unless @landing_page %ul#aspect_nav - %li{:class => ("selected" if @aspect == :all)} + %li{:class => ('selected' if @aspect == :all)} = link_to t('_home'), root_path, :class => 'home_selector' - for aspect in @all_aspects %li{:data=>{:guid=>aspect.id}, :class => ("selected" if current_aspect?(aspect))} - = link_to aspect.name, '#', :class => 'aspect_selector' + = link_for_aspect(aspect, :class => 'aspect_selector') = link_to '▼', edit_aspect_path(aspect), :class => 'aspect_selector_edit' %li diff --git a/app/views/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index cbac6e953..bea3af33a 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -4,9 +4,12 @@ :javascript function createUploader(){ + + var aspectIds = "#{aspect_ids}".split(','); + var uploader = new qq.FileUploaderBasic({ element: document.getElementById('file-upload'), - params: {'photo' : {'pending' : 'true', 'aspect_ids' : "#{aspect_ids}"}, 'set_profile_image' : "#{set_profile_image if defined?(set_profile_image)}"}, + params: {'photo' : {'pending' : 'true', 'aspect_ids' : aspectIds}, 'set_profile_image' : "#{set_profile_image if defined?(set_profile_image)}"}, allowedExtensions: ['jpg', 'jpeg', 'png'], action: "#{photos_path}", debug: true, diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index c4951732d..2de6b9879 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -53,5 +53,5 @@ = render 'shared/public_explain' #publisher_photo_upload - = render 'photos/new_photo', :aspect_ids => @aspect_ids + = render 'photos/new_photo', :aspect_ids => @aspect_ids.join(',')