aspect dropdown takes public and all aspects option
This commit is contained in:
parent
beb5380ada
commit
2b2443b6b9
7 changed files with 75 additions and 37 deletions
|
|
@ -9,7 +9,7 @@ class StatusMessagesController < ApplicationController
|
|||
respond_to :mobile
|
||||
|
||||
# Called when a user clicks "Mention" on a profile page
|
||||
# @option [Integer] person_id The id of the person to be mentioned
|
||||
# @param person_id [Integer] The id of the person to be mentioned
|
||||
def new
|
||||
if params[:person_id] && @person = Person.where(params[:person_id]).first
|
||||
@aspect = :profile
|
||||
|
|
@ -19,7 +19,6 @@ class StatusMessagesController < ApplicationController
|
|||
@aspects_with_person = @contact.aspects
|
||||
@aspect_ids = @aspects_with_person.map(&:id)
|
||||
@contacts_of_contact = @contact.contacts
|
||||
|
||||
render :layout => nil
|
||||
end
|
||||
else
|
||||
|
|
@ -33,6 +32,9 @@ class StatusMessagesController < ApplicationController
|
|||
@aspects = current_user.aspects
|
||||
@selected_contacts = @aspects.map { |aspect| aspect.contacts }.flatten.uniq
|
||||
@aspect_ids = @aspects.map{|x| x.id}
|
||||
|
||||
pp @aspect_ids.inspect
|
||||
|
||||
render :layout => nil
|
||||
end
|
||||
|
||||
|
|
@ -51,7 +53,14 @@ class StatusMessagesController < ApplicationController
|
|||
if @status_message.save
|
||||
Rails.logger.info("event=create type=status_message chars=#{params[:status_message][:text].length}")
|
||||
|
||||
aspects = current_user.aspects_from_ids(params[:aspect_ids])
|
||||
# always send to all aspects if public
|
||||
if params[:status_message][:public] || params[:status_message][:aspect_ids].first == "all_aspects"
|
||||
aspect_ids = current_user.aspects.map{|a| a.id}
|
||||
else
|
||||
aspect_ids = params[:aspect_ids]
|
||||
end
|
||||
|
||||
aspects = current_user.aspects_from_ids(aspect_ids)
|
||||
current_user.add_to_streams(@status_message, aspects)
|
||||
receiving_services = current_user.services.where(:type => params[:services].map{|s| "Services::"+s.titleize}) if params[:services]
|
||||
current_user.dispatch_post(@status_message, :url => short_post_url(@status_message.guid), :services => receiving_services)
|
||||
|
|
@ -81,7 +90,8 @@ class StatusMessagesController < ApplicationController
|
|||
end
|
||||
|
||||
def normalize_public_flag!
|
||||
public_flag = params[:status_message][:public]
|
||||
# mobile || desktop conditions
|
||||
public_flag = params[:status_message][:aspect_ids].first == 'public' || params[:status_message][:public]
|
||||
public_flag.to_s.match(/(true)|(on)/) ? public_flag = true : public_flag = false
|
||||
params[:status_message][:public] = public_flag
|
||||
public_flag
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
/ Stylesheets
|
||||
= include_stylesheets :mobile
|
||||
= yield(:custom_css)
|
||||
|
||||
%script{:src => "/javascripts/vendor/mbp-modernizr-custom.js"}
|
||||
/ Media Queries Polyfill https://github.com/shichuan/mobile-html5-boilerplate/wiki/Media-Queries-Polyfill
|
||||
|
|
|
|||
|
|
@ -2,26 +2,38 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
- content_for :custom_css do
|
||||
:css
|
||||
body {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
|
||||
= form_for StatusMessage.new, {:data => {:ajax => false}} do |status|
|
||||
#message_container
|
||||
= status.text_area :text, :placeholder => t('.whats_on_your_mind'), :style => "width:300px", :rows => 4, :autofocus => "autofocus"
|
||||
|
||||
- for aspect_id in aspect_ids
|
||||
= hidden_field_tag 'aspect_ids[]', aspect_id.to_s
|
||||
|
||||
%fieldset
|
||||
%div{:style => 'float:right;'}
|
||||
= select_tag 'aspect_ids[]', options_from_collection_for_select(current_user.aspects, "id", "name")
|
||||
/%input{:type => 'checkbox', :name => 'status_message[public]', :id => 'public', :class => 'custom', :value => 'true'}
|
||||
/%label{:for => 'public'}
|
||||
/ = t('.make_public')
|
||||
- unless current_user.services.empty?
|
||||
%div{:data => {:role => 'fieldcontain'}}
|
||||
%label{:for => 'services', :class => 'select'}
|
||||
- current_user.services.each do |service|
|
||||
%input{:type => 'checkbox', :name => "services[]", :id => "#{service.provider}", :class => 'custom', :value => "#{service.provider}"}
|
||||
%label{:for => "#{service.provider}"}
|
||||
= "#{service.provider}"
|
||||
|
||||
= status.submit t('.share'), :class => 'action'
|
||||
|
||||
%select{:id => "aspect_ids_", :name => "aspect_ids[]"}
|
||||
%option{:value => 'public'}
|
||||
= t('public')
|
||||
|
||||
%option{:value => 'all_aspects', :selected => true}
|
||||
= t('all_aspects')
|
||||
|
||||
- current_user.aspects.each do |aspect|
|
||||
%option{:value => aspect.id}
|
||||
= "· #{aspect.name}"
|
||||
|
||||
/- unless current_user.services.empty?
|
||||
/ %div{:data => {:role => 'fieldcontain'}}
|
||||
/ %label{:for => 'services', :class => 'select'}
|
||||
/ - current_user.services.each do |service|
|
||||
/ %input{:type => 'checkbox', :name => "services[]", :id => "#{service.provider}", :class => 'custom', :value => "#{service.provider}"}
|
||||
/ %label{:for => "#{service.provider}"}
|
||||
/ = "#{service.provider}"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,13 @@
|
|||
.stream_element{:data=>{:guid=>post.id}}
|
||||
|
||||
.photo_area
|
||||
- if post.is_a?(StatusMessage) && post.photos.size > 0
|
||||
- photos = post.photos
|
||||
- if post.is_a?(StatusMessage)
|
||||
-if post.photos.size > 0
|
||||
.photo_attachments
|
||||
= image_tag photos.first.url(:thumb_large), :class => "stream-photo big-stream-photo", 'data-small-photo' => photos.first.url(:thumb_medium), 'data-full-photo' => photos.first.url
|
||||
- if post.photos.size > 1
|
||||
.additional_photo_count
|
||||
= "+ #{post.photos.size-1}"
|
||||
= image_tag post.photos.first.url(:thumb_large), :class => "stream-photo big-stream-photo"
|
||||
- elsif post.activity_streams?
|
||||
= image_tag post.image_url
|
||||
|
||||
|
|
@ -19,6 +22,13 @@
|
|||
.info
|
||||
%span.time{:integer => post.created_at.to_i}
|
||||
= t('ago', :time => time_ago_in_words(post.created_at))
|
||||
–
|
||||
%span.scope_scope
|
||||
- if post.public?
|
||||
= t('public')
|
||||
- else
|
||||
= t('limited')
|
||||
|
||||
%span.via
|
||||
- if post.activity_streams?
|
||||
= t('.via', :link => link_to("#{post.provider_display_name}", post.actor_url)).html_safe
|
||||
|
|
|
|||
|
|
@ -2,6 +2,17 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
- if defined?(reshare) && reshare
|
||||
.photo_area
|
||||
- if post.is_a?(StatusMessage)
|
||||
-if post.photos.size > 0
|
||||
.photo_attachments
|
||||
- if post.photos.size > 1
|
||||
.additional_photo_count
|
||||
= "+ #{post.photos.size-1}"
|
||||
= image_tag post.photos.first.url(:thumb_large), :class => "stream-photo big-stream-photo"
|
||||
- elsif post.activity_streams?
|
||||
= image_tag post.image_url
|
||||
|
||||
%div{:class => direction_for(post.text)}
|
||||
!= markdownify(post, :youtube_maps => post[:youtube_titles])
|
||||
|
|
|
|||
|
|
@ -154,18 +154,6 @@ describe AspectsController do
|
|||
end
|
||||
end
|
||||
|
||||
context "mobile" do
|
||||
it "renders a share button when you don't pass aspect IDs" do
|
||||
get :index, :format => :mobile
|
||||
response.body.should =~ /#{Regexp.escape('id="status_message_submit"')}/
|
||||
end
|
||||
|
||||
it "renders a share button when you pass aspect IDs" do
|
||||
get :index, :a_ids => [@alices_aspect_1], :format => :mobile
|
||||
response.body.should =~ /#{Regexp.escape('id="status_message_submit"')}/
|
||||
end
|
||||
end
|
||||
|
||||
describe 'performance', :performance => true do
|
||||
before do
|
||||
require 'benchmark'
|
||||
|
|
@ -357,7 +345,6 @@ describe AspectsController do
|
|||
it 'should not 500' do
|
||||
get :index, :format => :mobile
|
||||
response.should be_success
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ describe StatusMessagesController do
|
|||
post :create, status_message_hash.merge(:format => 'js')
|
||||
json = JSON.parse(response.body)
|
||||
save_fixture(json['html'], "created_status_message")
|
||||
|
||||
end
|
||||
|
||||
it 'escapes XSS' do
|
||||
|
|
@ -76,6 +75,14 @@ describe StatusMessagesController do
|
|||
end
|
||||
end
|
||||
|
||||
it 'takes public in aspect ids' do
|
||||
post :create, status_message_hash.merge(:aspect_ids => ['public'])
|
||||
end
|
||||
|
||||
it 'takes all_aspects in aspect ids' do
|
||||
post :create, status_message_hash.merge(:aspect_ids => ['all_aspects'])
|
||||
end
|
||||
|
||||
it "dispatches the post to the specified services" do
|
||||
s1 = Services::Facebook.new
|
||||
alice.services << s1
|
||||
|
|
|
|||
Loading…
Reference in a new issue