Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/javascripts/forms.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $ ->

KS.content().on 'change', 'select[data-update]', ->
if (target = $("##{ $(@).data('update') }"))? && (url = target.data('src'))?
$.ajax(url: url, dataType: 'json', data: category: $(@).val()).done (response) ->
$.ajax(url: url, dataType: 'json', data: { category: $(@).val(), lat: $('#request_lat').val(), long: $('#request_long').val()}).done (response) ->
target.html('').append "<option disabled='disabled' selected='selected' class='placeholder'>#{
target.data('placeholder') }</option>"
$(response).each ->
Expand Down
9 changes: 1 addition & 8 deletions app/controllers/services_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ class ServicesController < ApplicationController
respond_to :json

def index
services = Service.collection.to_a.dup
if (type = params[:type]).present?
services.reject! { |s| s.type != type }
end
if (category = params[:category]).present?
services.reject! { |s| s.group != category }
end
respond_with services
respond_with Service.where(params.permit(:lat, :long).merge(group: params[:category], keywords: params[:type]))
rescue ActionController::UnknownFormat
head :not_acceptable
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/requests_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def categories(type, current = nil)
end

def services(category = nil, current = nil)
services = Service.collection.select { |s| s.group == category }.map { |s|
services = Service.collection.select { |s| s.group == category }.map { |s|
[s.service_name, s.service_code]
}.insert 0, [t('placeholder.select.service'), disabled: true, class: :placeholder]
options_for_select services, current
options_for_select services, current
end

def service
Expand Down