Commit 3191b86f authored by Mateus Ravedutti's avatar Mateus Ravedutti

Update schedules search form

parent ee5b9a28
......@@ -20,10 +20,90 @@ get_date_object = (string, separator) ->
date_object
update_city_hall_child_selects = (city_hall_id) ->
if city_hall_id || city_hall_id != ""
app_root_url = $("input#app_root_url").val()
$.getJSON(app_root_url + 'city_halls/' + city_hall_id + '/professionals.json')
.done((dados) ->
if dados.length > 0
select = []
select.push('<option value=\"\">Todos </option>')
$.each(dados, (i, professional) ->
select.push('<option value="' + professional['id'] + '">' + professional['name'] + '</option>')
)
$('select#q_shift_professional_performer_id_eq').html(select)
else
$('select#q_shift_professional_performer_id_eq').html('<option value="">Todos </option>')
)
update_professional_child_selects = (professional_id) ->
if professional_id or professional_id != ""
app_root_url = $("input#app_root_url").val()
$.getJSON(app_root_url + 'professionals/' + professional_id + '/service_places.json')
.done((dados) ->
if dados.length > 0
select = []
select.push('<option value=\"\">Todos </option>')
$.each(dados, (i, service_place) ->
select.push('<option value="' + service_place[0] + '">' + service_place[1] + '</option>')
)
$('select#q_service_place_id_eq').html(select)
else
$('select#q_service_place_id_eq').html('<option value="">Todos </option>')
)
update_service_place_child_selects = (service_place_id) ->
if service_place_id or service_place_id != ""
app_root_url = $("input#app_root_url").val()
$.getJSON(app_root_url + 'service_places/' + service_type_id + '/service_types.json')
.done((dados) ->
if dados.length > 0
select = []
select.push('<option value=\"\">Todos </option>')
$.each(dados, (i, service_type) ->
select.push('<option value="' + service_type['id'] + '">' + service_type['description'] + '</option>')
)
$('select#q_shift_service_type_id_eq').html(select)
else
$('select#q_shift_service_type_id_eq').html('<option value="">Todos </option>')
)
desabilita_selects_from_city_hall = () ->
$('select#q_service_place_id_eq').html('<option value="">Todos </option>')
$('select#q_shift_service_type_id_eq').html('<option value="">Todos </option>')
$('select#q_shift_professional_performer_id_eq').html('<option value="">Todos </option>')
desabilita_select_service_place = () ->
$('select#q_service_place_id_eq').html('<option value="">Todos </option>')
desabilita_select_service_type = () ->
$('select#q_shift_service_type_id_eq').html('<option value="">Todos </option>')
$(document).ready(->
# Parâmetros da URL
params = get_url_params()
$('select#q_service_place_city_hall_id_eq').on('change', () ->
city_hall_id = $("select#q_service_place_city_hall_id_eq").val()
update_city_hall_child_selects(city_hall_id)
desabilita_selects_from_city_hall()
)
$('select#q_shift_professional_performer_id_eq').on('change', () ->
professional_id = $("select#q_shift_professional_performer_id_eq").val()
update_professional_child_selects(professional_id)
desabilita_select_service_place()
desabilita_select_service_type()
)
$('select#q_service_place_id_eq').on('change', () ->
service_place_id = $("select#q_service_place_id_eq").val()
update_service_place_child_selects(service_place_id)
desabilita_select_service_type()
)
$('#reset_btn').click ->
$('.search-field').val('')
$('.ordenacao').val('Decrescente')
......
......@@ -31,32 +31,45 @@
{ :value => @limite_fim.strftime("%d/%m/%Y"), :class => "date agendamentos_atend_calendario", :readonly => "true" } %>
<% end %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :service_place_city_hall_id, t(:city_hall) %><br />
<% if @currentProfessionalServicePlace.role == "adm_c3sl" %>
<%= f.collection_select :service_place_city_hall_id_eq, CityHall.active.order(:name),
:id, :name, { :include_blank => "Todos" }, { :class => "search-field" } %>
<% else %>
<%= f.collection_select :service_place_city_hall_id_eq, CityHall.where(id: @currentCityHall.id),
:id, :name, { disabled: true }, { :class => "search-field" } %>
<% end %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :shift_professional_performer_id, t(:Professional)+": " %><br />
<%= f.collection_select :shift_professional_performer_id_eq, @professionals,
<%= f.collection_select :shift_professional_performer_id_eq, [],
:id, :name, {:include_blank => "Todos"}, {:class => "search-field"} %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :service_place_id_eq, t(:service_place) %><br />
<%= f.collection_select :service_place_id_eq, [], :id,
:name,{ :include_blank => "Todos" },
{ :class => "search-field" } %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :escala_tipo_atendimento_id, t(:service_type)+": " %><br />
<%= f.collection_select :shift_service_type_id_eq, @city_service_types,
<%= f.collection_select :shift_service_type_id_eq, [],
:id, :description, {:include_blank => "Todos"}, {:class => "search-field"} %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :situation_id, t(:Situation)+": " %><br />
<%= f.collection_select :situation_id_eq, @situations, :id,
:description, {:include_blank => "Todos"},
{:class => "search-field"} %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :service_place_id_eq, t(:service_place) %><br />
<%= f.collection_select :service_place_id_eq, @city_service_places, :id,
:name,{ :include_blank => "Todos" },
{ :class => "search-field" } %>
</div>
</div>
<div class="actions">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment