Initial commit
This commit is contained in:
parent
9ed5089508
commit
78e0e82449
16 changed files with 317 additions and 15 deletions
49
client/General/Workouts/workouts.js
Normal file
49
client/General/Workouts/workouts.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue