Skip to content

Commit

Permalink
Fixes location list duplication in iPhone
Browse files Browse the repository at this point in the history
  • Loading branch information
sukima committed Jan 13, 2011
1 parent 8f791b8 commit 8956e8e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/controllers/asset_check_ins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def new
@asset_check_in = @equipment_asset.asset_check_ins.new(params[:asset_check_in])
@asset_check_in.equipment_asset_oos = @equipment_asset.oos
@asset_check_in.person ||= cookies[:asset_check_in_person]
@asset_check_in.location ||= @equipment_asset.location if !@equipment_asset.asset_check_ins.empty?
@asset_check_in.location ||= cookies[:asset_check_in_location]

respond_to do |wants|
Expand All @@ -41,15 +42,17 @@ def new
def loclist
@asset_check_in = @equipment_asset.asset_check_ins.new(params[:asset_check_in])
@query = params[:query]
if @query && !@query.empty?
@locations = AssetCheckIn.find(:all, :conditions => ["location LIKE ?", "%#{@query}%" ] ).map(&:location)
if @query.blank?
@locations = AssetCheckIn.find(:all, :group => 'location').map(&:location)
else
@locations = AssetCheckIn.find(:all).map(&:location)
@locations = AssetCheckIn.find(:all, :group => 'location', :conditions => ["location LIKE ?", "%#{@query}%"] ).map(&:location)
@asset_check_in.location ||= @query
end

respond_to do |wants|
# Only iPhone uses this action
wants.html do
@locations.unshift(@query) if @query && !@query.empty?
@locations.unshift(@query) if !@query.blank? && !@locations.include?(@query)
render 'loclist_iphone', :layout => false
end
wants.js do
Expand Down

0 comments on commit 8956e8e

Please sign in to comment.