Adding more methods and views, updated dashboards a bit. Still not ready

This commit is contained in:
Brian McGonagill 2022-08-16 16:46:14 -05:00
parent 266dbd0856
commit 42643a37f5
23 changed files with 374 additions and 32 deletions

View file

@ -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);
}
});
}
}
}
});