mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-26 15:58:50 +00:00
42 lines
No EOL
1.2 KiB
JavaScript
42 lines
No EOL
1.2 KiB
JavaScript
import { Menus } from '../../imports/api/menu.js';
|
|
import { M } from '../lib/assets/materialize.js';
|
|
|
|
Template.addMenuModal.onCreated(function() {
|
|
this.subscribe("myMenus");
|
|
});
|
|
|
|
Template.addMenuModal.onRendered(function() {
|
|
Session.set("menuNameErr", false);
|
|
var elems = document.querySelectorAll('.modal');
|
|
var instances = M.Modal.init(elems, {});
|
|
});
|
|
|
|
Template.addMenuModal.helpers({
|
|
menuNameErr: function() {
|
|
return Session.get("menuNameErr");
|
|
},
|
|
editMode: function() {
|
|
return Session.get("menuEditMode");
|
|
}
|
|
});
|
|
|
|
Template.addMenuModal.events({
|
|
'click .saveMenu' (event) {
|
|
event.preventDefault();
|
|
let menuName = $("#menuNameInp").val();
|
|
if (menuName == "" || menuName == null) {
|
|
Session.set("menuNameErr", true);
|
|
} else {
|
|
const addMenu = async() => {
|
|
let result = await Meteor.callAsync("add.menu", menuName);
|
|
if (!result) {
|
|
console.log(" ERROR adding menu: " + err);
|
|
} else {
|
|
console.log(" SUCCESS adding menu.");
|
|
$("#menuNameInp").val("");
|
|
}
|
|
}
|
|
addMenu();
|
|
}
|
|
},
|
|
}); |