mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +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
|
|
@ -29,7 +29,7 @@ Template.cleanUpModalConfirm.events({
|
||||||
case "Menus":
|
case "Menus":
|
||||||
cleanUp("clean.Menus", whatItems);
|
cleanUp("clean.Menus", whatItems);
|
||||||
case "Products":
|
case "Products":
|
||||||
// cleanUp("clean.Products", whatItems);
|
cleanUp("clean.Products", whatItems);
|
||||||
case "Stores":
|
case "Stores":
|
||||||
// cleanUp("clean.Stores", whatItems);
|
// cleanUp("clean.Stores", whatItems);
|
||||||
case "Tasks":
|
case "Tasks":
|
||||||
|
|
@ -43,7 +43,7 @@ Template.cleanUpModalConfirm.events({
|
||||||
cleanUp = async function(methodName, whatItems) {
|
cleanUp = async function(methodName, whatItems) {
|
||||||
let result = Meteor.callAsync(methodName);
|
let result = Meteor.callAsync(methodName);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
console.log(" ERROR cleaning " + whatItems + ": " + err);
|
console.log(" ERROR cleaning " + whatItems);
|
||||||
} else {
|
} else {
|
||||||
showSnackbar(whatItems + " have been cleaned up!", "green");
|
showSnackbar(whatItems + " have been cleaned up!", "green");
|
||||||
let confirmModal = document.getElementById('cleanUpConfirm');
|
let confirmModal = document.getElementById('cleanUpConfirm');
|
||||||
|
|
@ -51,6 +51,15 @@ cleanUp = async function(methodName, whatItems) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanProducts = async function(methodName, whatItems) {
|
||||||
|
let result = await Meteor.call(methodName, whatItems);
|
||||||
|
if (!result) {
|
||||||
|
console.log(" ERROR cleaning " + whatItems);
|
||||||
|
} else {
|
||||||
|
showSnackbar(whatItems + " have been cleaned up.", "green");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cleanTasks = async function(methodName, whatItems) {
|
cleanTasks = async function(methodName, whatItems) {
|
||||||
let timeFrame = Session.get("overdueVal");
|
let timeFrame = Session.get("overdueVal");
|
||||||
let result = await Meteor.call(methodName, timeFrame);
|
let result = await Meteor.call(methodName, timeFrame);
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,14 @@
|
||||||
<span>Show Products without Store Assigned</span>
|
<span>Show Products without Store Assigned</span>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="col s12">
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" id="showNoList" />
|
||||||
|
<span>Show Products Never Used in a List</span>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col s12 m6 l6 input-field outlined">
|
<div class="col s12 m6 l6 input-field outlined">
|
||||||
<input type="text" class="prodName" style="{{#if $eq prodNameErr true}}border: 2px solid red;{{/if}}" id="prodName" />
|
<input type="text" class="prodName" style="{{#if $eq prodNameErr true}}border: 2px solid red;{{/if}}" id="prodName" />
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,14 @@ Template.prodMgmtForm.events({
|
||||||
Session.set("noStoreSet", false);
|
Session.set("noStoreSet", false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'click #showNoList' (event) {
|
||||||
|
let notUsedInList = $("#showNoList").prop('checked');
|
||||||
|
if (notUsedInList == true) {
|
||||||
|
Session.set("noListUsed", true);
|
||||||
|
} else {
|
||||||
|
Session.set("noListUsed", false);
|
||||||
|
}
|
||||||
|
},
|
||||||
'submit .prodInputForm' (event) {
|
'submit .prodInputForm' (event) {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,17 @@
|
||||||
import { Products } from '../../../imports/api/products.js';
|
import { Products } from '../../../imports/api/products.js';
|
||||||
|
import { ListItems } from '../../../imports/api/listItems.js';
|
||||||
import { M } from '../../lib/assets/materialize.js';
|
import { M } from '../../lib/assets/materialize.js';
|
||||||
|
|
||||||
Template.prodMgmtTbl.onCreated(function() {
|
Template.prodMgmtTbl.onCreated(function() {
|
||||||
this.subscribe("myProducts");
|
this.subscribe("myProducts");
|
||||||
|
this.subscribe("allListItems");
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.prodMgmtTbl.onRendered(function() {
|
Template.prodMgmtTbl.onRendered(function() {
|
||||||
Session.set("searchProds", false);
|
Session.set("searchProds", false);
|
||||||
Session.set("searchStore", false);
|
Session.set("searchStore", false);
|
||||||
Session.set("noStoreSet", false);
|
Session.set("noStoreSet", false);
|
||||||
|
Session.set("noListUsed", false);
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.prodMgmtTbl.helpers({
|
Template.prodMgmtTbl.helpers({
|
||||||
|
|
@ -16,6 +19,7 @@ Template.prodMgmtTbl.helpers({
|
||||||
let searchProd = Session.get("searchProds");
|
let searchProd = Session.get("searchProds");
|
||||||
let searchStore = Session.get("searchStore");
|
let searchStore = Session.get("searchStore");
|
||||||
let noStoreSet = Session.get("noStoreSet");
|
let noStoreSet = Session.get("noStoreSet");
|
||||||
|
let noListUsed = Session.get("noListUsed");
|
||||||
|
|
||||||
if (searchProd == true) {
|
if (searchProd == true) {
|
||||||
let searchVal = Session.get("searchVal");
|
let searchVal = Session.get("searchVal");
|
||||||
|
|
@ -33,6 +37,20 @@ Template.prodMgmtTbl.helpers({
|
||||||
}
|
}
|
||||||
} else if (noStoreSet == true) {
|
} else if (noStoreSet == true) {
|
||||||
return Products.find({ prodStore: '' }, { sort: { prodName: 1 }});
|
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 {
|
} else {
|
||||||
return Products.find({}, { sort: { prodName: 1 }});
|
return Products.find({}, { sort: { prodName: 1 }});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,5 +63,15 @@ Meteor.methods({
|
||||||
}
|
}
|
||||||
|
|
||||||
return await Products.removeAsync({ _id: prodId });
|
return await Products.removeAsync({ _id: prodId });
|
||||||
|
},
|
||||||
|
async 'clean.Products' () {
|
||||||
|
if (!this.userId) {
|
||||||
|
throw new Meteor.Error('You are not allowed to delete products. Make sure you are logged in with valid user credentials.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// first we need to find potential duplicate products
|
||||||
|
// next we need to see which of those are on incomplete lists
|
||||||
|
// Then we'll update those to use the main products ID instead
|
||||||
|
// finally we'll delete the duplicates
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,14 @@ Meteor.publish("myListItems", function(listId) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Meteor.publish("allListItems", function() {
|
||||||
|
try {
|
||||||
|
return ListItems.find({});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(" ERROR pulling all list items.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Meteor.publish("myStoreListItems", function(listId) {
|
Meteor.publish("myStoreListItems", function(listId) {
|
||||||
try {
|
try {
|
||||||
let stores = Store.find({});
|
let stores = Store.find({});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue