55 lines
No EOL
1.7 KiB
JavaScript
55 lines
No EOL
1.7 KiB
JavaScript
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
|
|
import { Workouts } from '../../../imports/api/workouts.js';
|
|
import { WorkoutLog } from '../../../imports/api/workoutLog.js';
|
|
|
|
Template.workouts.onCreated(function() {
|
|
this.subscribe("myWorkoutRoutines");
|
|
});
|
|
|
|
Template.workouts.onRendered(function() {
|
|
Session.set("showAddRoutineForm", false);
|
|
});
|
|
|
|
Template.workouts.helpers({
|
|
showAddRoutineForm: function() {
|
|
return Session.get("showAddRoutineForm");
|
|
},
|
|
workoutRoutines: function() {
|
|
return Workouts.find({});
|
|
},
|
|
});
|
|
|
|
Template.workouts.events({
|
|
'click #addRoutine' (e) {
|
|
Session.set("showAddRoutineForm", true);
|
|
},
|
|
'click #addRoutineForm' (e) {
|
|
let routineName = $("#routineName").val();
|
|
|
|
if (routineName == "" || routineName == null) {
|
|
showSnackbar("Routine Name is Required!", "red");
|
|
return;
|
|
} else {
|
|
console.log("Routine Name: " + routineName);
|
|
const addWorkout = async() => {
|
|
try {
|
|
const result = await Meteor.callAsync('add.workoutRoutine', routineName);
|
|
if (!result) {
|
|
console.log("An issue occurred adding the routing name.");
|
|
} else {
|
|
console.log("Routine added : " + result);
|
|
}
|
|
} catch(error) {
|
|
console.log(" ERROR adding routine nemae: " + error);
|
|
}
|
|
}
|
|
addWorkout();
|
|
}
|
|
},
|
|
'click .routine' (e) {
|
|
let routineId = e.currentTarget.id;
|
|
console.log("Routine ID set: " + routineId);
|
|
Session.set("routineId", routineId);
|
|
FlowRouter.go('/workoutLog');
|
|
},
|
|
}); |