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

View file

@ -18,9 +18,9 @@
<div class="row">
<div class="col s12 m12 l12">
{{#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}}
<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}}
</div>
</div>

View file

@ -3,7 +3,8 @@ Template.deleteConfirmationModal.onCreated(function() {
});
Template.deleteConfirmationModal.onRendered(function() {
$('.modal').modal();
// put new modal init here
// $('.modal').modal();
});
Template.deleteConfirmationModal.helpers({
@ -26,7 +27,8 @@ Template.deleteConfirmationModal.events({
console.log(" ERROR deleting item from modal: " + err);
} else {
// 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.onRendered(function() {
$('.sidenav').sidenav();
setTimeout(function() {
$('.sidenav').sidenav();
$(".dropdown-trigger").dropdown();
$('.collapsible').collapsible();
}, 200)
$(".dropdown-trigger").dropdown();
$('.collapsible').collapsible();
var elems = document.querySelectorAll('.sidenav');
var instances = M.Sidenav.init(elems, {});
var elemd = document.querySelectorAll('.dropdown-trigger');
var instances = M.Dropdown.init(elemd, {});
});
Template.headerBar.helpers({

View file

@ -1,11 +1,12 @@
import { M } from '../../lib/assets/materialize.js';
Template.myModal.onCreated(function() {
});
Template.myModal.onRendered(function() {
$('.modal').modal();
var elems = document.querySelectorAll('.modal');
var instances = M.Modal.init(elems, {});
});
Template.myModal.helpers({
@ -30,7 +31,7 @@ Template.myModal.events({
} else {
$("#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) {

View file

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

View file

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

View file

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

View file

@ -1,11 +1,27 @@
import { UserConfig } from "../imports/api/userConfig";
Template.MainLayout.onCreated(function() {
this.subscribe("UserConfigPrefs");
});
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({

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 {
padding: 10px;
font-family: sans-serif;
background-color: #F9FBFC;
}
.clickable, .closeIcon, .dispo {
cursor: pointer;
}
.dark-mode {
background: #191818;
color: #fcfcfc;
}
input.dark-mode {
color: #fcfcfc;
}
select.dark-mode {
color: #fcfcfc;
}
li.collection-item {
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() );
let userId = Meteor.userId();
Roles.addUsersToRoles(userId, role);
Meteor.call('add.darkPref', false, function(err, result) {
Meteor.call('add.darkModePref', "light", function(err, result) {
if (err) {
console.log(" ERROR: can't set user dark mode preference: " + err);
} else {
@ -22,7 +22,7 @@ Meteor.methods({
console.log("Creating first system admin user: " + Meteor.userId() );
let userId = Meteor.userId();
Roles.addUsersToRoles(userId, "systemadmin");
Meteor.call('add.darkPref', false, function(err, result) {
Meteor.call('add.darkModePref', "light", function(err, result) {
if (err) {
console.log(" ERROR: can't set user dark mode preference: " + err);
} else {

View file

@ -8,6 +8,7 @@ import { Menus } from '../imports/api/menu.js';
import { MenuItems } from '../imports/api/menuItems.js';
import moment from 'moment';
import { TaskItems } from '../imports/api/tasks.js';
import { UserConfig } from '../imports/api/userConfig.js';
Meteor.publish("SystemConfig", function() {
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() {
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() {
try {
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) {
try {
// console.log("List Id is: " + listId);
return ListItems.find({ listId: listId });
} catch (error) {
console.log(" ERROR pulling list items for this list: " + error);