get_my/client/Dashboard/dashboard.js

96 lines
2.7 KiB
JavaScript
Raw Normal View History

import { Categories } from "../../imports/api/category";
import { Lists } from "../../imports/api/lists";
import { Locations } from "../../imports/api/location";
import { Products } from "../../imports/api/products";
import { Stores } from "../../imports/api/stores";
2022-08-04 19:50:18 -05:00
Template.dashboard.onCreated(function() {
this.subscribe("userList");
this.subscribe("myLists");
this.subscribe("myCategories");
this.subscribe("storeInfo");
this.subscribe("myProducts");
this.subscribe("myLocations");
2022-08-04 19:50:18 -05:00
});
Template.dashboard.onRendered(function() {
});
Template.dashboard.helpers({
userCount: function() {
return Meteor.users.find().count();
},
listCount: function() {
return Lists.find().count();
},
storeCount: function() {
return Stores.find().count();
},
productCount: function() {
return Products.find().count();
},
catCount: function() {
return Categories.find().count();
},
locCount: function() {
return Locations.find().count();
}
2022-08-04 19:50:18 -05:00
});
Template.dashboard.events({
"click .cardLink" (event) {
event.preventDefault();
let link = event.currentTarget.id;
switch(link) {
case "userMgmtLink":
FlowRouter.go('/userMgmt');
break;
case "listMgmtLink":
FlowRouter.go('/manageLists');
break;
case "storeMgmtLink":
FlowRouter.go('/manageStore');
break;
case "prodMgmtLink":
FlowRouter.go('/manageProduct');
break;
case "catMgmtLink":
FlowRouter.go('/manageCategory');
break;
case "locationMgmtLink":
FlowRouter.go('/manageLocation');
break;
default:
break;
}
},
'click .card' (event) {
event.preventDefault();
let cardId = event.currentTarget.id;
switch(cardId) {
case "userInfoCard":
FlowRouter.go('/userMgmt');
break;
case "listInfoCard":
FlowRouter.go("/mylists");
break;
case "storeInfoCard":
FlowRouter.go('/manageStore');
break;
case "catInfoCard":
FlowRouter.go('/manageCategory');
break;
case "locInfoCard":
FlowRouter.go('/manageLocation');
break;
case "prodInfoCard":
FlowRouter.go("/manageProduct");
break;
default:
break;
}
}
2022-08-04 19:50:18 -05:00
});