mirror of
https://github.com/bodyrep/DemoApp.git
synced 2026-02-07 13:01:45 +00:00
added basic sortable to workout creation
This commit is contained in:
@@ -1,20 +1,13 @@
|
|||||||
var Schema = require('mongoose').Schema;
|
var Schema = require('mongoose').Schema;
|
||||||
|
|
||||||
var Datafield = new Schema({
|
|
||||||
datafieldname: { type: String},
|
|
||||||
datafieldtype: { type: String}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
var exerciseSchema = new Schema({
|
var exerciseSchema = new Schema({
|
||||||
name: {type: String, unique: true, required: true},
|
name: {type: String, unique: true, required: true},
|
||||||
type: String,
|
|
||||||
description: String,
|
description: String,
|
||||||
difficulty: Number,
|
difficulty: Number,
|
||||||
musclearray: [Number],
|
musclearray: [Number],
|
||||||
keywords: [String],
|
keywords: [String],
|
||||||
alternatives: [String],
|
alternatives: [String],
|
||||||
datafields: [Datafield]
|
datafields: [String]
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = exerciseSchema;
|
module.exports = exerciseSchema;
|
||||||
@@ -37,8 +37,7 @@ $("#newexercise").validate({
|
|||||||
required: true,
|
required: true,
|
||||||
maxlength: 24
|
maxlength: 24
|
||||||
},
|
},
|
||||||
type: {
|
keywords: {
|
||||||
notEqual: "notselected",
|
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ $(document).ready(function() {
|
|||||||
cancel: ':input, button' ,
|
cancel: ':input, button' ,
|
||||||
placeholder: "ui-state-highlight",
|
placeholder: "ui-state-highlight",
|
||||||
revert: true,
|
revert: true,
|
||||||
|
start: function(e, ui){
|
||||||
|
ui.placeholder.height(ui.item.height());
|
||||||
|
},
|
||||||
stop: function(event, ui) {
|
stop: function(event, ui) {
|
||||||
$('#newworkout').trigger('sortupdate');
|
$('#newworkout').trigger('sortupdate');
|
||||||
}
|
}
|
||||||
@@ -78,6 +81,9 @@ $(document).ready(function() {
|
|||||||
cancel: ':input, button' ,
|
cancel: ':input, button' ,
|
||||||
placeholder: "ui-state-highlight",
|
placeholder: "ui-state-highlight",
|
||||||
revert: true,
|
revert: true,
|
||||||
|
start: function(e, ui){
|
||||||
|
ui.placeholder.height(ui.item.height());
|
||||||
|
},
|
||||||
stop: function(event, ui) {
|
stop: function(event, ui) {
|
||||||
$('#newworkout').trigger('sortupdate');
|
$('#newworkout').trigger('sortupdate');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,23 +7,22 @@ a {
|
|||||||
color: #00B7FF;
|
color: #00B7FF;
|
||||||
}
|
}
|
||||||
|
|
||||||
li {
|
ul, menu, dir {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
|
||||||
|
|
||||||
#sortable ul {
|
#sortable ul {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#sortable li {
|
/*#sortable li {
|
||||||
margin: 0 3px 3px 3px;
|
margin: 0 3px 3px 3px;
|
||||||
padding: 0.4em;
|
padding: 0.4em;
|
||||||
padding-left: 1.5em;
|
padding-left: 1.5em;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
label {
|
label {
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ var notLoggedIn = require('./middleware/not_logged_in');
|
|||||||
var loadWorkout = require('./middleware/load_workout');
|
var loadWorkout = require('./middleware/load_workout');
|
||||||
var loggedIn = require('./middleware/logged_in');
|
var loggedIn = require('./middleware/logged_in');
|
||||||
var maxWorkoutsPerPage = 5;
|
var maxWorkoutsPerPage = 5;
|
||||||
|
var Exercise = require('../data/models/exercise');
|
||||||
|
var loadExercise = require('./middleware/load_exercise');
|
||||||
var Moment = require('moment');
|
var Moment = require('moment');
|
||||||
|
|
||||||
module.exports = function(app) {
|
module.exports = function(app) {
|
||||||
@@ -57,6 +59,22 @@ module.exports = function(app) {
|
|||||||
res.render('workouts/new', {title: "New workout"});
|
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){
|
app.get('/workouts/:_id', loadWorkout, function(req, res, next){
|
||||||
console.log("time" + Moment.utc(req.workout.workoutDate).format("ddd, hA"));
|
console.log("time" + Moment.utc(req.workout.workoutDate).format("ddd, hA"));
|
||||||
res.render('workouts/workout', {title: req.workout.title,
|
res.render('workouts/workout', {title: req.workout.title,
|
||||||
|
|||||||
@@ -11,16 +11,6 @@ block content
|
|||||||
li
|
li
|
||||||
label(for="name") Exercise Name<br />
|
label(for="name") Exercise Name<br />
|
||||||
input#name(name="name")
|
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
|
li
|
||||||
label(for="type") Exercise Description<br />
|
label(for="type") Exercise Description<br />
|
||||||
input#description(name="description", class="needsnumber")
|
input#description(name="description", class="needsnumber")
|
||||||
@@ -36,9 +26,20 @@ block content
|
|||||||
- }
|
- }
|
||||||
li
|
li
|
||||||
label(for="type") Keywords<br />
|
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
|
li
|
||||||
label(for="type") Alternatives<br />
|
label(for="type") Alternatives<br />
|
||||||
li
|
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
|
li
|
||||||
input(type="submit", value="Create")
|
input(type="submit", value="Create")
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
html
|
html
|
||||||
head
|
head
|
||||||
title BodyREP - #{title}
|
title BodyREP - #{title}
|
||||||
link(rel='stylesheet', '/stylesheets/style.css')
|
|
||||||
include scripts
|
include scripts
|
||||||
block additionalscripts
|
block additionalscripts
|
||||||
body
|
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://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='http://jzaefferer.github.com/jquery-validation/jquery.validate.js')
|
||||||
script(src='/javascripts/scripts.js')
|
script(src='/javascripts/scripts.js')
|
||||||
|
|
||||||
//script(src='/javascripts/livevalidation_standalone.compressed.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/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/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