mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Updated Lists to pull last viewed list from db
This commit is contained in:
parent
be07ec72bd
commit
3ad8fab67b
5 changed files with 97 additions and 6 deletions
|
|
@ -2,11 +2,13 @@ import { ListItems } from '../../imports/api/listItems.js'
|
|||
import { Lists } from '../../imports/api/lists.js';
|
||||
import { Products } from '../../imports/api/products.js';
|
||||
import { M } from '../lib/assets/materialize.js';
|
||||
import { UserLast } from '../../imports/api/userLast.js';
|
||||
|
||||
Template.listItemsForm.onCreated(function() {
|
||||
this.subscribe("myListItems", Session.get("listId"));
|
||||
this.subscribe("myLists");
|
||||
this.subscribe("myProducts");
|
||||
this.subscribe("userLastView");
|
||||
});
|
||||
|
||||
Template.listItemsForm.onRendered(function() {
|
||||
|
|
@ -28,9 +30,16 @@ Template.listItemsForm.onRendered(function() {
|
|||
|
||||
Template.listItemsForm.helpers({
|
||||
selListName: function() {
|
||||
let selListId = Session.get("listId");
|
||||
let selListId = "";
|
||||
if (Session.get("listId")) {
|
||||
selListId = Session.get("listId");
|
||||
} else {
|
||||
selListId = UserLast.findOne({ view: "List", userId: Meteor.userId() }).viewId;
|
||||
}
|
||||
let listInfo = Lists.findOne({ _id: selListId });
|
||||
return listInfo.listName;
|
||||
if (listInfo) {
|
||||
return listInfo.listName;
|
||||
}
|
||||
},
|
||||
itemProdName: function() {
|
||||
return Products.find({});
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import { ListItems } from '../../imports/api/listItems.js';
|
||||
import { M } from '../lib/assets/materialize.js';
|
||||
import { UserLast } from '../../imports/api/userLast.js';
|
||||
|
||||
Template.listItemsTbl.onCreated(function() {
|
||||
this.autorun( () => {
|
||||
this.subscribe("myListItems", Session.get("listId"));
|
||||
});
|
||||
this.subscribe("userLastView");
|
||||
});
|
||||
|
||||
Template.listItemsTbl.onRendered(function() {
|
||||
|
|
@ -13,6 +15,14 @@ Template.listItemsTbl.onRendered(function() {
|
|||
|
||||
Session.set("showReceivedItems", false);
|
||||
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({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue