fixed out of stock
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
<div class="col-md- panel">
|
||||
<div class="form-group p-l-15">
|
||||
<%= f.input :item_instance_code ,:input_html=>{:class=>""},:required=>true %>
|
||||
|
||||
|
||||
<% flash.each do |test, msg| %>
|
||||
<% str="[\"#{msg['item_instance_code']}\"]"
|
||||
str.gsub!('["', '')
|
||||
@@ -25,11 +25,14 @@
|
||||
<%= f.input :item_instance_name %>
|
||||
<%= f.input :price %>
|
||||
|
||||
<%= f.input :item_attributes, collection: @item.item_attributes, include_blank: false, include_hidden: false%>
|
||||
<% @item.item_attributes.each do |type, value| %>
|
||||
<%= f.input :attributes, :label => type, :collection => value.map {|v| [v['name'], v['id']]}, :include_blank => false, :input_html => {:class => "form-control item_sets #{type}"} %>
|
||||
<% end %>
|
||||
<%= f.input :item_attributes, :as => :hidden, :input_html => { :value => '', :id => "attr_type" } %>
|
||||
|
||||
<%= f.input :is_on_promotion %>
|
||||
<%= f.input :promotion_price %>
|
||||
|
||||
<%= f.input :promotion_price %>
|
||||
|
||||
<%= f.input :is_available %>
|
||||
<%= f.input :is_default %>
|
||||
|
||||
@@ -69,6 +72,39 @@
|
||||
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.menu_item_txt") %> <br>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
attr_type = <%= raw @item.item_attributes.to_json %>;
|
||||
attr_id = [];
|
||||
if (window.location.pathname.includes('edit')){
|
||||
item_attributes = <%= raw @menu_item_instance.item_attributes.to_json %>
|
||||
$.each(item_attributes, function (key, value){
|
||||
$.each(attr_type, function(k, v) {
|
||||
$('.' + k + ' > option').each(function(){
|
||||
if ($(this).val() == value ) {
|
||||
$(this).prop("selected",true)
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
};
|
||||
set_option(attr_type);
|
||||
$('.item_sets').change(function() {
|
||||
attr_id = [];
|
||||
set_option(attr_type);
|
||||
});
|
||||
|
||||
function set_option(attr_type){
|
||||
$.each(attr_type, function(k, v) {
|
||||
option = $('.' + k + ' option:selected').val();
|
||||
console.log(option);
|
||||
attr_id.push(option);
|
||||
});
|
||||
$('#attr_type').val(JSON.stringify(attr_id));
|
||||
};
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
// auto selected after loaded
|
||||
<%
|
||||
<%
|
||||
@settings_menu_item_instances.item_sets.each do |set|
|
||||
%>
|
||||
$("#menu_item_instance_item_sets option[value='" + <%= set.id %> + "']").attr("selected","selected").css({'color':'#fff','background':'#215d9c'});
|
||||
<%
|
||||
<%
|
||||
end
|
||||
%>
|
||||
|
||||
|
||||
@@ -1 +1,13 @@
|
||||
<%= render 'form', settings_simple_menu_item_menu_item_instances: @settings_menu_item_instances, item_sets: @item_sets %>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
attr_type = <%= raw @item.item_attributes.to_json %>;
|
||||
attr_id = [];
|
||||
$.each(attr_type, function(k, v) {
|
||||
option = $('.' + k + ' option:selected').val();
|
||||
attr_id.push(option);
|
||||
});
|
||||
$('#attr_type').val(JSON.stringify(attr_id));
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user