From 3f08f99bf4fe66ce9b20776ccc3e510a944139bb Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Mon, 5 Aug 2019 11:23:25 +0630 Subject: [PATCH] option select addorder --- app/assets/javascripts/addorder.js | 41 ++++++++++++++++++++++++---- app/assets/stylesheets/addorder.scss | 6 ++++ 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 500fcacb..750ea7bb 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -329,16 +329,15 @@ $(function() { } }); } - for(var j in item_options) { value = item_options[j]["values"]; type = item_options[j]["type"]; row = "

"+type+"

" $(value).each(function(i){ - row +=""; }); - $(".options-list").append(row); + $(".options-list").append(row); } $('.set-item').attr('data-code',instances[0]['code']); $('.set-item').attr('data-name',instances[0]['name']); @@ -375,7 +374,7 @@ $(function() { type = item_options[field]["type"]; row = "

"+type+"

" $(value).each(function(i){ - row +=""; }); @@ -646,7 +645,7 @@ $(function() { type = item_options[field]["type"]; row = "

"+type+"

" $(value).each(function(i){ - row +=""; }); $(".options-list").append(row); @@ -710,6 +709,7 @@ $(function() { value = $(this).data('value'); type = $(this).data('type'); group = $(this).data('group'); + console.log(group); options = $(".option_btn"); $(options).each(function(i){ if ($(options[i]).attr('data-type')==type){ @@ -744,7 +744,38 @@ $(function() { } }); //End selecct attribute buttom + // click select option icon for add + $(document).on('click', '.check_option_btn', function(event){ + active =$(this).hasClass('selected-option'); + value = $(this).data('value'); + type = $(this).data('type'); + group = $(this).data('group'); + if (active) { + $(this).removeClass('selected-option'); + }else{ + $(this).addClass('selected-option'); + } + if(group == "set_menu"){ + option_arr = get_selected_attributes('selected-option'); + $(".selected-set:last").attr('data-options',JSON.stringify(option_arr)); + $(".selected-set:last").children().children('#instance_option').text(option_arr); + // instance = $(".selected-instance"); + // $(instance).each(function(i){ + // if ($(instance[i]).attr('data-code')==code){ + // option_arr = get_selected_attributes('selected-option'); + // $(instance[i]).attr('data-options',JSON.stringify(option_arr)); + // $(instance[i]).children().children('#instance_option').text(option_arr); + // } + // }); + } + if(group == "set_menu_default"){ + option_arr = get_selected_attributes('selected-option'); + $('.set-item').attr('data-options',JSON.stringify(option_arr)); + $('.set_default_option').text(option_arr); + } + + }); //End selecct attribute buttom // click add order $(document).on('click', '.add_to_order', function(event){ total_price = $('#total_price').text(); diff --git a/app/assets/stylesheets/addorder.scss b/app/assets/stylesheets/addorder.scss index 1cda9286..f23e98dc 100755 --- a/app/assets/stylesheets/addorder.scss +++ b/app/assets/stylesheets/addorder.scss @@ -334,3 +334,9 @@ i.logout_icon{ .custom-flex-footer{ display:flex; } +.check_option_btn { + white-space: normal !important; + margin-bottom: 5px; + margin-right: 5px; + color: #111 !important; +}