mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 08:18:50 +00:00
Fixing clean Up and added option to show which products arent used in a list
This commit is contained in:
parent
c6c5951d16
commit
680f7c614d
6 changed files with 71 additions and 10 deletions
|
|
@ -1,14 +1,17 @@
|
|||
import { Products } from '../../../imports/api/products.js';
|
||||
import { ListItems } from '../../../imports/api/listItems.js';
|
||||
import { M } from '../../lib/assets/materialize.js';
|
||||
|
||||
Template.prodMgmtTbl.onCreated(function() {
|
||||
this.subscribe("myProducts");
|
||||
this.subscribe("allListItems");
|
||||
});
|
||||
|
||||
Template.prodMgmtTbl.onRendered(function() {
|
||||
Session.set("searchProds", false);
|
||||
Session.set("searchStore", false);
|
||||
Session.set("noStoreSet", false);
|
||||
Session.set("noListUsed", false);
|
||||
});
|
||||
|
||||
Template.prodMgmtTbl.helpers({
|
||||
|
|
@ -16,6 +19,7 @@ Template.prodMgmtTbl.helpers({
|
|||
let searchProd = Session.get("searchProds");
|
||||
let searchStore = Session.get("searchStore");
|
||||
let noStoreSet = Session.get("noStoreSet");
|
||||
let noListUsed = Session.get("noListUsed");
|
||||
|
||||
if (searchProd == true) {
|
||||
let searchVal = Session.get("searchVal");
|
||||
|
|
@ -33,6 +37,20 @@ Template.prodMgmtTbl.helpers({
|
|||
}
|
||||
} else if (noStoreSet == true) {
|
||||
return Products.find({ prodStore: '' }, { sort: { prodName: 1 }});
|
||||
} else if (noListUsed == true) {
|
||||
let i;
|
||||
let idList = [];
|
||||
let idsInLists = ListItems.find({}).fetch();
|
||||
for (i=0; i < idsInLists.length; i++) {
|
||||
// console.log(idsInList[i]);
|
||||
idList.push(idsInLists[i].prodId);
|
||||
}
|
||||
if (i > idsInLists.length - 1) {
|
||||
console.dir(idList);
|
||||
let noProdsNot = Products.find({ _id: { $nin: idList }}).count();
|
||||
console.log(noProdsNot);
|
||||
return Products.find({ _id: { $nin: idList }}, { sort: { prodName: 1 }});
|
||||
}
|
||||
} else {
|
||||
return Products.find({}, { sort: { prodName: 1 }});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue