mirror of
https://github.com/bodyrep/DemoApp.git
synced 2026-01-25 14:43:00 +00:00
added rudimentary admin pages, started testing validation code
This commit is contained in:
21
views/admin/exercise.jade
Normal file
21
views/admin/exercise.jade
Normal file
@@ -0,0 +1,21 @@
|
||||
extends ../layout
|
||||
|
||||
block content
|
||||
h1 Bodyrep
|
||||
p Exercise Admin
|
||||
|
||||
p
|
||||
a(href="/users") List Users
|
||||
p
|
||||
a(href="/workouts") List workouts
|
||||
p
|
||||
a(href="/admin") Admin Index
|
||||
p
|
||||
a(href="/admin/users") Admin Users
|
||||
p
|
||||
a(href="/admin/exercises") Admin Exercises
|
||||
p
|
||||
a(href="/admin/exercises/new") Add Exercise
|
||||
hr
|
||||
|
||||
p= exercise
|
||||
37
views/admin/exercises.jade
Normal file
37
views/admin/exercises.jade
Normal file
@@ -0,0 +1,37 @@
|
||||
extends ../layout
|
||||
|
||||
block content
|
||||
h1 Bodyrep
|
||||
p Exercise Admin
|
||||
|
||||
p
|
||||
a(href="/users") List Users
|
||||
p
|
||||
a(href="/workouts") List workouts
|
||||
p
|
||||
a(href="/admin") Admin Index
|
||||
p
|
||||
a(href="/admin/users") Admin Users
|
||||
p
|
||||
a(href="/admin/exercises") Admin Exercises
|
||||
p
|
||||
a(href="/admin/exercises/new") Add Exercise
|
||||
hr
|
||||
|
||||
ul
|
||||
- exercises.forEach(function(exercise) {
|
||||
li
|
||||
a(href="/admin/exercises/" + encodeURIComponent(exercise._id))= exercise.name
|
||||
form(action="/admin/exercises/" + encodeURIComponent(exercise._id), method="POST")
|
||||
input(name="_method", type="hidden", value="DELETE")
|
||||
input(type="submit", value="Delete")
|
||||
- });
|
||||
|
||||
- if (page > 0) {
|
||||
a(href="?page=" + (page - 1)) Previous
|
||||
|
||||
- }
|
||||
|
||||
- if (! lastPage) {
|
||||
a(href="?page=" + (page + 1)) Next
|
||||
- }
|
||||
16
views/admin/index.jade
Normal file
16
views/admin/index.jade
Normal file
@@ -0,0 +1,16 @@
|
||||
extends ../layout
|
||||
|
||||
block content
|
||||
h1 Bodyrep
|
||||
p Admin Index
|
||||
|
||||
p
|
||||
a(href="/users") List Users
|
||||
p
|
||||
a(href="/workouts") List workouts
|
||||
p
|
||||
a(href="/admin") Admin Index
|
||||
p
|
||||
a(href="/admin/users") Admin Users
|
||||
p
|
||||
a(href="/admin/exercises") Admin Exercises
|
||||
44
views/admin/newexercise.jade
Normal file
44
views/admin/newexercise.jade
Normal file
@@ -0,0 +1,44 @@
|
||||
extends ../layout
|
||||
|
||||
block additionalscripts
|
||||
script(src='/javascripts/newexercisevalidation.js')
|
||||
|
||||
block content
|
||||
h1 New Exercise<p></p>
|
||||
|
||||
form(method="POST", action="/admin/exercises")
|
||||
ul
|
||||
li
|
||||
label(for="name") Exercise Name<br />Need to add check to ensure we donbt get duplicate names<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='0130') Exercise Machines
|
||||
option(value='0200') Bodyweight
|
||||
option(value='0200') Kettlebells
|
||||
option(value='0200') Cardio
|
||||
|
||||
li
|
||||
label(for="type") Exercise Description<br />
|
||||
input#description(name="description", class="needsnumber")
|
||||
li
|
||||
label(for="type") Exercise Difficulty<br />
|
||||
input#difficulty(name="difficulty")
|
||||
i = 0
|
||||
- for (i ; i < 10; ++i) {
|
||||
marray = "musclearray[" + i + "]"
|
||||
li
|
||||
label(for="type") Muscle data #{i}
|
||||
input(name= marray, class= marray, id= marray)
|
||||
- }
|
||||
li
|
||||
label(for="type") Keywords<br />
|
||||
li
|
||||
label(for="type") Alternatives<br />
|
||||
li
|
||||
label(for="type") Datafields<br />
|
||||
li
|
||||
input(type="submit", value="Create")
|
||||
14
views/admin/newexercisevalidation.jade
Normal file
14
views/admin/newexercisevalidation.jade
Normal file
@@ -0,0 +1,14 @@
|
||||
/script(
|
||||
$(document).ready(function() {
|
||||
////Validation
|
||||
var name = new LiveValidation('name');
|
||||
name.add( Validate.Format, { pattern: /^\s*[a-zA-Z0-9,\s]+\s*$/ } );
|
||||
name.add( Validate.Length, { minimum: 3, maximum: 12 , failureMessage: "Please enter a valid name" } );
|
||||
var type = new LiveValidation('type');
|
||||
type.add( Validate.Exclusion, { within: ['notselected', 'Select One'], failureMessage: "Please select an entry from the list" } );
|
||||
var difficulty = new LiveValidation('difficulty');
|
||||
difficulty.add( Validate.Numericality, { minimum: 1, maximum: 10, onlyInteger: true, failureMessage: "Must be a number between 1 and 10" });
|
||||
var description = new LiveValidation('description');
|
||||
description.add( Validate.Format, { pattern: /^\s*[a-zA-Z0-9,\s]+\s*$/ } );
|
||||
});
|
||||
/)
|
||||
36
views/admin/users.jade
Normal file
36
views/admin/users.jade
Normal file
@@ -0,0 +1,36 @@
|
||||
extends ../layout
|
||||
|
||||
block content
|
||||
h1 Bodyrep
|
||||
p User Admin
|
||||
|
||||
p
|
||||
a(href="/users") List Users
|
||||
p
|
||||
a(href="/workouts") List workouts
|
||||
p
|
||||
a(href="/admin") Admin Index
|
||||
p
|
||||
a(href="/admin/users") Admin Users
|
||||
p
|
||||
a(href="/admin/exercises") Admin Exercises
|
||||
|
||||
hr
|
||||
|
||||
ul
|
||||
- users.forEach(function(user) {
|
||||
li
|
||||
a(href="/users/" + encodeURIComponent(user.username))= user.name
|
||||
form(action="/admin/users/" + encodeURIComponent(user._id), method="POST")
|
||||
input(name="_method", type="hidden", value="DELETE")
|
||||
input(type="submit", value="Delete")
|
||||
- });
|
||||
|
||||
- if (page > 0) {
|
||||
a(href="?page=" + (page - 1)) Previous
|
||||
|
||||
- }
|
||||
|
||||
- if (! lastPage) {
|
||||
a(href="?page=" + (page + 1)) Next
|
||||
- }
|
||||
Reference in New Issue
Block a user