mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Making it so that Menu and Lists load from db when refreshed.
This commit is contained in:
parent
3ad8fab67b
commit
2f3f82477a
7 changed files with 47 additions and 19 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
<template name="listItemsForm">
|
<template name="listItemsForm">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s6 center">
|
<div class="col s6 center">
|
||||||
|
{{#if Template.subscriptionsReady}}
|
||||||
<h5>{{selListName}}</h5>
|
<h5>{{selListName}}</h5>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div class="col s6">
|
<div class="col s6">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,13 @@ Template.listItemsForm.helpers({
|
||||||
if (Session.get("listId")) {
|
if (Session.get("listId")) {
|
||||||
selListId = Session.get("listId");
|
selListId = Session.get("listId");
|
||||||
} else {
|
} else {
|
||||||
selListId = UserLast.findOne({ view: "List", userId: Meteor.userId() }).viewId;
|
selListInfo = UserLast.findOne({ view: "List" });
|
||||||
|
if (selListInfo) {
|
||||||
|
selListId = selListInfo.viewId;
|
||||||
|
Session.set("listId", selListId);
|
||||||
|
} else {
|
||||||
|
console.log("not finding any value for viewId.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let listInfo = Lists.findOne({ _id: selListId });
|
let listInfo = Lists.findOne({ _id: selListId });
|
||||||
if (listInfo) {
|
if (listInfo) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<ul class="collection">
|
<ul class="collection">
|
||||||
|
{{#if Template.subscriptionsReady}}
|
||||||
{{#each thisListItems}}
|
{{#each thisListItems}}
|
||||||
<li class="collection-item">
|
<li class="collection-item">
|
||||||
<span>
|
<span>
|
||||||
|
|
@ -15,6 +16,7 @@
|
||||||
<i class="material-icons clickable markListItemReceived right">check</i>
|
<i class="material-icons clickable markListItemReceived right">check</i>
|
||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,6 @@ Template.listItemsTbl.onRendered(function() {
|
||||||
|
|
||||||
Session.set("showReceivedItems", false);
|
Session.set("showReceivedItems", false);
|
||||||
Session.set("searchVal", "");
|
Session.set("searchVal", "");
|
||||||
|
|
||||||
if (Session.get("listId")) {
|
|
||||||
console.log("got List Id in Session var.");
|
|
||||||
// no action
|
|
||||||
} else {
|
|
||||||
let selListId = UserLast.find({ view: "List" }).listId;
|
|
||||||
Session.set("listId", selListId);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.listItemsTbl.helpers({
|
Template.listItemsTbl.helpers({
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,12 @@ import { MenuItems } from '../../imports/api/menuItems.js';
|
||||||
import { Menus } from '../../imports/api/menu.js';
|
import { Menus } from '../../imports/api/menu.js';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { M } from '../lib/assets/materialize.js';
|
import { M } from '../lib/assets/materialize.js';
|
||||||
|
import { UserLast } from '../../imports/api/userLast.js';
|
||||||
|
|
||||||
Template.menuItemsForm.onCreated(function() {
|
Template.menuItemsForm.onCreated(function() {
|
||||||
this.subscribe("myMenus");
|
this.subscribe("myMenus");
|
||||||
this.subscribe("allMenuItems", Session.get("menuId"));
|
this.subscribe("allMenuItems", Session.get("menuId"));
|
||||||
|
this.subscribe("userLastView");
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.menuItemsForm.onRendered(function() {
|
Template.menuItemsForm.onRendered(function() {
|
||||||
|
|
@ -29,10 +31,17 @@ Template.menuItemsForm.helpers({
|
||||||
return Session.get("menuItemErr");
|
return Session.get("menuItemErr");
|
||||||
},
|
},
|
||||||
menuName: function() {
|
menuName: function() {
|
||||||
let menuId = Session.get("menuId");
|
let menuId = "";
|
||||||
|
if (Session.get("menuId")) {
|
||||||
|
menuId = Session.get("menuId");
|
||||||
|
} else {
|
||||||
|
menuId = UserLast.findOne({ view: "Menu" }).viewId;
|
||||||
|
}
|
||||||
|
|
||||||
let menuInfo = Menus.findOne({ _id: menuId });
|
let menuInfo = Menus.findOne({ _id: menuId });
|
||||||
let menuName = menuInfo.menuName;
|
if (menuInfo) {
|
||||||
return menuName;
|
return menuInfo.menuName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
import { MenuItems } from '../../imports/api/menuItems.js';
|
import { MenuItems } from '../../imports/api/menuItems.js';
|
||||||
import { M } from '../lib/assets/materialize.js';
|
import { M } from '../lib/assets/materialize.js';
|
||||||
|
import { UserLast } from '../../imports/api/userLast.js';
|
||||||
|
|
||||||
Template.menuItemsTbl.onCreated(function() {
|
Template.menuItemsTbl.onCreated(function() {
|
||||||
this.autorun( () => {
|
this.autorun( () => {
|
||||||
this.subscribe("myMenuItems", Session.get("menuId"));
|
this.subscribe("myMenuItems", Session.get("menuId"));
|
||||||
});
|
});
|
||||||
|
this.subscribe("userLastView");
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.menuItemsTbl.onRendered(function() {
|
Template.menuItemsTbl.onRendered(function() {
|
||||||
|
|
@ -22,7 +24,16 @@ Template.menuItemsTbl.onRendered(function() {
|
||||||
|
|
||||||
Template.menuItemsTbl.helpers({
|
Template.menuItemsTbl.helpers({
|
||||||
thisMenuItems: function() {
|
thisMenuItems: function() {
|
||||||
return MenuItems.find({ menuId: Session.get("menuId") }, { sort: { serveDateActual: 1 }});
|
let menuId = "";
|
||||||
|
if (Session.get("menuId")) {
|
||||||
|
menuId = Session.get("menuId");
|
||||||
|
} else {
|
||||||
|
menuId = UserLast.findOne({ view: "Menu" }).viewId;
|
||||||
|
}
|
||||||
|
let menuInfo = MenuItems.find({ menuId: menuId }, { sort: { serveDateActual: 1 }});
|
||||||
|
if (menuInfo) {
|
||||||
|
return menuInfo
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -40,7 +51,7 @@ Template.menuItemsTbl.events({
|
||||||
},
|
},
|
||||||
'click .addProdsToList' (event) {
|
'click .addProdsToList' (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
console.log("Menu Iteme Id sent is: " + this._id);
|
// console.log("Menu Iteme Id sent is: " + this._id);
|
||||||
Session.set("menuItemId", this._id);
|
Session.set("menuItemId", this._id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -28,12 +28,18 @@ Template.mainMenuTbl.events({
|
||||||
if (menuId == "addMenu") {
|
if (menuId == "addMenu") {
|
||||||
// console.log("add menu clicked");
|
// console.log("add menu clicked");
|
||||||
} else {
|
} else {
|
||||||
console.log("menuId is: " + menuId);
|
// console.log("menuId is: " + menuId);
|
||||||
|
Meteor.call('add.userLast', "Menu", menuId, function(err, result) {
|
||||||
|
if (err) {
|
||||||
|
console.log(" ERROR writing last menu viewed by user to db: " + err);
|
||||||
|
} else {
|
||||||
Session.set("menuId", menuId);
|
Session.set("menuId", menuId);
|
||||||
Meteor.setTimeout(function() {
|
Meteor.setTimeout(function() {
|
||||||
FlowRouter.go('/menuitems');
|
FlowRouter.go('/menuitems');
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} else if (sender.localName == "i") {
|
} else if (sender.localName == "i") {
|
||||||
let menuId = this._id;
|
let menuId = this._id;
|
||||||
Meteor.call("markMenu.complete", menuId, function(err, result) {
|
Meteor.call("markMenu.complete", menuId, function(err, result) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue