mirror of
https://github.com/bodyrep/DemoApp.git
synced 2025-12-06 06:01:48 +00:00
added basic sortable to workout creation
This commit is contained in:
@@ -1,20 +1,13 @@
|
||||
var Schema = require('mongoose').Schema;
|
||||
|
||||
var Datafield = new Schema({
|
||||
datafieldname: { type: String},
|
||||
datafieldtype: { type: String}
|
||||
});
|
||||
|
||||
|
||||
var exerciseSchema = new Schema({
|
||||
name: {type: String, unique: true, required: true},
|
||||
type: String,
|
||||
description: String,
|
||||
difficulty: Number,
|
||||
musclearray: [Number],
|
||||
keywords: [String],
|
||||
alternatives: [String],
|
||||
datafields: [Datafield]
|
||||
datafields: [String]
|
||||
});
|
||||
|
||||
module.exports = exerciseSchema;
|
||||
@@ -37,8 +37,7 @@ $("#newexercise").validate({
|
||||
required: true,
|
||||
maxlength: 24
|
||||
},
|
||||
type: {
|
||||
notEqual: "notselected",
|
||||
keywords: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
@@ -27,6 +27,9 @@ $(document).ready(function() {
|
||||
cancel: ':input, button' ,
|
||||
placeholder: "ui-state-highlight",
|
||||
revert: true,
|
||||
start: function(e, ui){
|
||||
ui.placeholder.height(ui.item.height());
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
$('#newworkout').trigger('sortupdate');
|
||||
}
|
||||
@@ -78,6 +81,9 @@ $(document).ready(function() {
|
||||
cancel: ':input, button' ,
|
||||
placeholder: "ui-state-highlight",
|
||||
revert: true,
|
||||
start: function(e, ui){
|
||||
ui.placeholder.height(ui.item.height());
|
||||
},
|
||||
stop: function(event, ui) {
|
||||
$('#newworkout').trigger('sortupdate');
|
||||
}
|
||||
|
||||
@@ -7,23 +7,22 @@ a {
|
||||
color: #00B7FF;
|
||||
}
|
||||
|
||||
li {
|
||||
ul, menu, dir {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
#sortable ul {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
|
||||
#sortable li {
|
||||
/*#sortable li {
|
||||
margin: 0 3px 3px 3px;
|
||||
padding: 0.4em;
|
||||
padding-left: 1.5em;
|
||||
height: 24px;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
*/
|
||||
label {
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
|
||||
@@ -9,6 +9,8 @@ var notLoggedIn = require('./middleware/not_logged_in');
|
||||
var loadWorkout = require('./middleware/load_workout');
|
||||
var loggedIn = require('./middleware/logged_in');
|
||||
var maxWorkoutsPerPage = 5;
|
||||
var Exercise = require('../data/models/exercise');
|
||||
var loadExercise = require('./middleware/load_exercise');
|
||||
var Moment = require('moment');
|
||||
|
||||
module.exports = function(app) {
|
||||
@@ -57,6 +59,22 @@ module.exports = function(app) {
|
||||
res.render('workouts/new', {title: "New workout"});
|
||||
});
|
||||
|
||||
app.get('/workouts/exerciselist', function(req, res) {
|
||||
res.contentType('json');
|
||||
Exercise.find({})
|
||||
.exec(function(err, exercises) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (! exercise) {
|
||||
return res.send(JSON.stringify({ "error": "true" }));
|
||||
}
|
||||
res.send(exercises);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
app.get('/workouts/:_id', loadWorkout, function(req, res, next){
|
||||
console.log("time" + Moment.utc(req.workout.workoutDate).format("ddd, hA"));
|
||||
res.render('workouts/workout', {title: req.workout.title,
|
||||
|
||||
@@ -11,16 +11,6 @@ block content
|
||||
li
|
||||
label(for="name") Exercise Name<br />
|
||||
input#name(name="name")
|
||||
li
|
||||
label(for="type") Exercise Type<br />
|
||||
select#type(name="type")
|
||||
option(value='notselected') Select One
|
||||
option(value='freeweights') Free Weights
|
||||
option(value='machine') Exercise Machines
|
||||
option(value='bodyweight') Bodyweight
|
||||
option(value='kettlebells') Kettlebells
|
||||
option(value='cardio') Cardio
|
||||
|
||||
li
|
||||
label(for="type") Exercise Description<br />
|
||||
input#description(name="description", class="needsnumber")
|
||||
@@ -36,9 +26,20 @@ block content
|
||||
- }
|
||||
li
|
||||
label(for="type") Keywords<br />
|
||||
select#type(name="keywords", multiple="multiple")
|
||||
option(value='Free Weights') Free Weights
|
||||
option(value='Exercise Machine') Exercise Machines
|
||||
option(value='Bodyweight') Bodyweight
|
||||
option(value='Kettlebells') Kettlebells
|
||||
option(value='Cardio') Cardio
|
||||
li
|
||||
label(for="type") Alternatives<br />
|
||||
li
|
||||
label(for="type") Datafields<br />
|
||||
label(for="datafields") Datafields<br />
|
||||
select#type(name="datafields", multiple="multiple")
|
||||
option(value='Reps') Reps
|
||||
option(value='Weight') Weight
|
||||
option(value='Time') Time
|
||||
option(value='Distance') Distance
|
||||
li
|
||||
input(type="submit", value="Create")
|
||||
@@ -2,7 +2,6 @@
|
||||
html
|
||||
head
|
||||
title BodyREP - #{title}
|
||||
link(rel='stylesheet', '/stylesheets/style.css')
|
||||
include scripts
|
||||
block additionalscripts
|
||||
body
|
||||
|
||||
@@ -2,6 +2,9 @@ script(src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js')
|
||||
script(src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js')
|
||||
script(src='http://jzaefferer.github.com/jquery-validation/jquery.validate.js')
|
||||
script(src='/javascripts/scripts.js')
|
||||
|
||||
//script(src='/javascripts/livevalidation_standalone.compressed.js')
|
||||
//link(rel='stylesheet', href='/stylesheets/smoothness/jquery-ui-1.8.20.custom.css',type='text/css' )
|
||||
|
||||
link(rel='stylesheet', href='/stylesheets/redmond/jquery-ui-1.10.0.custom.css',type='text/css' )
|
||||
link(rel='stylesheet', href='/stylesheets/style.css')
|
||||
Reference in New Issue
Block a user