Updating the materialize library and calls.

This commit is contained in:
Brian McGonagill 2024-07-22 11:56:35 -05:00
parent a118bf38fc
commit e44ef98be4
17 changed files with 10582 additions and 15529 deletions

View file

@ -8,7 +8,6 @@ Template.reg.onRendered(function() {
Session.set("canreg", false); Session.set("canreg", false);
Session.set("missingReq", false); Session.set("missingReq", false);
Session.set("missingName", false); Session.set("missingName", false);
Session.set("missingPhone", false);
Session.set("missingEmail", false); Session.set("missingEmail", false);
Session.set("missingPassword", false); Session.set("missingPassword", false);
}); });
@ -53,7 +52,6 @@ Template.reg.events({
let email = $("#email").val(); let email = $("#email").val();
let password = $("#password").val(); let password = $("#password").val();
let name = $("#name").val(); let name = $("#name").val();
let phone = $("#phone").val();
if (name == "" || name == null) { if (name == "" || name == null) {
missingName = true; missingName = true;

View file

@ -18,9 +18,9 @@
<div class="row"> <div class="row">
<div class="col s12 m12 l12"> <div class="col s12 m12 l12">
{{#if $eq editMode false}} {{#if $eq editMode false}}
<a class="waves-effect waves-light btn saveListMgmt green right">Add</a> <a class="waves-effect waves-light btn saveListMgmt green white-text right">Add</a>
{{else}} {{else}}
<a class="waves-effect waves-light btn renameListMgmt blue right">Rename</a> <a class="waves-effect waves-light btn renameListMgmt blue white-text right">Rename</a>
{{/if}} {{/if}}
</div> </div>
</div> </div>

View file

@ -3,7 +3,8 @@ Template.deleteConfirmationModal.onCreated(function() {
}); });
Template.deleteConfirmationModal.onRendered(function() { Template.deleteConfirmationModal.onRendered(function() {
$('.modal').modal(); // put new modal init here
// $('.modal').modal();
}); });
Template.deleteConfirmationModal.helpers({ Template.deleteConfirmationModal.helpers({
@ -26,7 +27,8 @@ Template.deleteConfirmationModal.events({
console.log(" ERROR deleting item from modal: " + err); console.log(" ERROR deleting item from modal: " + err);
} else { } else {
// console.log(" SUCCESSFULLY deleted."); // console.log(" SUCCESSFULLY deleted.");
$('#modalDelete').modal('close'); // put the new modal open / close here
// $('#modalDelete').modal('close');
} }
}); });
}, },

View file

@ -1,19 +1,14 @@
import { M } from '../lib/assets/materialize';
Template.headerBar.onCreated(function() { Template.headerBar.onCreated(function() {
}); });
Template.headerBar.onRendered(function() { Template.headerBar.onRendered(function() {
$('.sidenav').sidenav(); var elems = document.querySelectorAll('.sidenav');
setTimeout(function() { var instances = M.Sidenav.init(elems, {});
$('.sidenav').sidenav(); var elemd = document.querySelectorAll('.dropdown-trigger');
$(".dropdown-trigger").dropdown(); var instances = M.Dropdown.init(elemd, {});
$('.collapsible').collapsible();
}, 200)
$(".dropdown-trigger").dropdown();
$('.collapsible').collapsible();
}); });
Template.headerBar.helpers({ Template.headerBar.helpers({

View file

@ -1,11 +1,12 @@
import { M } from '../../lib/assets/materialize.js';
Template.myModal.onCreated(function() { Template.myModal.onCreated(function() {
}); });
Template.myModal.onRendered(function() { Template.myModal.onRendered(function() {
$('.modal').modal(); var elems = document.querySelectorAll('.modal');
var instances = M.Modal.init(elems, {});
}); });
Template.myModal.helpers({ Template.myModal.helpers({
@ -30,7 +31,7 @@ Template.myModal.events({
} else { } else {
$("#genModal").modal('close'); $("#genModal").modal('close');
window[callFunction](functionPassId); // <-- calls the function and passed the Id on confirm. window[callFunction](functionPassId); // <-- calls the function and passes the Id on confirm.
} }
}, },
'click #cancel' (event) { 'click #cancel' (event) {

View file

@ -1,27 +1,26 @@
import { ListItems } from '../../imports/api/listItems.js' import { ListItems } from '../../imports/api/listItems.js'
import { Lists } from '../../imports/api/lists.js'; import { Lists } from '../../imports/api/lists.js';
import { Products } from '../../imports/api/products.js'; import { Products } from '../../imports/api/products.js';
import { typeahead } from 'typeahead-standalone'; import { M } from '../lib/assets/materialize.js';
Template.listItemsForm.onCreated(function() { Template.listItemsForm.onCreated(function() {
this.subscribe("myListItems", Session.get("listId")); this.subscribe("myListItems", Session.get("listId"));
this.subscribe("myLists"); this.subscribe("myLists");
// this.subscribe("listProducts", Session.get("listItemVal"));
this.subscribe("myProducts"); this.subscribe("myProducts");
}); });
Template.listItemsForm.onRendered(function() { Template.listItemsForm.onRendered(function() {
Meteor.setTimeout(function() { var elems = document.querySelectorAll('select');
$('select').formSelect(); var instances = M.FormSelect.init(elems, {});
}, 100);
$('select').formSelect();
Session.set("listItemEditMode", false); Session.set("listItemEditMode", false);
Session.set("itemReqErr", false); Session.set("itemReqErr", false);
Session.set("showReceivedItems", false); Session.set("showReceivedItems", false);
Session.set("filtering", false); Session.set("filtering", false);
Session.set("findListItems", {}); Session.set("findListItems", {});
this.autorun(() => { this.autorun(() => {
$('input.autocomplete').autocomplete({ var elems = document.querySelectorAll('.autocomplete');
var instances = M.Autocomplete.init(elems, {
minLength: 0,
data: Session.get("findListItems"), data: Session.get("findListItems"),
}); });
}); });
@ -95,20 +94,11 @@ Template.listItemsForm.events({
}, },
'keyup #findListItems' (event) { 'keyup #findListItems' (event) {
if (event.which !== 13) { if (event.which !== 13) {
let listItemObj = {};
let findItemVal = $("#findListItems").val(); let findItemVal = $("#findListItems").val();
console.log("Should start showing options now..."); let listItemInfo = Products.find({ prodName: {$regex: findItemVal + '.*', $options: 'i'}}).fetch();
Session.set("listItemVal", findItemVal);
let listItemInfo = Products.find({ prodName: {$regex: findItemVal + '.*', $options: 'i'}}, { limit: 5 }).fetch();
if (typeof listItemInfo != 'undefined' && listItemInfo != "" && listItemInfo != null) { if (typeof listItemInfo != 'undefined' && listItemInfo != "" && listItemInfo != null) {
for (i=0; i < listItemInfo.length; i++) { getDataList(listItemInfo);
let item = listItemInfo[i].prodName;
let store = listItemInfo[i].prodStore;
listItemObj[item] = store;
}
Session.set("findListItems", listItemObj);
} }
} }
}, },
'click #filterOn' (event) { 'click #filterOn' (event) {
@ -119,4 +109,10 @@ Template.listItemsForm.events({
event.preventDefault(); event.preventDefault();
Session.set("filtering", false); Session.set("filtering", false);
} }
}); });
getDataList = function(listItemInfo) {
let listItemObjArray = [];
listItemObjArray = listItemInfo.map(info => ({ id: info._id, text: info.prodName, store: info.prodStore }))
Session.set("findListItems", listItemObjArray);
}

View file

@ -7,7 +7,8 @@ Template.listItemsTbl.onCreated(function() {
}); });
Template.listItemsTbl.onRendered(function() { Template.listItemsTbl.onRendered(function() {
$('.modal').modal(); // new modal init here
// $('.modal').modal();
Session.set("showReceivedItems", false); Session.set("showReceivedItems", false);
Session.set("searchVal", ""); Session.set("searchVal", "");
}); });
@ -70,6 +71,8 @@ Template.listItemsTbl.events({
Session.set("method", "delete.listItem"); Session.set("method", "delete.listItem");
Session.set("item", this.itemName); Session.set("item", this.itemName);
Session.set("view", "List Items"); Session.set("view", "List Items");
$('#modalDelete').modal('open');
// put the new modal js here
// $('#modalDelete').modal('open');
}, },
}); });

View file

@ -8,7 +8,7 @@
<i class="material-icons clickable markAsComplete right" id="check_{{this._id}}">check</i> <i class="material-icons clickable markAsComplete right" id="check_{{this._id}}">check</i>
</li> </li>
{{/each}} {{/each}}
<li class="collection-item clickable addNew" id="addList"> + Add New List</li> <li data-target="modalList" class="modal-trigger collection-item clickable addNew" id="addList"> + Add New List</li>
</ul> </ul>
</div> </div>
</div> </div>
@ -19,7 +19,7 @@
{{> listMgmtForm}} {{> listMgmtForm}}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a href="#!" class="modal-close waves-effect waves-green btn-flat">Done</a> <a href="#!" class="modal-close waves-effect black white-text btn-flat">Done</a>
</div> </div>
</div> </div>
{{> snackbar}} {{> snackbar}}

View file

@ -1,11 +1,13 @@
import { Lists } from '../../imports/api/lists.js'; import { Lists } from '../../imports/api/lists.js';
import { M } from '../lib/assets/materialize.js';
Template.listsTbl.onCreated(function() { Template.listsTbl.onCreated(function() {
this.subscribe("myLists"); this.subscribe("myLists");
}); });
Template.listsTbl.onRendered(function() { Template.listsTbl.onRendered(function() {
$('.modal').modal(); var elems = document.querySelectorAll('.modal');
var instances = M.Modal.init(elems, {});
}); });
Template.listsTbl.helpers({ Template.listsTbl.helpers({
@ -21,7 +23,7 @@ Template.listsTbl.events({
if (sender.localName == "li" || sender.localName == "span") { if (sender.localName == "li" || sender.localName == "span") {
let listId = event.currentTarget.id; let listId = event.currentTarget.id;
if (listId == "addList") { if (listId == "addList") {
$('#modalList').modal('open'); // $('#modalList').modal('open');
} else { } else {
// console.log("listId is: " + listId); // console.log("listId is: " + listId);
Session.set("listId", listId); Session.set("listId", listId);

View file

@ -1,8 +1,10 @@
<template name="MainLayout"> <template name="MainLayout">
{{> headerBar}} {{#if Template.subscriptionsReady}}
{{#if currentUser}} {{> headerBar}}
{{> Template.dynamic template=main}} {{#if currentUser}}
{{else}} {{> Template.dynamic template=main}}
{{> Template.dynamic template=notLoggedIn}} {{else}}
{{> Template.dynamic template=notLoggedIn}}
{{/if}}
{{/if}} {{/if}}
</template> </template>

View file

@ -1,11 +1,27 @@
import { UserConfig } from "../imports/api/userConfig";
Template.MainLayout.onCreated(function() { Template.MainLayout.onCreated(function() {
this.subscribe("UserConfigPrefs");
}); });
Template.MainLayout.onRendered(function() { Template.MainLayout.onRendered(function() {
this.autorun(() => {
let myId = Meteor.userId();
let myprefs = UserConfig.findOne({ user: myId });
if (typeof myprefs != 'undefined') {
if (myprefs.darkPref == "light") {
console.log("Found theme as light");
// Session.set("myTheme", "light");
document.documentElement.setAttribute('theme', "light");
} else {
console.log("Found theme as dark");
// Session.set("myTheme", "dark");
document.documentElement.setAttribute('theme', "dark");
}
} else {
console.log("User Prefs appear undefined.");
}
});
}); });
Template.MainLayout.helpers({ Template.MainLayout.helpers({

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,26 +1,12 @@
body { body {
padding: 10px; padding: 10px;
font-family: sans-serif; font-family: sans-serif;
background-color: #F9FBFC;
} }
.clickable, .closeIcon, .dispo { .clickable, .closeIcon, .dispo {
cursor: pointer; cursor: pointer;
} }
.dark-mode {
background: #191818;
color: #fcfcfc;
}
input.dark-mode {
color: #fcfcfc;
}
select.dark-mode {
color: #fcfcfc;
}
li.collection-item { li.collection-item {
font-size: 20px; font-size: 20px;

42
imports/api/userConfig.js Normal file
View file

@ -0,0 +1,42 @@
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { check } from 'meteor/check';
export const UserConfig = new Mongo.Collection('userConfig');
UserConfig.allow({
insert: function(userId, doc){
// if use id exists, allow insert
return !!userId;
},
});
Meteor.methods({
'add.darkModePref' (pref) {
check(pref, String);
if (!this.userId) {
throw new Meteor.Error('Not able to change registration setting. Make sure you are logged in with valid system administrator credentials.');
}
return UserConfig.insert({
user: this.userId,
darkMode: pref,
dateAdded: Date()
});
},
'update.darkModePref' (pref) {
check(pref, String);
if (!this.userId) {
throw new Meteor.Error('Not able to change registration setting. Make sure you are logged in with valid system administrator credentials.');
}
return UserConfig.update({ user: this.userId }, {
$set: {
darkMode: pref,
dateUpdate: Date()
}
});
}
});

View file

@ -11,7 +11,7 @@ Meteor.methods({
console.log("User id for role: " + Meteor.userId() ); console.log("User id for role: " + Meteor.userId() );
let userId = Meteor.userId(); let userId = Meteor.userId();
Roles.addUsersToRoles(userId, role); Roles.addUsersToRoles(userId, role);
Meteor.call('add.darkPref', false, function(err, result) { Meteor.call('add.darkModePref', "light", function(err, result) {
if (err) { if (err) {
console.log(" ERROR: can't set user dark mode preference: " + err); console.log(" ERROR: can't set user dark mode preference: " + err);
} else { } else {
@ -22,7 +22,7 @@ Meteor.methods({
console.log("Creating first system admin user: " + Meteor.userId() ); console.log("Creating first system admin user: " + Meteor.userId() );
let userId = Meteor.userId(); let userId = Meteor.userId();
Roles.addUsersToRoles(userId, "systemadmin"); Roles.addUsersToRoles(userId, "systemadmin");
Meteor.call('add.darkPref', false, function(err, result) { Meteor.call('add.darkModePref', "light", function(err, result) {
if (err) { if (err) {
console.log(" ERROR: can't set user dark mode preference: " + err); console.log(" ERROR: can't set user dark mode preference: " + err);
} else { } else {

View file

@ -8,6 +8,7 @@ import { Menus } from '../imports/api/menu.js';
import { MenuItems } from '../imports/api/menuItems.js'; import { MenuItems } from '../imports/api/menuItems.js';
import moment from 'moment'; import moment from 'moment';
import { TaskItems } from '../imports/api/tasks.js'; import { TaskItems } from '../imports/api/tasks.js';
import { UserConfig } from '../imports/api/userConfig.js';
Meteor.publish("SystemConfig", function() { Meteor.publish("SystemConfig", function() {
try { try {
@ -17,6 +18,14 @@ Meteor.publish("SystemConfig", function() {
} }
}); });
Meteor.publish("UserConfigPrefs", function() {
try {
return UserConfig.find({});
} catch (error) {
console.log(" ERROR: Error accessing user config: " + error);
}
});
Meteor.publish('userList', function() { Meteor.publish('userList', function() {
return Meteor.users.find({}); return Meteor.users.find({});
}); });
@ -37,6 +46,14 @@ Meteor.publish("myProducts", function() {
} }
}); });
Meteor.publish("limProducts", function(findItemVal) {
try {
return Products.find({ prodName: {$regex: findItemVal + '.*', $options: 'i' }});
} catch (error) {
cconsole.log(" ERROR pulling limited product data: " + error);
}
})
Meteor.publish("myLists", function() { Meteor.publish("myLists", function() {
try { try {
return Lists.find( { $or: [ { listOwner: this.userId, listComplete: false }, { listShared: true, listComplete: false } ] } ); return Lists.find( { $or: [ { listOwner: this.userId, listComplete: false }, { listShared: true, listComplete: false } ] } );
@ -47,7 +64,6 @@ Meteor.publish("myLists", function() {
Meteor.publish("myListItems", function(listId) { Meteor.publish("myListItems", function(listId) {
try { try {
// console.log("List Id is: " + listId);
return ListItems.find({ listId: listId }); return ListItems.find({ listId: listId });
} catch (error) { } catch (error) {
console.log(" ERROR pulling list items for this list: " + error); console.log(" ERROR pulling list items for this list: " + error);