|
|
@@ -28,12 +28,32 @@
|
|
|
<div class="row">
|
|
|
|
|
|
<div class='col-md-12'>
|
|
|
+
|
|
|
+ <div class="form-group">
|
|
|
+ <%= label_tag 'destiny', {:class=>"col-md-2 control-label"} do %> ¿El producto tiene variantes?
|
|
|
+ <span class="required">*</span>
|
|
|
+ <% end %>
|
|
|
+ <div class="col-md-3" style="padding-left:0px;padding-right:0px">
|
|
|
+ <%= check_box_tag('product_has_variants', 'no', false,
|
|
|
+ {
|
|
|
+ class: "make-switch",
|
|
|
+ disabled: false,
|
|
|
+ data: {
|
|
|
+ on_color: "success",
|
|
|
+ off_color: "warning",
|
|
|
+ on_text: "SI",
|
|
|
+ off_text: "NO"
|
|
|
+ }
|
|
|
+ }) %>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
<div class="form-group">
|
|
|
<label class="col-md-2 control-label" for="typeahead"> Producto
|
|
|
<span class="required">*</span>
|
|
|
</label>
|
|
|
<div class="col-md-4" style="padding-left:0px">
|
|
|
- <input class="form-control" type="text" id="typeahead" data-option-url="/find_products_sp/%QUERY">
|
|
|
+ <input class="form-control" type="text" id="typeahead" data-option-url="/URL/%QUERY">
|
|
|
</div>
|
|
|
<button id="products_new" disabled class="btn btn-success" type="button" onclick="addRow()"> Agregar <i class="fa fa-plus"></i> </button>
|
|
|
</div>
|
|
|
@@ -92,15 +112,19 @@
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- // initialize bloodhound engine
|
|
|
var bloodhound = new Bloodhound({
|
|
|
datumTokenizer: function (d) {
|
|
|
return Bloodhound.tokenizers.whitespace(d.value);
|
|
|
},
|
|
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
|
|
remote: {
|
|
|
- url: $('#typeahead').data('option-url'),
|
|
|
- wildcard: '%QUERY'
|
|
|
+ url: "/URL/" + "%QUERY",
|
|
|
+ wildcard: '%QUERY',
|
|
|
+ replace: function(url, uriEncodedQuery) {
|
|
|
+ has_variants = $('#product_has_variants').bootstrapSwitch('state');
|
|
|
+ type = has_variants ? 'find_products_sp' : 'find_products'
|
|
|
+ return url.replace('URL', type).replace('%QUERY', uriEncodedQuery)
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
bloodhound.initialize();
|