Created
October 2, 2015 05:28
-
-
Save anchietajunior/328948b79b51ecd687d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= simple_form_for(@bill) do |f| %> | |
<%= f.error_notification %> | |
<div class="form-inputs"> | |
<div class="row"> | |
<div id="supplier_name"> | |
</div> | |
<div class="col-md-11"> | |
<%= f.association :supplier, label_method: :fancy_name %> | |
</div> | |
<div class="col-md-1"> | |
<a href="#" data-toggle='modal' data-target='#modal_add_supplier' class="btn btn-default"><i class="fa fa-plus"></i></a> | |
</div> | |
</div> | |
</div> | |
<div class="form-actions"> | |
<%= f.button :submit, class: 'btn btn-default btn btn-primary btn-lg' %> | |
<%= link_to t('view.action.back'), bills_path, class: 'btn btn-link btn-lg' %> | |
</div> | |
<% end %> | |
<!-- MODAL SUPPLIER --> | |
<div id="modal_add_supplier" class="modal fade" role="dialog"> | |
<div class="modal-dialog" style="width: 800px; height: 400px;"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<button type="button" class="close" data-dismiss="modal">×</button> | |
<h4 class="modal-title">Selecione os Centros de Custo</h4> | |
</div> | |
<div class="modal-body"> | |
<%= render 'suppliers/form', modal: true %> | |
</div> | |
<div class="modal-footer"> | |
</div> | |
</div> | |
</div> | |
</div> | |
<!-- MODAL SUPPLIER --> | |
<script> | |
$(document).ready(function(){ | |
$('[data-toggle="tooltip"]').tooltip(); | |
//$('#bill_amount').maskMoney(); | |
$("#bill_amount").maskMoney({ allowNegative: false, thousands:'.', decimal:',', affixesStay: false}); | |
// $('#currency2').maskMoney(); | |
//$("input[type=text].currency").setMask('decimal'); | |
$('#desconto').change(function(){ | |
$('.form-control.esconde').hide(); | |
$('.form-control.esconde').val(''); | |
$('#' + $(this).val()).show(); | |
}); | |
}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#supplier_name').append("<%= j render (@supplier) %>"); | |
$('#modal_add_supplier').modal_success(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@supplier = Supplier.new(supplier_params) | |
respond_to do |format| | |
if @supplier.save | |
format.html { redirect_to @supplier, notice: 'Fornecedor Cadastrado com sucesso' } | |
format.json { render action: 'show', status: :created, location: @supplier } | |
# added: | |
format.js { render 'bills/supplier', status: :created, location: @supplier } | |
else | |
format.html { render action: 'new' } | |
format.json { render json: @supplier.errors, status: :unprocessable_entity } | |
# added: | |
format.js { render json: @supplier.errors, status: :unprocessable_entity } | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% modal ||= false %> | |
<% remote = modal ? true : false %> | |
<%= simple_form_for(@supplier, remote: remote, html: {role: :form, 'data-model' => 'supplier'}) do |f| %> | |
<%= f.error_notification %> | |
<div class="form-inputs"> | |
<%= f.input :cnpj, autofocus: true %> | |
<span class="help-block"></span> | |
<%= f.input :fancy_name %> | |
<span class="help-block"></span> | |
<%= f.input :corporate_name %> | |
<span class="help-block"></span> | |
<%= f.input :state_registration %> | |
<%= f.input :main_supplier %> | |
<%= f.input :alternative_supplier %> | |
</div> | |
<div class="form-actions"> | |
<%= f.button :submit, class: 'btn btn-default btn btn-primary btn-lg' %> | |
<%= link_to t('view.action.back'), suppliers_path, class: 'btn btn-link btn-lg' %> | |
</div> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment