Commit 2b1eaf11 authored by Pedro Henrique's avatar Pedro Henrique

Fix forms that dont fill with address

Signed-off-by: Pedro Henrique's avatarPedro Henrique! <pha14@inf.ufpr.br>
parent 34e7408b
......@@ -15,8 +15,12 @@ carrega_cep = ->
$("input#city_hall_address_complement").removeAttr("disabled", "disabled")
if(dados["logradouro"] == "")
$("input#city_hall_address_street").removeAttr("disabled", "disabled")
else
$("input#city_hall_address_street").attr("disabled", true)
if(dados["bairro"] == "")
$("input#city_hall_neighborhood").removeAttr("disabled", "disabled")
else
$("input#city_hall_neighborhood").attr("disabled", true)
$("input#city_hall_address_street").attr("value", dados["logradouro"])
$("input#city_hall_neighborhood").attr("value", dados["bairro"])
$.getJSON(app_root_url + 'get_state/' + dados["uf"] )
......@@ -97,7 +101,7 @@ $(document).ready(->
code = null
code = if e.keyCode then e.keyCode else e.which
if (code == 13) then false else true
carrega_cep()
#carrega_cep()
$("input#city_hall_cep").change ->
carrega_cep()
......
......@@ -15,8 +15,12 @@ carrega_cep = ->
$("input#service_place_address_complement").removeAttr("disabled", "disabled")
if(dados["logradouro"] == "")
$("input#service_place_address_street").removeAttr("disabled", "disabled")
else
$("input#service_place_address_street").attr("disabled", true)
if(dados["bairro"] == "")
$("input#service_place_neighborhood").removeAttr("disabled", "disabled")
else
$("input#service_place_neighborhood").attr("disabled", true)
$("input#service_place_address_street").attr("value", dados["logradouro"])
$("input#service_place_neighborhood").attr("value", dados["bairro"])
city_hall_id = dados["prefeitura"]
......@@ -107,7 +111,7 @@ $(document).ready(->
code = null
code = if e.keyCode then e.keyCode else e.which
if (code == 13) then false else true
carrega_cep()
#carrega_cep()
$("input#service_place_cep").change ->
carrega_cep()
......
......@@ -48,7 +48,7 @@
<div class="field-required">
<%= label_tag :state_id, t(:state)+":" %><br />
<%= collection_select(:city, :state_id, State.all, :id, :name,
{ :include_blank => "Selecione um Estado" },
{ :selected => @city_hall.city.state.id },
{ :disabled => "disabled" }) %>
</div>
</div>
......@@ -58,21 +58,23 @@
<%= hidden_field_tag :cities_list, root_url %>
<%= f.label :city_id, t(:city)+"*: " %>
<p id="city_hall_city_id_loading" style="display: none;"><i>Carregando lista de municípios...</i></p>
<%= select(:city_hall, :city_id, %w[], { :include_blank => "Selecione um Município" }, { :disabled => "disabled" }) %>
<%= collection_select(:city_hall, :city_id, @city_hall.city.state.cities, :id, :name,
{ :selected => @city_hall.city.id },
{ :disabled => "disabled" }) %>
</div>
</div>
<div class="col s12 m6 l6">
<div class="field-required">
<%= f.label :neighborhood, t(:neighborhood)+"*: " %><br />
<%= f.text_field :neighborhood, :disabled => "disabled" %>
<%= f.text_field :neighborhood %>
</div>
</div>
<div class="col s12 m6 l6">
<div class="field-required">
<%= f.label :address_street, t(:address_street)+" da sede*: " %><br />
<%= f.text_field :address_street, :disabled => "disabled" %>
<%= f.text_field :address_street %>
</div>
</div>
......
......@@ -44,30 +44,31 @@
<div class="col s12 m6 l6">
<div class="field-required">
<%= f.label :neighborhood, t(:neighborhood)+"*: " %><br />
<%= f.text_field :neighborhood, { :disabled => "disabled", value: "Digite um CEP válido" }%>
<%= f.text_field :neighborhood %>
</div>
</div>
<div class="col s12 m6 l6">
<div class="field-required">
<%= label_tag :state_id, t(:state)+"*:" %><br />
<%= label_tag :state_id, t(:state)+":" %><br />
<%= collection_select(:city, :state_id, State.all, :id, :name,
{ :include_blank => "Digite um CEP válido" },
{ :selected => @service_place.city.state.id },
{ :disabled => "disabled" }) %>
</div>
</div>
<div class="col s12 m6 l6">
<div class="field-required">
<%= hidden_field_tag :cities_list, root_url %>
<%= f.label :city_id, t(:city)+"*: " %><br />
<%= f.label :city_id, t(:city)+"*: " %>
<p id="service_place_city_id_loading" style="display: none;"><i>Carregando lista de municípios...</i></p>
<%= collection_select(:service_place, :city_id, City.all, :id,
:name, { :include_blank => "Digite um CEP válido" },{:disabled => "disabled" }) %>
<%= collection_select(:service_place, :city_id, @service_place.city.state.cities, :id, :name,
{ :selected => @service_place.city.id },
{ :disabled => "disabled" }) %>
</div>
</div>
<div class="col s12 m6 l6">
<div class="field-required">
<%= f.label :address_street, t(:address_street)+"*: " %><br />
<%= f.text_field :address_street, { :disabled => "disabled", value: "Digite um CEP válido" }%>
<%= f.text_field :address_street %>
</div>
</div>
<div class="col s12 m6 l6">
......
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