Commit b004ffbd authored by mateus ravedutti's avatar mateus ravedutti
Browse files

Update selects from shifts index

parent 02293fd6
......@@ -420,6 +420,46 @@ cria_select_json = (app_root_url, orgao_id, orgao_url, html_id, option_valor, co
conta_caracteres("#observacao_agendamento", 140, "#observacao_restante");
# Atualiza os campos select dos locais de atendimento dependentes do tipo de atendimento
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_place_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_professional_performer_id_eq').html(select)
else
$('select#q_professional_performer_id_eq').html('<option value="">Todos </option>')
)
# Atualiza os campos select dos locais de atendimento dependentes do tipo de atendimento
update_service_type_child_selects = (service_type_id) ->
if service_type_id or service_type_id != ""
app_root_url = $("input#app_root_url").val()
$.getJSON(app_root_url + 'service_types/' + service_type_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>')
)
desabilita_select_professional = () ->
$('select#q_professional_performer_id_eq').html('<option value="">Todos </option>')
desabilita_select_service_place = () ->
$('select#q_service_place_id_eq').html('<option value="">Todos </option>')
$(document).ready ->
# Desabilita a confirmação para verificar se o usuário deseja
# realmente sair da página (evento window.beforeunload)
......@@ -431,6 +471,18 @@ $(document).ready ->
# para o caso de editar uma shift
shift_id = document.URL.split('/')[4]
$('select#q_service_type_id_eq').on('change', () ->
service_type_id = $("select#q_service_type_id_eq").val()
update_service_type_child_selects(service_type_id)
desabilita_select_service_place()
)
$('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_professional()
)
# Obtêm o órgão selecionado
if $('#shift_service_place_id').prop('tagName') == "SELECT"
orgao_id = $('select#shift_service_place_id').val()
......
......@@ -10,26 +10,19 @@
:id, :description, { :include_blank => "Todos" }, { :class => "search-field" } %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :professional_performer_id, t(:Professional) %><br />
<% if @selected_professional %>
<%= f.collection_select :professional_performer_id_eq, @service_places_professionals, :first, :second, { include_blank: "Todos", selected: @selected_professional }, { :class => "search-field" }%>
<% else %>
<%= f.collection_select :professional_performer_id_eq, @service_places_professionals,
:first, :second, { include_blank: "Todos" }, { :class => "search-field" }%>
<% end %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :service_place_id, t(:service_place) %><br />
<% if @currentProfessionalServicePlace.role == "adm_c3sl" %>
<%= f.collection_select :service_place_id_eq, @professional_places, :id, :name_with_city_hall,
{ include_blank: "Todos" }, { :class => "search-field" } %>
<% else %>
<%= f.collection_select :service_place_id_eq, @professional_places, :id, :name,
{ include_blank: "Todos" }, { :class => "search-field" } %>
<% end %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :service_place_id, t(:service_place)+": " %><br />
<%= f.select :service_place_id_eq,
options_from_collection_for_select([],"id","description", @search.service_place_id_eq),
{:include_blank => "Todos"}, {:class => "search-field"} %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :professional_performer_id, t(:Professional)+": " %><br />
<%= f.select :professional_performer_id_eq,
options_from_collection_for_select([],"id","name", @search.service_place_id_eq),
{:include_blank => "Todos"}, {:class => "search-field"} %>
</div>
<div class="field-h col s12 m6 l3">
<%= f.label :execution_start_time, "A partir de: " %><br />
......
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