Skip to content

Instantly share code, notes, and snippets.

@rafael-acerqueira
Created July 29, 2020 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafael-acerqueira/6984a16b6be26a14b330b2c131ea4f16 to your computer and use it in GitHub Desktop.
Save rafael-acerqueira/6984a16b6be26a14b330b2c131ea4f16 to your computer and use it in GitHub Desktop.
<%= simple_form_for @material, url: (@material.id ? material_path(@material) : materials_path) do |f| %>
<%= f.simple_fields_for :product do |p| %>
<div class='row-fluid'>
<%= p.input :only_movements_with_barcode, as: :boolean,
inline_label: true,
label: false,
wrapper_html: { class: 'span2' }
%>
<%= p.input :uniq_barcode_mode,
collection: ProductUniqBarcodeMode.to_a,
wrapper_html: {
class: 'span3'
},
input_html: {
class: 'span12'
}
%>
<%= p.input :name,
wrapper_html: {
class: 'span3'
},
input_html: {
class: 'span12 toUpperCase',
maxlength: 100,
rows: 2,
cols: 100
}
%>
<%= p.input :nickname,
wrapper_html: {
class: 'span2'
},
input_html: {
class: 'span12 toUpperCase',
maxlength: 256
}
%>
<%= p.input :code,
wrapper_html: {
class: 'span2'
},
input_html: {
class: 'span12 toUpperCase',
size: 5, maxlength: 5, autofocus: true
}
%>
</div>
<div class='row-fluid'>
<%= p.input :family,
required: true,
collection: Product::Family.select(:name, :id).to_a,
wrapper_html: {
class: 'span2'
},
input_html: {
class: 'span12'
}
%>
<%= f.input :description,
as: :text,
wrapper_html: {
class: 'span4'
},
input_html: {
class: 'span12 toUpperCase',
rows: 3
}
%>
<%= p.input :catmat_code,
wrapper_html: {
class: 'span2'
},
input_html: {
class: 'span12 toUpperCase',
maxlength: 20
}
%>
<%= p.input :sigaf_barcode,
wrapper_html: {
class: 'span2'
},
input_html: {
class: 'span12 toUpperCase'
}
%>
<%= p.input :integration_identifier,
wrapper_html: {
class: 'span2'
},
input_html: {
class: 'span12 toUpperCase',
maxlength: 256
}
%>
</div>
<div class='row-fluid'>
<%= f.input :material_type,
collection: MaterialType.to_a,
wrapper_html: {
class: 'span2'
},
input_html: {
class: 'span12'
}
%>
<div class='control-group span3'>
<%= p.label :presentation_unit %>
<%= p.input_field :presentation_unit,
class: 'autocomplete span12',
data: {
'js-identifier' => 'typeahead-autocomplete',
'autocomplete-url' => '/products/presentation_units/autocomplete',
'key' => 'name'
} %>
</div>
<div class='control-group span3'>
<%= p.label :unit %>
<%= p.input_field :unit,
class: 'autocomplete span12',
data: {
'js-identifier' => 'typeahead-autocomplete',
'autocomplete-url' => '/products/units/autocomplete',
'key' => 'name'
} %>
</div>
<%= p.input :quantity_unit,
as: :string,
required: true,
wrapper_html: {
class: 'span2'
},
input_html: {
class: 'span12',
value: p.object.quantity_unit.present? ? number_with_precision(p.object.quantity_unit, precision: 2) : ''
}
%>
<%= p.input :active, as: :boolean,
inline_label: true,
label: false,
wrapper_html: { class: 'span2' }
%>
<%= f.input :perishable, as: :boolean,
inline_label: true,
label: false,
wrapper_html: { class: 'span2' }
%>
</div>
<div class="form-actions">
<%= f.submit nil, class: 'btn btn-success', data: { disable_with: 'Salvando...' } %>
<%= link_to 'Voltar', materials_path, class: 'btn' %>
</div>
<% end %>
<script>
$("#material_product_attributes_quantity_unit")
.priceFormat({
prefix: "",
centsSeparator: ",",
thousandsSeparator: ".",
centsLimit: 2,
limit: 10
})
.live("blur", function () {
if (this.value === "0,00") { this.value = "" }
});
$(".toUpperCase").keyup(function(){
$(this).val($(this).val().toUpperCase())
})
</script>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment