mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-26 15:58:50 +00:00
66 lines
No EOL
2.3 KiB
JavaScript
66 lines
No EOL
2.3 KiB
JavaScript
import { Lists } from '../../imports/api/lists.js';
|
|
import { M } from '../lib/assets/materialize.js';
|
|
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
|
|
|
|
Template.listsTbl.onCreated(function() {
|
|
this.subscribe("myLists");
|
|
});
|
|
|
|
Template.listsTbl.onRendered(function() {
|
|
var elems = document.querySelectorAll('.modal');
|
|
var instances = M.Modal.init(elems, {});
|
|
});
|
|
|
|
Template.listsTbl.helpers({
|
|
mylists: function() {
|
|
return Lists.find({});
|
|
},
|
|
});
|
|
|
|
Template.listsTbl.events({
|
|
'click li.collection-item' (event) {
|
|
event.preventDefault();
|
|
let sender = event.target;
|
|
if (sender.localName == "li" || sender.localName == "span") {
|
|
let listId = event.currentTarget.id;
|
|
if (listId == "addList") {
|
|
// opens the modal and allows you to add a new List
|
|
} else {
|
|
console.log("listId is: " + listId);
|
|
Session.set("listId", listId);
|
|
const addUserLast = async() => {
|
|
let result = await Meteor.callAsync('add.userLast', "List", listId);
|
|
if (!result) {
|
|
console.log(" ERROR setting user last list id in db: " + err);
|
|
} else {
|
|
setTimeout(function() {
|
|
FlowRouter.go('/listitems');
|
|
}, 100);
|
|
}
|
|
}
|
|
addUserLast();
|
|
}
|
|
}
|
|
},
|
|
'click i.markAsComplete' (event) {
|
|
event.preventDefault();
|
|
let sender = event.target;
|
|
if (sender.localName == "i") {
|
|
let listFullId = event.currentTarget.id;
|
|
let splitList = listFullId.split("_");
|
|
let listId = splitList[1];
|
|
// console.log("listId is " + listId);
|
|
const markComp = async() => {
|
|
let result = await Meteor.callAsync("mark.complete", listId);
|
|
if (!result) {
|
|
console.log(" ERROR marking list complete!");
|
|
showSnackbar("ERROR! List Not Makred Complete!", "red");
|
|
} else {
|
|
// console.log(" SUCCESS marking list complete.");
|
|
showSnackbar("List Marked Complete!", "green");
|
|
}
|
|
}
|
|
markComp();
|
|
}
|
|
}
|
|
}); |