From 42643a37f50c5401eeee5e660dcfdf0f29482b27 Mon Sep 17 00:00:00 2001 From: Brian McGonagill Date: Tue, 16 Aug 2022 16:46:14 -0500 Subject: [PATCH] Adding more methods and views, updated dashboards a bit. Still not ready --- client/AdminMgmt/CategoryMgMt/catMgmtTbl.html | 32 +++---- client/AdminMgmt/ListMgmt/listMgmt.html | 5 + client/AdminMgmt/ListMgmt/listMgmt.js | 16 ++++ client/AdminMgmt/ListMgmt/listMgmtForm.html | 18 ++++ client/AdminMgmt/ListMgmt/listMgmtForm.js | 92 +++++++++++++++++++ client/AdminMgmt/ListMgmt/listMgmtTbl.html | 16 ++++ client/AdminMgmt/ListMgmt/listMgmtTbl.js | 47 ++++++++++ client/AdminMgmt/MgmtPage/mgmtPage.html | 4 +- .../AdminMgmt/ProductMgmt/prodMgmtForm.html | 27 +++++- client/AdminMgmt/ProductMgmt/prodMgmtForm.js | 12 ++- .../{StoreMgMt => StoreMgmt}/storeMgmt.html | 0 .../{StoreMgMt => StoreMgmt}/storeMgmt.js | 0 .../storeMgmtForm.html | 0 .../{StoreMgMt => StoreMgmt}/storeMgmtForm.js | 0 .../storeMgmtTbl.html | 0 .../{StoreMgMt => StoreMgmt}/storeMgmtTbl.js | 0 client/Dashboard/dashboard.html | 67 +++++++++++++- client/Dashboard/dashboard.js | 20 ++++ client/General/headerBar.html | 4 +- client/main.css | 4 + imports/api/lists.js | 26 +++++- lib/routes.js | 7 ++ server/publish.js | 9 ++ 23 files changed, 374 insertions(+), 32 deletions(-) create mode 100644 client/AdminMgmt/ListMgmt/listMgmt.html create mode 100644 client/AdminMgmt/ListMgmt/listMgmt.js create mode 100644 client/AdminMgmt/ListMgmt/listMgmtForm.html create mode 100644 client/AdminMgmt/ListMgmt/listMgmtForm.js create mode 100644 client/AdminMgmt/ListMgmt/listMgmtTbl.html create mode 100644 client/AdminMgmt/ListMgmt/listMgmtTbl.js rename client/AdminMgmt/{StoreMgMt => StoreMgmt}/storeMgmt.html (100%) rename client/AdminMgmt/{StoreMgMt => StoreMgmt}/storeMgmt.js (100%) rename client/AdminMgmt/{StoreMgMt => StoreMgmt}/storeMgmtForm.html (100%) rename client/AdminMgmt/{StoreMgMt => StoreMgmt}/storeMgmtForm.js (100%) rename client/AdminMgmt/{StoreMgMt => StoreMgmt}/storeMgmtTbl.html (100%) rename client/AdminMgmt/{StoreMgMt => StoreMgmt}/storeMgmtTbl.js (100%) diff --git a/client/AdminMgmt/CategoryMgMt/catMgmtTbl.html b/client/AdminMgmt/CategoryMgMt/catMgmtTbl.html index cd65384..1531675 100644 --- a/client/AdminMgmt/CategoryMgMt/catMgmtTbl.html +++ b/client/AdminMgmt/CategoryMgMt/catMgmtTbl.html @@ -1,21 +1,15 @@ \ No newline at end of file diff --git a/client/AdminMgmt/ListMgmt/listMgmt.html b/client/AdminMgmt/ListMgmt/listMgmt.html new file mode 100644 index 0000000..5e9a5d6 --- /dev/null +++ b/client/AdminMgmt/ListMgmt/listMgmt.html @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/client/AdminMgmt/ListMgmt/listMgmt.js b/client/AdminMgmt/ListMgmt/listMgmt.js new file mode 100644 index 0000000..2f42eec --- /dev/null +++ b/client/AdminMgmt/ListMgmt/listMgmt.js @@ -0,0 +1,16 @@ + +Template.listMgmt.onCreated(function() { + +}); + +Template.listMgmt.onRendered(function() { + +}); + +Template.listMgmt.helpers({ + +}); + +Template.listMgmt.events({ + +}); \ No newline at end of file diff --git a/client/AdminMgmt/ListMgmt/listMgmtForm.html b/client/AdminMgmt/ListMgmt/listMgmtForm.html new file mode 100644 index 0000000..d2b2fac --- /dev/null +++ b/client/AdminMgmt/ListMgmt/listMgmtForm.html @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/client/AdminMgmt/ListMgmt/listMgmtForm.js b/client/AdminMgmt/ListMgmt/listMgmtForm.js new file mode 100644 index 0000000..43c26cf --- /dev/null +++ b/client/AdminMgmt/ListMgmt/listMgmtForm.js @@ -0,0 +1,92 @@ +import { Lists } from '../../../imports/api/lists.js'; + +Template.listMgmtForm.onCreated(function() { + this.subscribe("myLists"); +}); + +Template.listMgmtForm.onRendered(function() { + Session.set("listNameMiss", false); + Session.set("listNameEditMode", false); +}); + +Template.listMgmtForm.helpers({ + listNameErr: function() { + return Session.get("listNameMiss"); + }, + editMode: function() { + return Session.get("listNameEditMode"); + } +}); + +Template.listMgmtForm.events({ + 'click .saveListMgmt' (event) { + event.preventDefault(); + let listName = $("#listNameInp").val(); + + if (listName == null || listName == "") { + Session.set("listNameMiss", true); + return; + } else { + Meteor.call('add.list', listName, function(err, result) { + if (err) { + console.log(" ERROR adding list name: " + err); + } else { + console.log(" SUCCESS adding list name."); + $("#listNameInp").val(""); + } + }); + } + }, + 'click .renameListMgmt' (event) { + event.preventDefault(); + let listName = $("#listNameInp").val(); + let listId = Session.get("listItemId"); + + if (listName == null || listName == "") { + Session.set("listNameMiss", true); + return; + } else { + Meteor.call('edit.list', listId, listName, function(err, result) { + if (err) { + console.log(" ERROR editing list name: " + err); + } else { + console.log(" SUCCESS editing list name."); + $("#listNameInp").val(""); + Session.set("listNameEditMode", false); + } + }); + } + }, + 'submit .listAdd' (event) { + event.preventDefault(); + let editMode = Session.get("listNameEditMode"); + let listName = $("#listNameInp").val(); + let listId = Session.get("listItemId"); + + if (listName == null || listName == "") { + Session.set("listNameMiss", true); + return; + } else { + if (editMode == false) { + Meteor.call('add.list', listName, function(err, result) { + if (err) { + console.log(" ERROR adding list name: " + err); + } else { + console.log(" SUCCESS adding list name."); + $("#listNameInp").val(""); + } + }); + } else { + Meteor.call('edit.list', listId, listName, function(err, result) { + if (err) { + console.log(" ERROR editing list name: " + err); + } else { + console.log(" SUCCESS editing list name."); + $("#listNameInp").val(""); + Session.set("listNameEditMode", false); + } + }); + } + } + } +}); \ No newline at end of file diff --git a/client/AdminMgmt/ListMgmt/listMgmtTbl.html b/client/AdminMgmt/ListMgmt/listMgmtTbl.html new file mode 100644 index 0000000..fde6b45 --- /dev/null +++ b/client/AdminMgmt/ListMgmt/listMgmtTbl.html @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/client/AdminMgmt/ListMgmt/listMgmtTbl.js b/client/AdminMgmt/ListMgmt/listMgmtTbl.js new file mode 100644 index 0000000..e3a837c --- /dev/null +++ b/client/AdminMgmt/ListMgmt/listMgmtTbl.js @@ -0,0 +1,47 @@ +import { Lists } from '../../../imports/api/lists.js'; + +Template.listMgmtTbl.onCreated(function() { + this.subscribe("myLists"); +}); + +Template.listMgmtTbl.onRendered(function() { + $('.tooltipped').tooltip(); +}); + +Template.listMgmtTbl.helpers({ + lists: function() { + return Lists.find({}); + } +}); + +Template.listMgmtTbl.events({ + 'click .deleteListName' (event) { + event.preventDefault(); + let listId = this._id; + Meteor.call('delete.list', listId, function(err, result) { + if (err) { + console.log(" ERROR deleting list: " + err); + } else { + console.log(" SUCCESS deleting list."); + } + }); + }, + 'click .editListName' (event) { + event.preventDefault(); + let listName = Lists.findOne({ _id: this._id }).listName; + $("#listNameInp").val(listName); + Session.set("listNameEditMode", true); + Session.set("listItemId", this._id); + }, + 'click .markListComplete' (event) { + event.preventDefault(); + let listId = this._id; + Meteor.call('mark.complete', listId, function(err, result) { + if (err) { + console.log(" ERROR marking complete: " + err); + } else { + console.log(" SUCCESS marking complete."); + } + }); + } +}); \ No newline at end of file diff --git a/client/AdminMgmt/MgmtPage/mgmtPage.html b/client/AdminMgmt/MgmtPage/mgmtPage.html index 0bf42f8..21a1460 100644 --- a/client/AdminMgmt/MgmtPage/mgmtPage.html +++ b/client/AdminMgmt/MgmtPage/mgmtPage.html @@ -1,12 +1,12 @@ \ No newline at end of file diff --git a/client/AdminMgmt/ProductMgmt/prodMgmtForm.js b/client/AdminMgmt/ProductMgmt/prodMgmtForm.js index bd28377..4eb60e7 100644 --- a/client/AdminMgmt/ProductMgmt/prodMgmtForm.js +++ b/client/AdminMgmt/ProductMgmt/prodMgmtForm.js @@ -62,6 +62,10 @@ Template.prodMgmtForm.events({ // console.log(" ERROR: can't add product: " + err); } else { // console.log(" SUCCESS adding product."); + $("#prodName").val(""); + $("#prodCategory").val(""); + $("#prodStore").val(""); + $("#prodLocation").val(""); } }); } @@ -71,7 +75,7 @@ Template.prodMgmtForm.events({ $("#prodName").val(""); $("#prodCategory").val(""); $("#prodStore").val(""); - $("#prodLocation").val("") + $("#prodLocation").val(""); }, 'change #prodStore' (event) { event.preventDefault(); @@ -81,7 +85,6 @@ Template.prodMgmtForm.events({ $("#prodStore").val(""); // open a modal to enter store information. $('#modalStore').modal('open'); - } }, 'change #prodLocation' (event) { @@ -98,10 +101,13 @@ Template.prodMgmtForm.events({ event.preventDefault(); let val = $("#prodCategory").val(); - if (val == "addNewCategory") { + if (val == "addNewCat") { $("#prodCategory").val(""); // open a modal to enter store information. $('#modalCategory').modal('open'); } }, + 'click .modal-close' (event) { + $('select').formSelect(); + } }); \ No newline at end of file diff --git a/client/AdminMgmt/StoreMgMt/storeMgmt.html b/client/AdminMgmt/StoreMgmt/storeMgmt.html similarity index 100% rename from client/AdminMgmt/StoreMgMt/storeMgmt.html rename to client/AdminMgmt/StoreMgmt/storeMgmt.html diff --git a/client/AdminMgmt/StoreMgMt/storeMgmt.js b/client/AdminMgmt/StoreMgmt/storeMgmt.js similarity index 100% rename from client/AdminMgmt/StoreMgMt/storeMgmt.js rename to client/AdminMgmt/StoreMgmt/storeMgmt.js diff --git a/client/AdminMgmt/StoreMgMt/storeMgmtForm.html b/client/AdminMgmt/StoreMgmt/storeMgmtForm.html similarity index 100% rename from client/AdminMgmt/StoreMgMt/storeMgmtForm.html rename to client/AdminMgmt/StoreMgmt/storeMgmtForm.html diff --git a/client/AdminMgmt/StoreMgMt/storeMgmtForm.js b/client/AdminMgmt/StoreMgmt/storeMgmtForm.js similarity index 100% rename from client/AdminMgmt/StoreMgMt/storeMgmtForm.js rename to client/AdminMgmt/StoreMgmt/storeMgmtForm.js diff --git a/client/AdminMgmt/StoreMgMt/storeMgmtTbl.html b/client/AdminMgmt/StoreMgmt/storeMgmtTbl.html similarity index 100% rename from client/AdminMgmt/StoreMgMt/storeMgmtTbl.html rename to client/AdminMgmt/StoreMgmt/storeMgmtTbl.html diff --git a/client/AdminMgmt/StoreMgMt/storeMgmtTbl.js b/client/AdminMgmt/StoreMgmt/storeMgmtTbl.js similarity index 100% rename from client/AdminMgmt/StoreMgMt/storeMgmtTbl.js rename to client/AdminMgmt/StoreMgmt/storeMgmtTbl.js diff --git a/client/Dashboard/dashboard.html b/client/Dashboard/dashboard.html index 68d2546..dcd254f 100644 --- a/client/Dashboard/dashboard.html +++ b/client/Dashboard/dashboard.html @@ -16,7 +16,70 @@ - {{/if}} - + {{/if}} +
+
+
+

My Lists

+
+
list
+

{{listCount}}

+
+
+ {{#if isInRole 'systemadmin'}} + + {{/if}} +
+
+
+
+
+

My Products

+
+
qr_code_scanner
+

{{productCount}}

+
+
+ {{#if isInRole 'systemadmin'}} + + {{/if}} +
+
+
+
+
+

My Stores

+
+
local_mall
+

{{storeCount}}

+
+
+ {{#if isInRole 'systemadmin'}} + + {{/if}} +
+
+
+
+
+

My Categories

+
+
category
+

{{catCount}}

+
+
+ {{#if isInRole 'systemadmin'}} + + {{/if}} +
+
\ No newline at end of file diff --git a/client/Dashboard/dashboard.js b/client/Dashboard/dashboard.js index f699886..d0d339e 100644 --- a/client/Dashboard/dashboard.js +++ b/client/Dashboard/dashboard.js @@ -1,7 +1,15 @@ +import { Categories } from "../../imports/api/category"; +import { Lists } from "../../imports/api/lists"; +import { Products } from "../../imports/api/products"; +import { Stores } from "../../imports/api/stores"; Template.dashboard.onCreated(function() { this.subscribe("userList"); + this.subscribe("myLists"); + this.subscribe("myCategories"); + this.subscribe("storeInfo"); + this.subscribe("myProducts"); }); Template.dashboard.onRendered(function() { @@ -11,6 +19,18 @@ 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(); } }); diff --git a/client/General/headerBar.html b/client/General/headerBar.html index 3c9a950..a014823 100644 --- a/client/General/headerBar.html +++ b/client/General/headerBar.html @@ -19,8 +19,8 @@