fixed menu load
This commit is contained in:
@@ -204,7 +204,7 @@ class HomeController < ApplicationController
|
|||||||
shift = ShiftSale.current_open_shift(employee)
|
shift = ShiftSale.current_open_shift(employee)
|
||||||
if food_court
|
if food_court
|
||||||
if !shift.nil?
|
if !shift.nil?
|
||||||
redirect_to foodcourt_food_court_path
|
redirect_to foodcourt_food_court_path(:anchor => "")
|
||||||
else
|
else
|
||||||
redirect_to new_foodcourt_shift_path
|
redirect_to new_foodcourt_shift_path
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -408,58 +408,16 @@
|
|||||||
<script>
|
<script>
|
||||||
var cashier_type = $('#cashier_type').val();
|
var cashier_type = $('#cashier_type').val();
|
||||||
//get menu item cache
|
//get menu item cache
|
||||||
function getAllMenu(){
|
|
||||||
$.ajax({
|
|
||||||
type: "GET",
|
|
||||||
url: '/foodcourt/get_all_menu',
|
|
||||||
data: {},
|
|
||||||
success:function(result){
|
|
||||||
localStorage.setItem("menus", JSON.stringify(result));
|
|
||||||
var menu = localStorage.getItem("menus");
|
|
||||||
if (menu != null ) {
|
|
||||||
$( "#loading_wrapper").hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
getAllMenu();
|
|
||||||
|
if (window.location.href.indexOf('#') != -1) {
|
||||||
|
getAllMenu();
|
||||||
|
}
|
||||||
|
|
||||||
var menus = JSON.parse(localStorage.getItem("menus"));
|
var menus = JSON.parse(localStorage.getItem("menus"));
|
||||||
if (menus != null) {
|
if (menus != null) {
|
||||||
menu_cache_append(menus);
|
menu_cache_append(menus);
|
||||||
}else{
|
|
||||||
$("#menu_data").removeClass("hidden");
|
|
||||||
}
|
|
||||||
|
|
||||||
function menu_cache_append(menus){
|
|
||||||
$("#menu_cache").removeClass("hidden");
|
|
||||||
$(".menu_cache_name").text(menus[0]["name"])
|
|
||||||
for(var i in menus) {
|
|
||||||
menu_list_template(menus[i]);
|
|
||||||
}
|
|
||||||
var category = menus[0]["categories"];
|
|
||||||
|
|
||||||
for(var ii in category) {
|
|
||||||
if (category[ii]["is_available"]== true){
|
|
||||||
if (category[ii]["valid_time"]== true){
|
|
||||||
if (category[ii]["parent_id"] == null ){
|
|
||||||
if(cashier_type){
|
|
||||||
if (category[ii]["code"].includes("SPL") != true) {
|
|
||||||
category_list_template(category[ii]);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if ($("#table_get_current").text()) {
|
|
||||||
if (category[ii]["code"].includes("SPL") != true) {
|
|
||||||
category_list_template(category[ii]);
|
|
||||||
}else {
|
|
||||||
category_list_template(category[ii]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".tables").on('click', function () {
|
$(".tables").on('click', function () {
|
||||||
@@ -501,37 +459,45 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
//End menu category Click
|
//End menu category Click
|
||||||
|
|
||||||
function menu_click_cache_append(name,menus,menu_id) {
|
function getAllMenu(){
|
||||||
var menu_list = $('.menu_items_list');
|
$.ajax({
|
||||||
menu_list.empty();
|
type: "GET",
|
||||||
|
url: '/foodcourt/get_all_menu',
|
||||||
|
data: {},
|
||||||
|
success:function(result){
|
||||||
|
var menus = JSON.stringify(result);
|
||||||
|
localStorage.setItem("menus", menus);
|
||||||
|
if (result != null ) {
|
||||||
|
menu_cache_append(result);
|
||||||
|
$( "#loading_wrapper").hide();
|
||||||
|
$("#oqs_loading_wrapper").css("display", "none");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var menu_cat = $('.category_list');
|
function menu_cache_append(menus){
|
||||||
menu_cat.empty();
|
$("#menu_cache").removeClass("hidden");
|
||||||
|
$(".menu_cache_name").text(menus[0]["name"])
|
||||||
|
for(var i in menus) {
|
||||||
|
menu_list_template(menus[i]);
|
||||||
|
}
|
||||||
|
var category = menus[0]["categories"];
|
||||||
|
|
||||||
$(".main_menu").text(name);
|
for(var ii in category) {
|
||||||
|
if (category[ii]["is_available"]== true){
|
||||||
for(var i in menus) {
|
if (category[ii]["valid_time"]== true){
|
||||||
|
if (category[ii]["parent_id"] == null ){
|
||||||
if (menu_id == menus[i]["id"] && menus[i]["is_active"] == true) {
|
if(cashier_type){
|
||||||
|
if (category[ii]["code"].includes("SPL") != true) {
|
||||||
// menu_list_template(menus[i]);
|
category_list_template(category[ii]);
|
||||||
var category = menus[i]["categories"];
|
}
|
||||||
|
}else{
|
||||||
for(var ii in category) {
|
if ($("#table_get_current").text()) {
|
||||||
if (category[ii]["is_available"]== true){
|
|
||||||
if (category[ii]["valid_time"]== true){
|
|
||||||
if (category[ii]["parent_id"] == null ){
|
|
||||||
if(cashier_type){
|
|
||||||
if (category[ii]["code"].includes("SPL") != true) {
|
if (category[ii]["code"].includes("SPL") != true) {
|
||||||
category_list_template(category[ii]);
|
category_list_template(category[ii]);
|
||||||
}
|
}else {
|
||||||
}else{
|
category_list_template(category[ii]);
|
||||||
if ($("#table_get_current").text()) {
|
|
||||||
if (category[ii]["code"].includes("SPL") != true) {
|
|
||||||
category_list_template(category[ii]);
|
|
||||||
}else {
|
|
||||||
category_list_template(category[ii]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -540,6 +506,46 @@ if (menu_id == menus[i]["id"] && menus[i]["is_active"] == true) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function menu_click_cache_append(name,menus,menu_id) {
|
||||||
|
var menu_list = $('.menu_items_list');
|
||||||
|
menu_list.empty();
|
||||||
|
|
||||||
|
var menu_cat = $('.category_list');
|
||||||
|
menu_cat.empty();
|
||||||
|
|
||||||
|
$(".main_menu").text(name);
|
||||||
|
|
||||||
|
for(var i in menus) {
|
||||||
|
|
||||||
|
if (menu_id == menus[i]["id"] && menus[i]["is_active"] == true) {
|
||||||
|
|
||||||
|
// menu_list_template(menus[i]);
|
||||||
|
var category = menus[i]["categories"];
|
||||||
|
|
||||||
|
for(var ii in category) {
|
||||||
|
if (category[ii]["is_available"]== true){
|
||||||
|
if (category[ii]["valid_time"]== true){
|
||||||
|
if (category[ii]["parent_id"] == null ){
|
||||||
|
if(cashier_type){
|
||||||
|
if (category[ii]["code"].includes("SPL") != true) {
|
||||||
|
category_list_template(category[ii]);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if ($("#table_get_current").text()) {
|
||||||
|
if (category[ii]["code"].includes("SPL") != true) {
|
||||||
|
category_list_template(category[ii]);
|
||||||
|
}else {
|
||||||
|
category_list_template(category[ii]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function category_list_template(menu) {
|
function category_list_template(menu) {
|
||||||
|
|||||||
@@ -118,7 +118,7 @@
|
|||||||
data: "opening_balance=" + amount + "&cashier_terminal="+ cashier_terminal,
|
data: "opening_balance=" + amount + "&cashier_terminal="+ cashier_terminal,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
if(result){
|
if(result){
|
||||||
window.location.href = "<%= foodcourt_food_court_path%>";
|
window.location.href = "<%= foodcourt_food_court_path(:anchor => "") %>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<ul class="list">
|
<ul class="list">
|
||||||
<li class="header"><%= t :main_navigation %></li>
|
<li class="header"><%= t :main_navigation %></li>
|
||||||
<li class="active">
|
<li class="active">
|
||||||
<a href="<%= foodcourt_food_court_path %>">
|
<a href="<%= foodcourt_food_court_path(:anchor => "") %>">
|
||||||
<i class="material-icons">monetization_on</i>
|
<i class="material-icons">monetization_on</i>
|
||||||
<span><%= t :origami %></span>
|
<span><%= t :origami %></span>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user