Skip to content

Commit

Permalink
merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolai-b committed May 3, 2015
2 parents 2d1788a + 41194d3 commit c1c4410
Show file tree
Hide file tree
Showing 89 changed files with 1,524 additions and 236 deletions.
1 change: 1 addition & 0 deletions .ruby-version
@@ -0,0 +1 @@
1.9.3-p551
6 changes: 2 additions & 4 deletions Gemfile
Expand Up @@ -36,6 +36,7 @@ gem 'whenever'
gem 'draper', '0.15.0' # pin due to failing tests: maybe when https://github.com/jcasimir/draper/pull/288 is released.
gem 'email_reply_parser'
gem 'memoist'
gem 'excon'
gem 'paranoia', '~> 1.0'

# Gems used only for assets and not required
Expand All @@ -61,11 +62,7 @@ group :development do
end

group :development, :test do
# IRB helpers
gem 'wirble'
gem 'hirb'
gem 'pry'

gem 'rspec-rails'
gem 'spring'
gem 'spring-commands-rspec'
Expand All @@ -81,4 +78,5 @@ group :test do
gem 'selenium-webdriver'
gem 'email_spec'
gem 'database_cleaner'
gem 'webmock'
end
13 changes: 9 additions & 4 deletions Gemfile.lock
Expand Up @@ -76,6 +76,8 @@ GEM
sass (~> 3.2.19)
compass-rails (2.0.0)
compass (>= 0.12.2)
crack (0.4.2)
safe_yaml (~> 1.0.0)
daemons (1.1.9)
database_cleaner (1.3.0)
declarative_authorization (0.5.7)
Expand Down Expand Up @@ -106,6 +108,7 @@ GEM
eventmachine (1.0.3)
exceptional (2.0.33)
rack
excon (0.44.4)
execjs (2.2.2)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
Expand All @@ -131,7 +134,6 @@ GEM
haml (>= 3.1, < 4.1)
railties (>= 3.1, < 4.1)
hike (1.2.3)
hirb (0.7.2)
i18n (0.7.0)
journey (1.0.4)
jquery-rails (2.0.3)
Expand Down Expand Up @@ -245,6 +247,7 @@ GEM
ruby_parser (3.6.3)
sexp_processor (~> 4.1)
rubyzip (1.1.6)
safe_yaml (1.0.4)
sass (3.2.19)
sass-rails (3.2.6)
railties (~> 3.2.0)
Expand Down Expand Up @@ -294,11 +297,13 @@ GEM
rack (>= 1.0.0)
warden (1.2.3)
rack (>= 1.0)
webmock (1.20.4)
addressable (>= 2.3.6)
crack (>= 0.3.2)
websocket (1.2.1)
whenever (0.9.4)
chronic (>= 0.6.3)
will_paginate (3.0.7)
wirble (0.1.3)
xpath (2.0.0)
nokogiri (~> 1.3)

Expand All @@ -322,12 +327,12 @@ DEPENDENCIES
email_reply_parser
email_spec
exceptional
excon
factory_girl_rails
foreman
formtastic (~> 2.2.1)
haml-lint
haml-rails
hirb
jquery-rails (= 2.0.3)
jquery-ui-rails (~> 4.2.0)
launchy
Expand Down Expand Up @@ -359,6 +364,6 @@ DEPENDENCIES
thumbs_up (~> 0.4.6)
tweet-button
uglifier (>= 1.0.3)
webmock
whenever
will_paginate (~> 3.0)
wirble
65 changes: 65 additions & 0 deletions app/assets/javascripts/street_view.js.coffee
@@ -0,0 +1,65 @@
$(document).ready ->
issue = new (google.maps.LatLng)(svLongNew, svLatNew)
svs = new google.maps.StreetViewService()
panorama = null

processSVData = (data, status) ->
if (status == google.maps.StreetViewStatus.OK)
panorama.setPano(data.location.pano)
panorama.setPov({
heading: 270,
pitch: 0
})
updateLocation()
updatePov()

panorama.setVisible(true)
else
pano = $("#newStreetViewPano").text('')
warningList = $('<ul>').addClass('bullets')
warningList.append $('<li>').text('Within 200m of the issue no Street View has been found')
pano.prepend warningList
pano.prepend $('<br>')
return

updateLocation = ->
$("#street_view_message_location_string").val panorama.getPosition()
return
updatePov = ->
$("#street_view_message_heading").val panorama.getPov().heading
$("#street_view_message_pitch").val panorama.getPov().pitch
return

addStreetView = (sv) ->
issue = new (google.maps.LatLng)(sv.long, sv.lat)

panoramaOptions = {
position: issue,
pov: {
heading: sv.head,
pitch: sv.pitch
},
visible: true
}
new google.maps.StreetViewPanorama(document.getElementById("streetViewPano#{sv.id}"), panoramaOptions)
return

initialize = ->
panorama = new google.maps.StreetViewPanorama(document.getElementById("newStreetViewPano"))

svs.getPanoramaByLocation(issue, 200, processSVData)

google.maps.event.addListener panorama, 'position_changed', ->
updateLocation()
google.maps.event.addListener panorama, 'pov_changed', ->
updatePov()

# http://stackoverflow.com/questions/14861975/resize-google-maps-when-tabs-are-triggered
$("a[href$='#new-street-view-message']").click( (e)->
google.maps.event.trigger(panorama, 'resize') )

addStreetView(streetView) for streetView in streetViews

return

google.maps.event.addDomListener window, 'load', initialize
5 changes: 3 additions & 2 deletions app/assets/javascripts/thread_scroller.js
@@ -1,7 +1,8 @@
$(document).ready(function() {
if(!window.location.hash) {
offset = $(".thread-view-from-here").offset()
if(!window.location.hash && offset) {
$('html, body').animate({
scrollTop: $(".thread-view-from-here").offset().top
scrollTop: offset.top
}, 2000);
}
});
3 changes: 0 additions & 3 deletions app/assets/javascripts/ui.js.coffee
Expand Up @@ -46,7 +46,6 @@ jQuery ->
# are linked via the auto-options and auto-options-param data
# attributes and update the target select box with the new options.
update_options: (source_select) ->
console.log "source_select", source_select
$("select[data-auto-options='##{source_select.attr("id")}']").each ->
target_select = $ this
param = target_select.data("auto-options-param")
Expand All @@ -57,7 +56,6 @@ jQuery ->
# are linked via the autoset and autoset-param data attributes
# and update them with the new value.
update_value: (source_select) ->
console.log "source_select", source_select
$("select[data-autoset='##{source_select.attr("id")}']").each ->
target_select = $ this
param = target_select.data("autoset-param")
Expand All @@ -67,7 +65,6 @@ jQuery ->
# When a select box is changed find any dependent elements and
# hide or show based on whether the new value is blank or not.
update_visibility: (source_select) ->
console.log "source_select", source_select
$("*[data-dependent='##{source_select.attr("id")}']").each ->
target = $ this
if source_select.val() != ""
Expand Down
26 changes: 24 additions & 2 deletions app/assets/stylesheets/content.css.scss
Expand Up @@ -437,7 +437,7 @@ section#user-locations {
border:1px solid $paneborder;
@include border-radius(10px);
.pane {

}
}
}
Expand Down Expand Up @@ -784,7 +784,7 @@ body.home {
color:$white;
font-size:12px;
}
}
}
}
}

Expand Down Expand Up @@ -851,3 +851,25 @@ body.home {
float: left;
}
}

.tag-item {
font-size: 11px;
line-height: 1;
padding: 5px 7px;
margin: 0px;
border-radius: 2px;
border: 1px solid #8C8C8C;
display: inline-block;
color: $grey;
line-height: 1;
font: {
size: 11px;
weight: normal;
}
background: $lightergrey;
}

.tag-item-m {
@extend .tag-item;
font-size: 14px;
}
5 changes: 5 additions & 0 deletions app/assets/stylesheets/maps.css.scss
Expand Up @@ -158,6 +158,11 @@
margin: 1em;
}

.streetViewPano {
width: auto;
height: 300px;
}

.olControlEditingToolbar .clearButtonItemInactive {
width: 24px;
height: 22px;
Expand Down
19 changes: 17 additions & 2 deletions app/assets/stylesheets/shared_elements.css.scss
Expand Up @@ -563,6 +563,21 @@ ul.group-list {
}
}

table.listing {
td {
padding-top: 15px;
padding-bottom: 20px;
}
.map {
width:270px;
padding-right:30px;
vertical-align:top;
.tinymap {
height: 180px;
}
}
}

.votes {
position: relative;
height: 130px;
Expand Down Expand Up @@ -755,8 +770,8 @@ section.new-message {
li {
float:left;
border-right:1px solid $paneborder;
padding-right:15px;
margin-right:15px;
padding-right:8px;
margin-right:8px;
&:last-child {
border-right:0;
padding-right:0;
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/users_controller.rb
Expand Up @@ -10,7 +10,7 @@ def edit
def update
@user = User.find(params[:id])

if @user.update_attributes(params[:user])
if @user.update_attributes(params[:user], as: current_user.role)
set_flash_message(:success)
redirect_to action: :index
else
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/dashboards_controller.rb
Expand Up @@ -16,6 +16,10 @@ def show

prioritised_threads = current_user.prioritised_threads.order('priority desc').order_by_latest_message.limit(20).includes(:issue, latest_message: [:component, :created_by])
@prioritised_threads = ThreadListDecorator.decorate(prioritised_threads)

planning_applications = current_user.planning_applications_near_locations.ordered
.not_hidden.paginate(page: params[:planning_page])
@planning_applications = PlanningApplicationDecorator.decorate(planning_applications)
end

def search
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/issues_controller.rb
Expand Up @@ -3,7 +3,10 @@ class IssuesController < ApplicationController

def index
issues = Issue.by_most_recent.paginate(page: params[:page]).includes(:created_by)
popular_issues = Issue.plusminus_tally(start_at: 8.weeks.ago, at_least: 1).includes(:created_by)

# work around till https://github.com/bouchard/thumbs_up/issues/64 is fixed
popular_issue_ids = Issue.plusminus_tally(start_at: 8.weeks.ago, at_least: 1).map &:id
popular_issues = Issue.where(id: popular_issue_ids).paginate(page: params[:pop_issues_page]).includes(:created_by)

@issues = IssueDecorator.decorate(issues)
@popular_issues = IssueDecorator.decorate(popular_issues)
Expand Down
34 changes: 31 additions & 3 deletions app/controllers/message/base_controller.rb
@@ -1,10 +1,38 @@
class Message::BaseController < ApplicationController
before_filter :load_thread
before_filter :thread
before_filter :build_message, only: :create

def create
if message.save
thread.add_subscriber(current_user) unless current_user.ever_subscribed_to_thread?(thread)
ThreadNotifier.notify_subscribers(thread, notification_name, message)
set_flash_message(:success)
else
set_flash_message(:failure)
end
redirect_to thread_path(@thread)
end

protected

def load_thread
def thread
# Need to check if user has access?
@thread = MessageThread.find(params[:thread_id])
@thread ||= MessageThread.find(params[:thread_id])
end

def message
@message ||= thread.messages.build
end

def build_message
message.created_by = current_user
message.component = populate_component
end

def populate_component
component.thread = thread
component.message = message
component.created_by = current_user
component
end
end
23 changes: 6 additions & 17 deletions app/controllers/message/deadlines_controller.rb
@@ -1,22 +1,11 @@
class Message::DeadlinesController < Message::BaseController
def create
@message = @thread.messages.build
@message.created_by = current_user
protected

@deadline = DeadlineMessage.new(params[:deadline_message])
@deadline.thread = @thread
@deadline.message = @message
@deadline.created_by = current_user

@message.component = @deadline
def component
@deadline ||= DeadlineMessage.new(params[:deadline_message])
end

if @message.save
@thread.add_subscriber(current_user) unless current_user.ever_subscribed_to_thread?(@thread)
ThreadNotifier.notify_subscribers(@thread, :new_deadline_message, @message)
set_flash_message(:success)
else
set_flash_message(:failure)
end
redirect_to thread_path(@thread)
def notification_name
:new_deadline_message
end
end

0 comments on commit c1c4410

Please sign in to comment.